[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql ccfafd7703 012/427: Always quote non-number values
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql ccfafd7703 012/427: Always quote non-number values. |
Date: |
Tue, 13 Dec 2022 02:59:23 -0500 (EST) |
branch: elpa/emacsql
commit ccfafd7703e8aa4857d5b37cfbe4e967bc0c385a
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Always quote non-number values.
---
emacsql.el | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/emacsql.el b/emacsql.el
index 54ff313d41..35834fb399 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -171,15 +171,16 @@ If FLATTEN is non-nil, don't include column names."
collect row into rows and do (setf row ())
finally (return rows)))))
-(defun emacsql-escape (identifier)
- "Escape an identifier."
+(defun emacsql-escape (identifier &optional force)
+ "Escape an identifier, always with quotes when FORCE is non-nil."
(let ((string (if (stringp identifier)
identifier
- (format "%S" identifier))))
+ (format "%S" identifier)))
+ (forbidden "[]-\000-\040!\"#%&'()*+,./:;<=>?@[\\^`{|}~\177]"))
(when (string-match-p "\n" string)
(error "Newlines not permitted in identifiers by emacsql."))
- (if (or (string-match-p "[]-\000-\040!\"#%&'()*+,./:;<=>?@[\\^`{|}~\177]"
- string)
+ (if (or force
+ (string-match-p forbidden string)
(string-match-p "^[0-9$]" string))
(format "'%s'" (replace-regexp-in-string "'" "''" string))
string)))
@@ -232,7 +233,7 @@ If FLATTEN is non-nil, don't include column names."
(let ((print-escape-newlines t))
(if (numberp value)
(prin1-to-string value)
- (emacsql-escape (prin1-to-string value)))))
+ (emacsql-escape (prin1-to-string value) t))))
(defun emacsql-insert (emacsql table &rest rows)
"Insert ROWS into TABLE.
- [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, 2022/12/13
- [nongnu] elpa/emacsql ccfafd7703 012/427: Always quote non-number values.,
ELPA Syncer <=
- [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
- [nongnu] elpa/emacsql a6dbb52a3c 009/427: Add flatten option., ELPA Syncer, 2022/12/13