r9826: * sql/expressions.lisp: conditionalise escaping of backslash in
authorMarcus Pearce <m.t.pearce@city.ac.uk>
Sun, 1 Aug 2004 22:47:19 +0000 (22:47 +0000)
committerMarcus Pearce <m.t.pearce@city.ac.uk>
Sun, 1 Aug 2004 22:47:19 +0000 (22:47 +0000)
generated SQL strings on backend.
* tests/test-fdml.lisp: test for escaping of backslash.
* sql/oodml.lisp: minor tidying in FIND-ALL.

ChangeLog
sql/expressions.lisp
sql/oodml.lisp
tests/test-fdml.lisp

index 23b103828cea4bddf6876594b00947cb822a3163..801bd68b280e91fec8a1bc922152cf173c567e73 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+1 Aug 2004 Marcus Pearce <m.t.pearce@city.ac.uk> 
+       * sql/expressions.lisp: conditionalise escaping of backslash in 
+       generated SQL strings on backend. 
+       * tests/test-fdml.lisp: test for escaping of backslash. 
+       * sql/oodml.lisp: minor tidying in FIND-ALL. 
+
 26 Jul 2004 Kevin Rosenberg <kevin@rosenberg.net>
        * NEWS: Initial 3.0 announcement draft
        * README: Expand acknowledgements of incorporated projects
 26 Jul 2004 Kevin Rosenberg <kevin@rosenberg.net>
        * NEWS: Initial 3.0 announcement draft
        * README: Expand acknowledgements of incorporated projects
@@ -6,7 +12,7 @@
 23 Jul 2004 Marcus Pearce <m.t.pearce@city.ac.uk> 
        * sql/oodml.lisp: add DATABASE-OUTPUT-SQL-AS-TYPE method specialisation
        to print floats with the exponent markers removed. 
 23 Jul 2004 Marcus Pearce <m.t.pearce@city.ac.uk> 
        * sql/oodml.lisp: add DATABASE-OUTPUT-SQL-AS-TYPE method specialisation
        to print floats with the exponent markers removed. 
-       * sql/test-oodml.lisp: add tests for updating records with floats. 
+       * tests/test-oodml.lisp: add tests for updating records with floats. 
 
 22 Jul 2004 Marcus Pearce <m.t.pearce@city.ac.uk> 
        * db-oracle/oracle-sql.lisp: enable :OWNER :ALL in DATABASE-LIST-* for 
 
 22 Jul 2004 Marcus Pearce <m.t.pearce@city.ac.uk> 
        * db-oracle/oracle-sql.lisp: enable :OWNER :ALL in DATABASE-LIST-* for 
index 7f0ad1f82ff601a6556a8d45080fcb481494ba27..bfb33c1550768270a87533a60350e66d58fc5d65 100644 (file)
@@ -850,7 +850,11 @@ uninclusive, and the args from that keyword to the end."
                         (setf (aref buf j) #\')
                         (incf j)
                         (setf (aref buf j) #\'))
                         (setf (aref buf j) #\')
                         (incf j)
                         (setf (aref buf j) #\'))
-                       ((char= char #\\)
+                       ((and (char= char #\\)
+                             ;; MTP: only escape backslash with pgsql/mysql 
+                             (member (database-underlying-type database) 
+                                     '(:postgresql :mysql)
+                                     :test #'eq))
                         (setf (aref buf j) #\\)
                         (incf j)
                         (setf (aref buf j) #\\))
                         (setf (aref buf j) #\\)
                         (incf j)
                         (setf (aref buf j) #\\))
index 4562be8558eb43b0b79e2be50f58b2881052bfda..dc4f7bb3b2512246e96163a7aeb325e848e2b6e6 100644 (file)
@@ -851,15 +851,15 @@ maximum of MAX-LEN instances updated in each query."
   View Classes VIEW-CLASSES are passed as arguments to SELECT."
   (declare (ignore all set-operation group-by having offset limit inner-join on)
            (optimize (debug 3) (speed 1)))
   View Classes VIEW-CLASSES are passed as arguments to SELECT."
   (declare (ignore all set-operation group-by having offset limit inner-join on)
            (optimize (debug 3) (speed 1)))
-  (labels ((ref-equal (ref1 ref2)
-            (equal (sql ref1)
-                   (sql ref2)))
-          (table-sql-expr (table)
-            (sql-expression :table (view-table table)))
-          (tables-equal (table-a table-b)
-            (when (and table-a table-b)
-              (string= (string (slot-value table-a 'name))
-                       (string (slot-value table-b 'name))))))
+  (flet ((ref-equal (ref1 ref2)
+           (string= (sql-output ref1 database)
+                    (sql-output ref2 database)))
+         (table-sql-expr (table)
+           (sql-expression :table (view-table table)))
+         (tables-equal (table-a table-b)
+           (when (and table-a table-b)
+             (string= (string (slot-value table-a 'name))
+                      (string (slot-value table-b 'name))))))
     (remf args :from)
     (remf args :where)
     (remf args :flatp)
     (remf args :from)
     (remf args :where)
     (remf args :flatp)
index c28632d678cc363721c7e46edc21529650248ae4..f067e1e48c3465352a7303796fa5cff20068786c 100644 (file)
    "What's up doc?" "What's up doc?" "What's up doc?" "What's up doc?"
    "What's up doc?" "What's up doc?"))
 
    "What's up doc?" "What's up doc?" "What's up doc?" "What's up doc?"
    "What's up doc?" "What's up doc?"))
 
+;; test proper treatment of backslash (depending on backend) 
+(deftest :fdml/select/36
+    (clsql:select "foo\\bar\\baz" :from [employee] :flatp t :field-names nil)
+ ("foo\\bar\\baz" "foo\\bar\\baz" "foo\\bar\\baz" "foo\\bar\\baz" 
+  "foo\\bar\\baz"  "foo\\bar\\baz" "foo\\bar\\baz" "foo\\bar\\baz" 
+  "foo\\bar\\baz" "foo\\bar\\baz"))
+
 (deftest :fdml/do-query/1
     (let ((result '()))
     (clsql:do-query ((name) [select [last-name] :from [employee]
 (deftest :fdml/do-query/1
     (let ((result '()))
     (clsql:do-query ((name) [select [last-name] :from [employee]