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

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

[nongnu] elpa/emacsql 727f3c8566 022/427: Make nil correspond to NULL.


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql 727f3c8566 022/427: Make nil correspond to NULL.
Date: Tue, 13 Dec 2022 02:59:24 -0500 (EST)

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

    Make nil correspond to NULL.
---
 emacsql-tests.el | 3 ++-
 emacsql.el       | 7 ++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/emacsql-tests.el b/emacsql-tests.el
index d1bcd2f41c..548eb807b6 100644
--- a/emacsql-tests.el
+++ b/emacsql-tests.el
@@ -14,4 +14,5 @@
   (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 '(a b c)) "'(a b c)'"))
+  (should (string= (emacsql-escape-value nil) "NULL")))
diff --git a/emacsql.el b/emacsql.el
index 4c5ed414e6..a8334426ea 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -91,6 +91,7 @@ buffer. This is for debugging purposes."
     (setf (process-sentinel process) (lambda (_proc _) (kill-buffer buffer)))
     (process-send-string process ".prompt #\n")
     (process-send-string process ".mode line\n")
+    (process-send-string process ".nullvalue nil\n")
     (let ((conn (emacsql--create :process process :file file)))
       (when log
         (setf (emacsql-log conn) (generate-new-buffer "*emacsql-log*")))
@@ -234,9 +235,9 @@ If NAMED is non-nil, don't include column names."
 (defun emacsql-escape-value (value)
   "Escape VALUE for sending to SQLite."
   (let ((print-escape-newlines t))
-    (if (numberp value)
-        (prin1-to-string value)
-      (emacsql-escape (prin1-to-string value) t))))
+    (cond ((null value) "NULL")
+          ((numberp value) (prin1-to-string value))
+          (:else (emacsql-escape (prin1-to-string value) t)))))
 
 (defun emacsql-insert (conn table &rest rows)
   "Insert ROWS into TABLE.



reply via email to

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