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

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

[nongnu] elpa/emacsql f794d4d38f 116/427: Allow for selected columns in


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql f794d4d38f 116/427: Allow for selected columns in :insert-into.
Date: Tue, 13 Dec 2022 02:59:33 -0500 (EST)

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

    Allow for selected columns in :insert-into.
---
 README.md  | 1 +
 emacsql.el | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 46b2465ecb..318906e58a 100644
--- a/README.md
+++ b/README.md
@@ -166,6 +166,7 @@ Provides `INSERT INTO`.
 
 ```el
 [:insert-into employees ...]
+[:insert-into (employees [id name]) ...]
 ```
 
 #### :delete
diff --git a/emacsql.el b/emacsql.el
index 91be4b9b3a..548606715f 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -502,7 +502,12 @@ definitions for return from a `emacsql-defexpander'."
 (emacsql-defexpander :insert-into (table)
   "Expands to the INSERT INTO keywords."
   (emacsql-with-vars "INSERT INTO "
-    (var table :identifier)))
+    (cl-typecase table
+      (symbol (var table :identifier))
+      (list (cl-destructuring-bind (name columns) table
+              (format "%s (%s)" (var name :identifier)
+                      (mapconcat (lambda (c) (var c :identifier))
+                                 columns ", ")))))))
 
 (emacsql-defexpander :where (expr)
   (emacsql-with-vars "WHERE "



reply via email to

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