[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql e956d91f99 095/427: Add -identifier to emacsql-esc
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql e956d91f99 095/427: Add -identifier to emacsql-escape. |
Date: |
Tue, 13 Dec 2022 02:59:31 -0500 (EST) |
branch: elpa/emacsql
commit e956d91f9908e3715aba7677bb8f9f5a51282ec8
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Add -identifier to emacsql-escape.
---
emacsql-tests.el | 16 ++++++++--------
emacsql.el | 15 ++++++++-------
2 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/emacsql-tests.el b/emacsql-tests.el
index ac96be14b2..bf1741298a 100644
--- a/emacsql-tests.el
+++ b/emacsql-tests.el
@@ -5,14 +5,14 @@
(require 'ert)
(require 'emacsql)
-(ert-deftest emacsql-escape ()
- (should (string= (emacsql-escape "foo") "foo"))
- (should (string= (emacsql-escape 'foo) "foo"))
- (should (string= (emacsql-escape :foo) "':foo'"))
- (should (string= (emacsql-escape "a b") "'a b'"))
- (should (string= (emacsql-escape '$foo) "'$foo'"))
- (should (string= (emacsql-escape "foo$") "foo$"))
- (should (string= (emacsql-escape "they're") "'they''re'")))
+(ert-deftest emacsql-escape-identifier ()
+ (should (string= (emacsql-escape-identifier "foo") "foo"))
+ (should (string= (emacsql-escape-identifier 'foo) "foo"))
+ (should (string= (emacsql-escape-identifier :foo) "':foo'"))
+ (should (string= (emacsql-escape-identifier "a b") "'a b'"))
+ (should (string= (emacsql-escape-identifier '$foo) "'$foo'"))
+ (should (string= (emacsql-escape-identifier "foo$") "foo$"))
+ (should (string= (emacsql-escape-identifier "they're") "'they''re'")))
(ert-deftest emacsql-escape-value ()
(should (string= (emacsql-escape-value 'foo) "'foo'"))
diff --git a/emacsql.el b/emacsql.el
index 10ae4eb93f..dddbe638f0 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -186,7 +186,7 @@ buffer. This is for debugging purposes."
collect row into rows and do (setf row ())
finally (cl-return rows)))))
-(defun emacsql-escape (identifier &optional force)
+(defun emacsql-escape-identifier (identifier &optional force)
"Escape an identifier, always with quotes when FORCE is non-nil."
(let ((string (if (stringp identifier)
identifier
@@ -219,7 +219,7 @@ buffer. This is for debugging purposes."
(defun emacsql--column-to-string (column)
"Convert COLUMN schema into a SQL string."
- (let ((name (emacsql-escape (pop column)))
+ (let ((name (emacsql-escape-identifier (pop column)))
(output ())
(type nil))
(while column
@@ -243,7 +243,8 @@ buffer. This is for debugging purposes."
(defun emacsql--schema-to-string (schema)
"Convert SCHEMA into a SQL-consumable string."
(cl-loop for column being the elements of schema
- when (symbolp column) collect (emacsql-escape column) into parts
+ when (symbolp column)
+ collect (emacsql-escape-identifier column) into parts
else collect (emacsql--column-to-string column) into parts
finally (cl-return (mapconcat #'identity parts ", "))))
@@ -252,7 +253,7 @@ buffer. This is for debugging purposes."
(let ((print-escape-newlines t))
(cond ((null value) "NULL")
((numberp value) (prin1-to-string value))
- ((emacsql-escape (prin1-to-string value) t)))))
+ ((emacsql-escape-identifier (prin1-to-string value) t)))))
(defun emacsql-escape-vector (vector)
"Encode VECTOR into a SQL vector scalar."
@@ -309,11 +310,11 @@ a list of (<string> [arg-pos] ...)."
(cl-loop for (i . kind) in vars collect
(let ((thing (nth i args)))
(cl-ecase kind
- (:identifier (emacsql-escape thing))
+ (:identifier (emacsql-escape-identifier thing))
(:value (emacsql-escape-value thing))
(:vector (emacsql-escape-vector thing))
(:auto (if (symbolp thing)
- (emacsql-escape thing)
+ (emacsql-escape-identifier thing)
(emacsql-escape-value thing)))))))))
(defun emacsql (conn sql &rest args)
@@ -339,7 +340,7 @@ KIND should be :value or :identifier."
(replace-regexp-in-string
"%" "%%" (cl-case kind
(:value (emacsql-escape-value thing))
- (:identifier (emacsql-escape thing))
+ (:identifier (emacsql-escape-identifier thing))
(:vector (emacsql-escape-vector thing))
(otherwise thing))))
- [nongnu] elpa/emacsql 76bf0c34dc 038/427: Add rudimentary :where expander., (continued)
- [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, 2022/12/13
- [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 <=
- [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
- [nongnu] elpa/emacsql cefe1ec014 121/427: Add emacsql-sqlite3-unavailable-p., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql b2d83c6477 123/427: Fix up ORDER BY, drop :ascending-by., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f52af86b05 124/427: Break apart and organize compilation tests., ELPA Syncer, 2022/12/13