[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql 97e9764343 008/427: Change the API of emacsql-inse
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql 97e9764343 008/427: Change the API of emacsql-insert. |
Date: |
Tue, 13 Dec 2022 02:59:23 -0500 (EST) |
branch: elpa/emacsql
commit 97e9764343bebab0088c9c7c99fd53ac2b2f5615
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Change the API of emacsql-insert.
---
README.md | 4 ++--
emacsql.el | 21 +++++++++++++--------
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index 0db964a4b2..eae6f6aea2 100644
--- a/README.md
+++ b/README.md
@@ -18,8 +18,8 @@ requests are synchronous.
(emacsql-create db :employees '((name text) (id integer) salary))
;; Insert some data:
-(emacsql-insert db :employees "Jeff" 1000 60000)
-(emacsql-insert db :employees "Susan" 1001 64000)
+(emacsql-insert db :employees ["Jeff" 1000 60000]
+ ["Susan" 1001 64000])
;; The high-level SELECT interface is a work in progress.
(emacsql-select-raw db (concat "SELECT name, id FROM ':employees' "
diff --git a/emacsql.el b/emacsql.el
index 8c3d91c9ef..ed81295794 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -29,8 +29,8 @@
;; Insert values into a table with `emacsql-insert'.
-;; (emacsql-insert db :employees "Jeff" 1000 60000)
-;; (emacsql-insert db :employees "Susan" 1001 64000)
+;; (emacsql-insert db :employees ["Jeff" 1000 60000]
+;; ["Susan" 1001 64000])
;; Currently all actions are synchronous and Emacs will block until
;; SQLite has indicated it is finished processing the last command.
@@ -230,13 +230,18 @@ buffer. This is for debugging purposes."
(prin1-to-string value)
(emacsql-escape (prin1-to-string value)))))
-(defun emacsql-insert (emacsql table &rest values)
- "Insert VALUES into TABLE."
+(defun emacsql-insert (emacsql table &rest rows)
+ "Insert ROWS into TABLE.
+Each row must be a sequence of values to store into TABLE.
+
+ (emacsql-insert db :table '(\"Chris\" 0) [\"Jeff\" 1])"
(emacsql-with-errors emacsql
- (emacsql--send emacsql
- (format "INSERT INTO %s VALUES(%s);"
- (emacsql-escape table)
- (mapconcat #'emacsql-escape-value values ", ")))))
+ (emacsql--send
+ emacsql
+ (format "INSERT INTO %s VALUES (%s);" (emacsql-escape table)
+ (mapconcat (lambda (row)
+ (mapconcat #'emacsql-escape-value row ", "))
+ rows "), (")))))
(defun emacsql-select-raw (emacsql query)
"Send a raw QUERY string to EMACSQL."
- [nongnu] branch elpa/emacsql created (now 6b2e65bdf7), ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 08ea1e6636 005/427: Wrap with single rather than double quotes., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1f57b77c4f 007/427: Add command logging., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c7597ab813 001/427: Initial commit., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3b24b5d17c 002/427: Drop closed-p field., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 161e3a41b1 006/427: Add some tests., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 97e9764343 008/427: Change the API of emacsql-insert.,
ELPA Syncer <=
- [nongnu] elpa/emacsql ccfafd7703 012/427: Always quote non-number values., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1074113f03 016/427: Add readability note., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 727f3c8566 022/427: Make nil correspond to NULL., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f8d9511d1d 025/427: Tweak README limitations paragraph., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 2f0a9457a4 029/427: Drop non-idiomatic :else., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 4f6b524b9f 026/427: Rename spec to schema., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 208885e264 031/427: Add testing to schema handling., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql abe43b3381 043/427: Add :where test., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 4a89bfaf44 044/427: Use a macro to greatly simplify expanders., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql eb10ddcdba 004/427: Error-free reaping since it's automatic., ELPA Syncer, 2022/12/13