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

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

[nongnu] elpa/emacsql 8b2cf8c208 041/427: Fix up :where.


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql 8b2cf8c208 041/427: Fix up :where.
Date: Tue, 13 Dec 2022 02:59:26 -0500 (EST)

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

    Fix up :where.
---
 emacsql.el | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/emacsql.el b/emacsql.el
index e130a531a2..b5ccb82a6b 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -328,11 +328,15 @@ and should return a list of (<string> [arg-pos] ...)."
   (cl-destructuring-bind (format . vars) expansion
     (apply #'format format
            (cl-loop for (i . kind) in vars collect
-                    (cl-ecase kind
-                      (:identifier (emacsql-escape (nth i args)))
-                      (:value (emacsql-escape-value (nth i args))))))))
-
-(defun emacsql (conn sql &optional args)
+                    (let ((thing (nth i args)))
+                      (cl-ecase kind
+                        (:identifier (emacsql-escape thing))
+                        (:value (emacsql-escape-value thing))
+                        (:auto (if (symbolp thing)
+                                   (emacsql-escape thing)
+                                 (emacsql-escape-value thing)))))))))
+
+(defun emacsql (conn sql &rest args)
   "Send structured SQL expression to CONN with ARGS."
   (emacsql--clear conn)
   (emacsql--send conn (apply #'emacsql-format (emacsql-expand sql) args))
@@ -393,18 +397,18 @@ KIND should be :value or :identifier."
 
 (emacsql-defexpander :where (expr)
   (let ((vars ()))
-    (cl-flet* ((collect (thing kind)
-                 (push (cons (emacsql-var thing) kind) vars) "%s")
+    (cl-flet* ((collect (thing)
+                 (push (cons (emacsql-var thing) :auto) vars) "%s")
                (handle (v)
                  (cond ((emacsql-var v) (collect v))
                        ((symbolp v) (emacsql-escape-format v :identifier))
-                       ((emacsql-escape-value v)))))
+                       ((emacsql-escape-format v :value)))))
       (cl-destructuring-bind (op a b) expr
         (cons (format "WHERE %s %s %s"
                       (handle a)
                       op
                       (handle b))
-              vars)))))
+              (nreverse vars))))))
 
 (provide 'emacsql)
 



reply via email to

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