From 65a91423955280d081858aadafab379e23b4304f Mon Sep 17 00:00:00 2001 From: Marcus Pearce Date: Sun, 1 Aug 2004 22:47:19 +0000 Subject: [PATCH] r9826: * 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. --- ChangeLog | 8 +++++++- sql/expressions.lisp | 6 +++++- sql/oodml.lisp | 18 +++++++++--------- tests/test-fdml.lisp | 7 +++++++ 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 23b1038..801bd68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +1 Aug 2004 Marcus Pearce + * 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 * NEWS: Initial 3.0 announcement draft * README: Expand acknowledgements of incorporated projects @@ -6,7 +12,7 @@ 23 Jul 2004 Marcus Pearce * 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 * db-oracle/oracle-sql.lisp: enable :OWNER :ALL in DATABASE-LIST-* for diff --git a/sql/expressions.lisp b/sql/expressions.lisp index 7f0ad1f..bfb33c1 100644 --- a/sql/expressions.lisp +++ b/sql/expressions.lisp @@ -850,7 +850,11 @@ uninclusive, and the args from that keyword to the end." (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) #\\)) diff --git a/sql/oodml.lisp b/sql/oodml.lisp index 4562be8..dc4f7bb 100644 --- a/sql/oodml.lisp +++ b/sql/oodml.lisp @@ -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))) - (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) diff --git a/tests/test-fdml.lisp b/tests/test-fdml.lisp index c28632d..f067e1e 100644 --- a/tests/test-fdml.lisp +++ b/tests/test-fdml.lisp @@ -485,6 +485,13 @@ "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] -- 2.34.1