From bf9ec3d91a79414deac039f7bf83352a9b0a9a85 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Wed, 29 Sep 2021 18:48:59 -0400 Subject: Update to Org 9.5 --- lisp/org/ob-sqlite.el | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'lisp/org/ob-sqlite.el') 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 -- cgit v1.2.3