branch: elpa/emacsql commit cc92c154ee34b8390aa29d7a9b7cd51e996cc457 Author: Christopher Wellons <well...@nullprogram.com> Commit: Christopher Wellons <well...@nullprogram.com>
Disallow nil as an identifier. --- emacsql-compiler.el | 7 ++++--- emacsql-tests.el | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/emacsql-compiler.el b/emacsql-compiler.el index 28bd574e35..5a226579fc 100644 --- a/emacsql-compiler.el +++ b/emacsql-compiler.el @@ -40,7 +40,8 @@ (keyword (substring (symbol-name identifier) 1)) (otherwise (format "%S" identifier)))) (forbidden "[]\000-\040!\"#%&'()*+,./;<=>?@[\\^`{|}~\177]")) - (when (or (string-match-p forbidden string) + (when (or (null identifier) + (string-match-p forbidden string) (string-match-p "^[0-9$]" string)) (emacsql-error "Invalid Emacsql identifier: %S" identifier)) (setf string (replace-regexp-in-string ":" "." string)) @@ -137,7 +138,7 @@ a list of (<string> [arg-pos] ...)." (:value (emacsql-escape-value thing)) (:vector (emacsql-escape-vector thing)) (:schema (car (emacsql--schema-to-string thing))) - (:auto (if (symbolp thing) + (:auto (if (and thing (symbolp thing)) (emacsql-escape-identifier thing) (emacsql-escape-value thing))) (otherwise @@ -178,7 +179,7 @@ KIND should be :value or :identifier." (cl-case kind ((:identifier :value :vector) (emacsql-escape-format thing kind)) (:auto (emacsql-escape-format - thing (if (symbolp thing) :identifier :value))) + thing (if (and thing (symbolp thing)) :identifier :value))) (otherwise (emacsql-error "Invalid var type: %S" kind)))))) (defun emacsql--vars-combine (expanded) diff --git a/emacsql-tests.el b/emacsql-tests.el index bf36d02881..e1058e1814 100644 --- a/emacsql-tests.el +++ b/emacsql-tests.el @@ -13,6 +13,7 @@ (should-error (emacsql-escape-identifier "a b")) (should-error (emacsql-escape-identifier '$foo)) (should-error (emacsql-escape-identifier 10)) + (should-error (emacsql-escape-identifier nil)) (should (string= (emacsql-escape-identifier 'person-id) "person_id")) (should (string= (emacsql-escape-identifier 'people:person-id) "people.person_id"))