Try to respect the casing of symbols where it seems intentional (ie:
authorRuss Tyndall <russ@acceleration.net>
Tue, 4 Sep 2012 17:29:49 +0000 (13:29 -0400)
committerRuss Tyndall <russ@acceleration.net>
Tue, 4 Sep 2012 17:41:41 +0000 (13:41 -0400)
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
sql/expressions.lisp

index bf623de5f1427452ba48976b0e1a1d9be577fc18..f1adb80718d48d8aeb5e07d08395215dd985da10 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-09-04  Russ Tyndall <russ@acceleration.net>
+       * 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 <ryan@acceleration.net>
        * db-sqlite3/sqlite3-api.lisp - allow pathnames in the connection
        settings, so '("/db/my.sqlite") and '(#P"/db/my.sqlite") are
index 7a8c11a6b226d1202ad6158830a4f0a8fd701676..983d4a526bb5667e1eb6fa17f2c6090c15f93823 100644 (file)
                             #\^ #\& #\* #\| #\( #\) #\- #\+ #\< #\>
                             #\{ #\}))))
 
+(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."
       (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)