From 912e2a813087be98c0ede7cbe0c62ab7f7633706 Mon Sep 17 00:00:00 2001 From: Russ Tyndall Date: Tue, 4 Sep 2012 13:29:49 -0400 Subject: [PATCH] Try to respect the casing of symbols where it seems intentional (ie: is not default). This should fix a failing test case, and I think behaves more understandibly. If you specify a casing '|Foo Bar| let us treat that a string "Foo Bar" and output it escaped --- ChangeLog | 8 ++++++++ sql/expressions.lisp | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf623de..f1adb80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2012-09-04 Russ Tyndall + * sql/expressions.lisp - Try to respect the casing of symbols + where it seems intentional (ie: is not default). This should fix + a failing test case, and I think behaves more understandibly. + + If you specify a casing '|Foo Bar| lets treat that a string "Foo Bar" + and output it escaped + 2012-08-28 Ryan Davis * db-sqlite3/sqlite3-api.lisp - allow pathnames in the connection settings, so '("/db/my.sqlite") and '(#P"/db/my.sqlite") are diff --git a/sql/expressions.lisp b/sql/expressions.lisp index 7a8c11a..983d4a5 100644 --- a/sql/expressions.lisp +++ b/sql/expressions.lisp @@ -68,6 +68,14 @@ #\^ #\& #\* #\| #\( #\) #\- #\+ #\< #\> #\{ #\})))) +(defun special-cased-symbol-p (sym) + "Should the symbols case be preserved, or should we convert to default casing" + (let ((name (symbol-name sym))) + (case (readtable-case *readtable*) + (:upcase (not (string= (string-upcase name) name))) + (:downcase (not (string= (string-downcase name) name))) + (t t)))) + (defun %make-database-identifier (inp &optional database) "We want to quote an identifier if it came to us as a string or if it has special characters in it." @@ -88,8 +96,12 @@ (symbol (let ((s (sql-escape inp))) (if (and (not (eql '* inp)) (special-char-p s)) - (%escape-identifier (convert-to-db-default-case s database) inp) - (make-instance '%database-identifier :escaped s :unescaped inp))))))) + (%escape-identifier + (if (special-cased-symbol-p inp) + s + (convert-to-db-default-case s database)) inp) + (make-instance '%database-identifier :escaped s :unescaped inp)) + ))))) (defun combine-database-identifiers (ids &optional (database clsql-sys:*default-database*) &aux res all-sym? pkg) -- 2.34.1