diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2011-10-18 10:15:04 -0600 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2011-10-18 10:15:04 -0600 |
commit | faaa881c50ae58be301de7afbd5ef8438fe4523e (patch) | |
tree | f93221ffe66e534228c46b7d91d6d930ed59f2de | |
parent | c1ac64094479cb24b94cc53b9f59726ce9767240 (diff) | |
download | org-mode-faaa881c50ae58be301de7afbd5ef8438fe4523e.tar.gz |
ob-sql returns literal results when requested
* lisp/ob-sql.el (org-babel-execute:sql): Respect literal-results options.
-rw-r--r-- | lisp/ob-sql.el | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index c526148..fb0d7d6 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -84,31 +84,37 @@ This function is called by `org-babel-execute-src-block'." (insert (org-babel-expand-body:sql body params))) (message command) (shell-command command) - (with-temp-buffer - ;; need to figure out what the delimiter is for the header row + (if (or (member "scalar" result-params) + (member "verbatim" result-params) + (member "html" result-params) + (member "code" result-params) + (equal (point-min) (point-max))) + (progn (insert-file-contents-literally out-file) (buffer-string)) (with-temp-buffer - (insert-file-contents out-file) - (goto-char (point-min)) - (when (re-search-forward "^\\(-+\\)[^-]" nil t) - (setq header-delim (match-string-no-properties 1))) - (goto-char (point-max)) - (forward-char -1) - (while (looking-at "\n") - (delete-char 1) - (goto-char (point-max)) - (forward-char -1)) - (write-file out-file)) - (org-table-import out-file '(16)) - (org-babel-reassemble-table - (mapcar (lambda (x) - (if (string= (car x) header-delim) - 'hline - x)) - (org-table-to-lisp)) - (org-babel-pick-name (cdr (assoc :colname-names params)) - (cdr (assoc :colnames params))) - (org-babel-pick-name (cdr (assoc :rowname-names params)) - (cdr (assoc :rownames params))))))) + ;; need to figure out what the delimiter is for the header row + (with-temp-buffer + (insert-file-contents out-file) + (goto-char (point-min)) + (when (re-search-forward "^\\(-+\\)[^-]" nil t) + (setq header-delim (match-string-no-properties 1))) + (goto-char (point-max)) + (forward-char -1) + (while (looking-at "\n") + (delete-char 1) + (goto-char (point-max)) + (forward-char -1)) + (write-file out-file)) + (org-table-import out-file '(16)) + (org-babel-reassemble-table + (mapcar (lambda (x) + (if (string= (car x) header-delim) + 'hline + x)) + (org-table-to-lisp)) + (org-babel-pick-name (cdr (assoc :colname-names params)) + (cdr (assoc :colnames params))) + (org-babel-pick-name (cdr (assoc :rowname-names params)) + (cdr (assoc :rownames params)))))))) (defun org-babel-sql-expand-vars (body vars) "Expand the variables held in VARS in BODY." |