emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/emacsql 3511a0df1d 037/427: Add a top-level query function


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql 3511a0df1d 037/427: Add a top-level query function, emacsql.
Date: Tue, 13 Dec 2022 02:59:25 -0500 (EST)

branch: elpa/emacsql
commit 3511a0df1d1a19d7be0b2507e16330eff6b12470
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>

    Add a top-level query function, emacsql.
---
 emacsql.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/emacsql.el b/emacsql.el
index 07a2b97901..ebb62d31b8 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -292,7 +292,7 @@ Each row must be a sequence of values to store into TABLE.
   (emacsql--check-error conn)
   (emacsql--parse conn))
 
-;; SQL Expansion Functions
+;; SQL Expansion:
 
 (defvar emacsql-expanders ()
   "Alist of all expansion functions.")
@@ -327,6 +327,13 @@ and should return a list of (<string> [arg-pos] ...)."
                       (:identifier (emacsql-escape (nth i args)))
                       (:value (emacsql-escape-value (nth i args))))))))
 
+(defun emacsql (conn sql &optional args)
+  "Send structured SQL expression to CONN with ARGS."
+  (emacsql--clear conn)
+  (emacsql--send conn (apply #'emacsql-format (emacsql-expand sql) args))
+  (emacsql--check-error conn)
+  (emacsql--parse conn))
+
 (defun emacsql-var (var)
   "Return the index number of VAR, or nil if VAR is not a variable.
 A variable is a symbol that looks like $1, $2, $3, etc. A $ means $1."
@@ -346,6 +353,8 @@ KIND should be :value or :identifier."
               (:identifier (emacsql-escape thing))
               (otherwise thing))))
 
+;; SQL Expansion Functions:
+
 (emacsql-defexpander :select (arg)
   "Expands to the SELECT keyword."
   (let ((vars ()))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]