[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql 8f59fe6e80 073/427: Add a vector escape.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql 8f59fe6e80 073/427: Add a vector escape. |
Date: |
Tue, 13 Dec 2022 02:59:29 -0500 (EST) |
branch: elpa/emacsql
commit 8f59fe6e8051b9cd1436e83a71633b7aec6dc355
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Add a vector escape.
---
emacsql.el | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/emacsql.el b/emacsql.el
index 49d87b0715..8aa0a67968 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -273,18 +273,11 @@ buffer. This is for debugging purposes."
((numberp value) (prin1-to-string value))
((emacsql-escape (prin1-to-string value) t)))))
-(defun emacsql-insert (conn 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 conn
- (emacsql--send
- conn
- (format "INSERT INTO %s VALUES (%s);" (emacsql-escape table)
- (mapconcat (lambda (row)
- (mapconcat #'emacsql-escape-value row ", "))
- rows "), (")))))
+(defun emacsql-escape-vector (vector)
+ "Encode VECTOR into a SQL vector scalar."
+ (cl-etypecase vector
+ (list (mapconcat #'emacsql-escape-vector vector ", "))
+ (vector (concat "(" (mapconcat #'emacsql-escape-value vector ", ") ")"))))
;; SQL Expansion:
@@ -339,6 +332,7 @@ See also `emacsql-with-errors'."
(cl-ecase kind
(:identifier (emacsql-escape thing))
(:value (emacsql-escape-value thing))
+ (:vector (emacsql-escape-vector thing))
(:auto (if (symbolp thing)
(emacsql-escape thing)
(emacsql-escape-value thing)))))))))
@@ -367,6 +361,7 @@ KIND should be :value or :identifier."
"%" "%%" (cl-case kind
(:value (emacsql-escape-value thing))
(:identifier (emacsql-escape thing))
+ (:vector (emacsql-escape-vector thing))
(otherwise thing))))
(defvar emacsql--vars ()
@@ -384,7 +379,7 @@ KIND should be :value or :identifier."
(if (emacsql-var thing)
(prog1 "%s" (push (cons (emacsql-var thing) kind) emacsql--vars))
(cl-ecase kind
- ((:identifier :value) (emacsql-escape-format thing kind))
+ ((:identifier :value :vector) (emacsql-escape-format thing kind))
(:auto (emacsql-escape-format
thing (if (symbolp thing) :identifier :value))))))
- [nongnu] elpa/emacsql 75ea77c9a0 149/427: Add an "as" operator, greatly simplifying :from., (continued)
- [nongnu] elpa/emacsql 75ea77c9a0 149/427: Add an "as" operator, greatly simplifying :from., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 213bb71b7a 152/427: Add :having expander., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8123020ca7 153/427: Make and and or operators variadic., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 76bf0c34dc 038/427: Add rudimentary :where expander., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql afe64ca63a 040/427: Fix emacsql-add-expander example., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 72145a1627 045/427: Allow for multi-arity keyword expanders., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f54142f1eb 062/427: Argument list checking in emacsql-format., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 86687b6ba3 067/427: Flesh out more README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a306de980a 070/427: Add :delete keyword., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql afa9aa5194 072/427: Add :into expander., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8f59fe6e80 073/427: Add a vector escape.,
ELPA Syncer <=
- [nongnu] elpa/emacsql eb3283990e 077/427: Drop emacsql-create., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 66df2afbf1 091/427: Simplify start-process call., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e956d91f99 095/427: Add -identifier to emacsql-escape., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8aade12994 101/427: Add a unit test for vector update., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql beb0e00b9e 100/427: Rename emacsql--vars-collect., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ee2877dab0 106/427: Clearer error message from escape identifier., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e9b77b4774 112/427: Add a test for CREATE TABLE., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 652847dbf5 110/427: Allow memoization cache to be nil (for development)., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ff4c59a2a7 113/427: Fix cl-lib mistake., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f794d4d38f 116/427: Allow for selected columns in :insert-into., ELPA Syncer, 2022/12/13