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

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

[nongnu] elpa/emacsql 616dde3752 361/427: An identifier named * means se


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql 616dde3752 361/427: An identifier named * means select all columns (#19)
Date: Tue, 13 Dec 2022 03:00:05 -0500 (EST)

branch: elpa/emacsql
commit 616dde37524f47246bbb161f20d3f5f090f10fbf
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Christopher Wellons <wellons@nullprogram.com>

    An identifier named * means select all columns (#19)
    
    For example:
    
        (emacsql conn [:select $i1 :from table] '*)
    
    Compiles to this SQL expression:
    
        SELECT * FROM table;
    
    Previously this compiled to:
    
        SELECT "*" FROM table;
    
    Which means to literally select the "*" column. That would be an insane
    schema.
---
 emacsql-compiler.el | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/emacsql-compiler.el b/emacsql-compiler.el
index 3267d18118..2885152c44 100644
--- a/emacsql-compiler.el
+++ b/emacsql-compiler.el
@@ -62,8 +62,11 @@
             (not (or (symbolp identifier)
                      (vectorp identifier))))
     (emacsql-error "Invalid identifier: %S" identifier))
-  (if (vectorp identifier)
-      (mapconcat #'emacsql-escape-identifier identifier ", ")
+  (cond
+   ((vectorp identifier)
+    (mapconcat #'emacsql-escape-identifier identifier ", "))
+   ((eq identifier '*) "*")
+   (t
     (let ((name (symbol-name identifier)))
       (if (string-match-p ":" name)
           (mapconcat #'emacsql-escape-identifier
@@ -74,7 +77,7 @@
                   (string-match-p "^[0-9$]" print)
                   (emacsql-reserved-p print))
               (emacsql-quote-identifier print)
-            print))))))
+            print)))))))
 
 (defun emacsql-escape-scalar (value)
   "Escape VALUE for sending to SQLite."



reply via email to

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