diff options
author | Kyle Meyer <kyle@kyleam.com> | 2021-09-29 18:48:59 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2021-09-29 23:21:21 -0400 |
commit | bf9ec3d91a79414deac039f7bf83352a9b0a9a85 (patch) | |
tree | 5e636992801ca408a26f7b7532c666d24c80020e /lisp/org/ob-sqlite.el | |
parent | dc94ca7b2b878c9a88be72fea118bf6557259ffd (diff) | |
download | emacs-bf9ec3d91a79414deac039f7bf83352a9b0a9a85.tar.gz emacs-bf9ec3d91a79414deac039f7bf83352a9b0a9a85.tar.bz2 emacs-bf9ec3d91a79414deac039f7bf83352a9b0a9a85.zip |
Update to Org 9.5
Diffstat (limited to 'lisp/org/ob-sqlite.el')
-rw-r--r-- | lisp/org/ob-sqlite.el | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/lisp/org/ob-sqlite.el b/lisp/org/ob-sqlite.el index 6e21fa9fd9a..7bfb66cf688 100644 --- a/lisp/org/ob-sqlite.el +++ b/lisp/org/ob-sqlite.el @@ -3,6 +3,7 @@ ;; Copyright (C) 2010-2021 Free Software Foundation, Inc. ;; Author: Eric Schulte +;; Maintainer: Nick Savage ;; Keywords: literate programming, reproducible research ;; Homepage: https://orgmode.org @@ -27,6 +28,7 @@ ;;; Code: (require 'ob) +(require 'ob-sql) (declare-function org-table-convert-region "org-table" (beg0 end0 &optional separator)) @@ -51,8 +53,8 @@ (defun org-babel-expand-body:sqlite (body params) "Expand BODY according to the values of PARAMS." - (org-babel-sqlite-expand-vars - body (org-babel--get-vars params))) + (org-babel-sql-expand-vars + body (org-babel--get-vars params) t)) (defvar org-babel-sqlite3-command "sqlite3") @@ -112,22 +114,8 @@ This function is called by `org-babel-execute-src-block'." (defun org-babel-sqlite-expand-vars (body vars) "Expand the variables held in VARS in BODY." - ;; FIXME: Redundancy with org-babel-sql-expand-vars! - (mapc - (lambda (pair) - (setq body - (replace-regexp-in-string - (format "$%s" (car pair)) - (let ((val (cdr pair))) - (if (listp val) - (let ((data-file (org-babel-temp-file "sqlite-data-"))) - (with-temp-file data-file - (insert (orgtbl-to-csv val nil))) - data-file) - (if (stringp val) val (format "%S" val)))) - body))) - vars) - body) + (declare (obsolete "use `org-babel-sql-expand-vars' instead." "9.5")) + (org-babel-sql-expand-vars body vars t)) (defun org-babel-sqlite-table-or-scalar (result) "If RESULT looks like a trivial table, then unwrap it." @@ -137,7 +125,7 @@ This function is called by `org-babel-execute-src-block'." (mapcar (lambda (row) (if (eq 'hline row) 'hline - (mapcar #'org-babel-string-read row))) + (mapcar #'org-babel-sqlite--read-cell row))) result))) (defun org-babel-sqlite-offset-colnames (table headers-p) @@ -151,6 +139,10 @@ This function is called by `org-babel-execute-src-block'." Prepare SESSION according to the header arguments specified in PARAMS." (error "SQLite sessions not yet implemented")) +(defun org-babel-sqlite--read-cell (cell) + "Process CELL to remove unnecessary characters." + (org-babel-read cell t)) + (provide 'ob-sqlite) ;;; ob-sqlite.el ends here |