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

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

[nongnu] elpa/emacsql 2e9e2d6ba1 390/427: Fix SQL truncated when print-l


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql 2e9e2d6ba1 390/427: Fix SQL truncated when print-level or print-length are changed
Date: Tue, 13 Dec 2022 03:00:15 -0500 (EST)

branch: elpa/emacsql
commit 2e9e2d6ba112fa87bb3cb645b04f824b962b2843
Author: Kisaragi Hiu <mail@kisaragi-hiu.com>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    Fix SQL truncated when print-level or print-length are changed
    
    For long values or statements (like saving entire hash tables into a
    field, for instance), if print-level and print-length were not reset
    to nil, `format` (`prin1-to-string` under the hood) would truncate the
    string, leading to an invalid value being sent.
    
        ;; Last 5 characters of the string
        ;; (eval-last-sexp does its own truncation)
        (s-right 5 (format "%s" (make-list 100 t)))
        ;; -> " t t)" if the result is not truncated
        ;;    " ...)" if it is
---
 emacsql-compiler.el | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/emacsql-compiler.el b/emacsql-compiler.el
index 81d8105492..ca7193a48d 100644
--- a/emacsql-compiler.el
+++ b/emacsql-compiler.el
@@ -516,17 +516,19 @@ Only use within `emacsql-with-params'!"
 (defun emacsql-format (expansion &rest args)
   "Fill in the variables EXPANSION with ARGS."
   (cl-destructuring-bind (format . vars) expansion
-    (apply #'format format
-           (cl-loop for (i . kind) in vars collect
-                    (let ((thing (nth i args)))
-                      (cl-case kind
-                        (:identifier (emacsql-escape-identifier thing))
-                        (:scalar (emacsql-escape-scalar thing))
-                        (:vector (emacsql-escape-vector thing))
-                        (:raw (emacsql-escape-raw thing))
-                        (:schema (emacsql-prepare-schema thing))
-                        (otherwise
-                         (emacsql-error "Invalid var type %S" kind))))))))
+    (let ((print-level nil)
+          (print-length nil))
+      (apply #'format format
+             (cl-loop for (i . kind) in vars collect
+                      (let ((thing (nth i args)))
+                        (cl-case kind
+                          (:identifier (emacsql-escape-identifier thing))
+                          (:scalar (emacsql-escape-scalar thing))
+                          (:vector (emacsql-escape-vector thing))
+                          (:raw (emacsql-escape-raw thing))
+                          (:schema (emacsql-prepare-schema thing))
+                          (otherwise
+                           (emacsql-error "Invalid var type %S" kind)))))))))
 
 (provide 'emacsql-compiler)
 



reply via email to

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