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

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

[nongnu] elpa/emacsql 6ad267f93b 229/427: Change :value to :scalar.


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql 6ad267f93b 229/427: Change :value to :scalar.
Date: Tue, 13 Dec 2022 02:59:46 -0500 (EST)

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

    Change :value to :scalar.
---
 emacsql-compiler.el | 22 +++++++++++-----------
 emacsql-tests.el    | 14 +++++++-------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/emacsql-compiler.el b/emacsql-compiler.el
index 5aabf4faa9..34d3498300 100644
--- a/emacsql-compiler.el
+++ b/emacsql-compiler.el
@@ -51,7 +51,7 @@
     (setf string (replace-regexp-in-string "-" "_" string))
     string))
 
-(defun emacsql-escape-value (value)
+(defun emacsql-escape-scalar (value)
   "Escape VALUE for sending to SQLite."
   (let ((print-escape-newlines t))
     (cond ((null value) "NULL")
@@ -63,7 +63,7 @@
   (cl-typecase vector
     (null   (emacsql-error "Empty SQL vector expression."))
     (list   (mapconcat #'emacsql-escape-vector vector ", "))
-    (vector (concat "(" (mapconcat #'emacsql-escape-value vector ", ") ")"))
+    (vector (concat "(" (mapconcat #'emacsql-escape-scalar vector ", ") ")"))
     (otherwise (emacsql-error "Invalid vector %S" vector))))
 
 ;; Statement compilers:
@@ -139,12 +139,12 @@ a list of (<string> [arg-pos] ...)."
                     (let ((thing (nth i args)))
                       (cl-case kind
                         (:identifier (emacsql-escape-identifier thing))
-                        (:value (emacsql-escape-value thing))
+                        (:scalar (emacsql-escape-scalar thing))
                         (:vector (emacsql-escape-vector thing))
                         (:schema (car (emacsql--schema-to-string thing)))
                         (:auto (if (and thing (symbolp thing))
                                    (emacsql-escape-identifier thing)
-                                 (emacsql-escape-value thing)))
+                                 (emacsql-escape-scalar thing)))
                         (otherwise
                          (emacsql-error "Invalid var type %S" kind))))))))
 
@@ -162,10 +162,10 @@ symbol is returned."
 
 (defun emacsql-escape-format (thing &optional kind)
   "Escape THING for use as a `format' spec, pre-escaping for KIND.
-KIND should be :value or :identifier."
+KIND should be :scalar or :identifier."
   (replace-regexp-in-string
    "%" "%%" (cl-case kind
-              (:value (emacsql-escape-value thing))
+              (:scalar (emacsql-escape-scalar thing))
               (:identifier (emacsql-escape-identifier thing))
               (:vector (emacsql-escape-vector thing))
               (otherwise thing))))
@@ -181,9 +181,9 @@ KIND should be :value or :identifier."
         (prog1 "%s"
           (setf emacsql--vars (nconc emacsql--vars (list (cons var kind)))))
       (cl-case kind
-        ((:identifier :value :vector) (emacsql-escape-format thing kind))
+        ((:identifier :scalar :vector) (emacsql-escape-format thing kind))
         (:auto (emacsql-escape-format
-                thing (if (and thing (symbolp thing)) :identifier :value)))
+                thing (if (and thing (symbolp thing)) :identifier :scalar)))
         (otherwise (emacsql-error "Invalid var type: %S" kind))))))
 
 (defun emacsql--vars-combine (expanded)
@@ -221,7 +221,7 @@ definitions for return from a `emacsql-defexpander'."
             (:non-nil (push "NOT NULL" output))
             (:unique  (push "UNIQUE" output))
             (:default (push "DEFAULT" output)
-                      (push (var (pop column) :value) output))
+                      (push (var (pop column) :scalar) output))
             (:check   (push "CHECK" output)
                       (push (format "(%s)" (expr (pop column))) output))
             (:references
@@ -301,7 +301,7 @@ definitions for return from a `emacsql-defexpander'."
       (list
        (mapconcat (lambda (v) (combine (emacsql--vector v))) vector ", "))
       (vector
-       (format "(%s)" (mapconcat (lambda (x) (var x :value)) vector ", ")))
+       (format "(%s)" (mapconcat (lambda (x) (var x :scalar)) vector ", ")))
       (otherwise (emacsql-error "Invalid vector: %S" vector)))))
 
 (defun emacsql--expr (expr)
@@ -355,7 +355,7 @@ definitions for return from a `emacsql-defexpander'."
              ;; quote special case
              ((quote)
               (cl-case (length args)
-                (1 (var (nth 0 args) :value))
+                (1 (var (nth 0 args) :scalar))
                 (otherwise (nops op))))
              ;; funcall special case
              ((funcall)
diff --git a/emacsql-tests.el b/emacsql-tests.el
index 15ca448a42..282bfe25af 100644
--- a/emacsql-tests.el
+++ b/emacsql-tests.el
@@ -39,13 +39,13 @@
   (should (string= (emacsql-escape-identifier 'foo$) "foo$"))
   (should (string= (emacsql-escape-identifier "foo:bar") "foo.bar")))
 
-(ert-deftest emacsql-escape-value ()
-  (should (string= (emacsql-escape-value 'foo) "'foo'"))
-  (should (string= (emacsql-escape-value "foo") "'\"foo\"'"))
-  (should (string= (emacsql-escape-value :foo) "':foo'"))
-  (should (string= (emacsql-escape-value [1 2 3]) "'[1 2 3]'"))
-  (should (string= (emacsql-escape-value '(a b c)) "'(a b c)'"))
-  (should (string= (emacsql-escape-value nil) "NULL")))
+(ert-deftest emacsql-escape-scalar ()
+  (should (string= (emacsql-escape-scalar 'foo) "'foo'"))
+  (should (string= (emacsql-escape-scalar "foo") "'\"foo\"'"))
+  (should (string= (emacsql-escape-scalar :foo) "':foo'"))
+  (should (string= (emacsql-escape-scalar [1 2 3]) "'[1 2 3]'"))
+  (should (string= (emacsql-escape-scalar '(a b c)) "'(a b c)'"))
+  (should (string= (emacsql-escape-scalar nil) "NULL")))
 
 (ert-deftest emacsql-escape-vector ()
   (should (string= (emacsql-escape-vector [1 2 3]) "(1, 2, 3)"))



reply via email to

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