[patch] don't munge case of keywords in SQL expressions

Tim Howe <[email protected]> Sun, 01 Apr 2007 12:06:36 -0400
Newsgroups gmane.lisp.clsql.devel
Organization quadium.net
Message-ID <[email protected]>
--=-=-=

The attached patch removes the code which converts keywords to the
database's default case within SQL expressions.  With PostgreSQL, stock
CLSQL does the following:

  [= [relation-type] :father]

    =>

  "relation_type = 'father'"

This is a problem as keywords are stored in the database in uppercase
(or perhaps *PRINT-CASE*, not sure).  So checking a value you stored
against itself will never succeed.

I don't believe the solution is to make storing into the database use
the database's default case, as that would gratuitiously remove data
portability between backends when moving from a database with a default
case of :UPCASE to one with a default case of :DOWNCASE, or vice versa.

-- 
vsync
http://quadium.net/~vsync/

Every answer asks a more beautiful question.
        -- http://www.cyberciti.biz/faq/

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline; filename=clsql-3.8.2_keyword-case.lisp.patch

diff -ur /home/vsync/unpack/clsql-3.8.2/sql/expressions.lisp clsql-3.8.2/sql/expressions.lisp
--- /home/vsync/unpack/clsql-3.8.2/sql/expressions.lisp	2006-12-31 01:36:25.000000000 +0000
+++ clsql-3.8.2/sql/expressions.lisp	2007-04-01 16:59:55.000000000 +0100
@@ -891,11 +891,9 @@
   (defmethod database-output-sql ((sym symbol) database)
   (if (null sym)
       +null-string+
-      (convert-to-db-default-case
-       (if (equal (symbol-package sym) keyword-package)
-           (concatenate 'string "'" (string sym) "'")
-           (symbol-name sym))
-       database))))
+      (if (equal (symbol-package sym) keyword-package)
+          (concatenate 'string "'" (string sym) "'")
+          (symbol-name sym)))))
 
 (defmethod database-output-sql ((tee (eql t)) database)
   (if database

--=-=-=
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
CLSQL-Devel mailing list
[email protected]
http://lists.b9.com/mailman/listinfo/clsql-devel

--=-=-=--