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

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

[nongnu] elpa/emacsql 568e663032 193/427: Fold dashes into underscores i


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql 568e663032 193/427: Fold dashes into underscores in identifiers.
Date: Tue, 13 Dec 2022 02:59:41 -0500 (EST)

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

    Fold dashes into underscores in identifiers.
---
 emacsql-compiler.el | 8 ++++----
 emacsql-tests.el    | 3 +++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/emacsql-compiler.el b/emacsql-compiler.el
index aa7cf9c724..13296b585f 100644
--- a/emacsql-compiler.el
+++ b/emacsql-compiler.el
@@ -39,13 +39,13 @@
                   (string identifier)
                   (keyword (substring (symbol-name identifier) 1))
                   (otherwise (format "%S" identifier))))
-        (forbidden "[]-\000-\040!\"#%&'()*+,./;<=>?@[\\^`{|}~\177]"))
+        (forbidden "[]\000-\040!\"#%&'()*+,./;<=>?@[\\^`{|}~\177]"))
     (when (or (string-match-p forbidden string)
               (string-match-p "^[0-9$]" string))
       (emacsql-error "Invalid Emacsql identifier: %S" identifier))
-    (if (string-match-p ":" string)
-        (replace-regexp-in-string ":" "." string)
-      string)))
+    (setf string (replace-regexp-in-string ":" "." string))
+    (setf string (replace-regexp-in-string "-" "_" string))
+    string))
 
 (defun emacsql-escape-value (value)
   "Escape VALUE for sending to SQLite."
diff --git a/emacsql-tests.el b/emacsql-tests.el
index 2ae2ec5fea..e635d93999 100644
--- a/emacsql-tests.el
+++ b/emacsql-tests.el
@@ -13,6 +13,9 @@
   (should-error (emacsql-escape-identifier "a b"))
   (should-error (emacsql-escape-identifier '$foo))
   (should-error (emacsql-escape-identifier 10))
+  (should (string= (emacsql-escape-identifier 'person-id) "person_id"))
+  (should (string= (emacsql-escape-identifier
+                    'people:person-id) "people.person_id"))
   (should (string= (emacsql-escape-identifier 'foo$) "foo$"))
   (should (string= (emacsql-escape-identifier "foo:bar") "foo.bar")))
 



reply via email to

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