r9359: Fixes for PRINT-QUERY and sql concatenation operator (||).
authorMarcus Pearce <m.t.pearce@city.ac.uk>
Sat, 15 May 2004 10:44:54 +0000 (10:44 +0000)
committerMarcus Pearce <m.t.pearce@city.ac.uk>
Sat, 15 May 2004 10:44:54 +0000 (10:44 +0000)
ChangeLog
TODO
sql/operations.lisp
sql/sql.lisp
sql/syntax.lisp
tests/test-fdml.lisp
tests/test-syntax.lisp

index 42f5b2911f4785bfdcd5cf3ecd3b0fab0a452b7d..f877f918542842447ca763a181e0c77133379aaa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+15 May 2004 Marcus Pearce (m.t.pearce@city.ac.uk) 
+       * sql/sql.lisp: PRINT-QUERY now calls QUERY with result-types and 
+       field-names set to nil. 
+       * sql/sql.lisp: PRINT-QUERY now computes column sizes correctly 
+       with null attribute values. 
+       * sql/operations.lisp: modify SQL concatenation operator to accept 
+       unescaped || symbol.  
+       * sql/syntax.lisp: modify sql reader macro function to accept 
+       unescaped sql concatenation operator. 
+       * tests/test-fdml.lisp: unescape sql concatenation operator. 
+       * tests/test-syntax.lisp: unescape sql concatenation operator. 
+       * TODO: remove items done. Add notes about SQLITE/MYSQL backends. 
+       Note to add test for universal-time. Note about difference from 
+       CommonSQL in transaction handling. 
+
 13 May 2004 Kevin Rosenberg (kevin@rosenberg.net)
        * tests/test-init.lisp: Add deferred-employee-address
        class
 13 May 2004 Kevin Rosenberg (kevin@rosenberg.net)
        * tests/test-init.lisp: Add deferred-employee-address
        class
diff --git a/TODO b/TODO
index 8563e0a7bf3ac324d975e47d85bf4bf21c6cd864..29e242cc601ae4802ed239c75656bfdf946c75d4 100644 (file)
--- a/TODO
+++ b/TODO
@@ -9,6 +9,7 @@ TESTS TO ADD
 * test *db-auto-sync* 
 * test SELECT caching
 * for-each-row macro
 * test *db-auto-sync* 
 * test SELECT caching
 * for-each-row macro
+* universal-time 
 
 COMMONSQL SPEC
 
 
 COMMONSQL SPEC
 
@@ -26,7 +27,6 @@ COMMONSQL SPEC
          nvl (Oracle specific) 
          userenv (Oracle specific) 
         minus (Oracle specific: does the same as EXCEPT) 
          nvl (Oracle specific) 
          userenv (Oracle specific) 
         minus (Oracle specific: does the same as EXCEPT) 
-        || 
 
       o variables (e.g., table identifiers) should be instantiated at runtime 
 
 
       o variables (e.g., table identifiers) should be instantiated at runtime 
 
@@ -56,7 +56,9 @@ MYSQL
 drop-index:   requires a table to be specified with the :from keyword parameter
 views:        mysql does not support views  
 queries:      nested subqueries are not supported
 drop-index:   requires a table to be specified with the :from keyword parameter
 views:        mysql does not support views  
 queries:      nested subqueries are not supported
+syntax:       doesn't support the sql concatenation operator (||). 
 
 SQLITE 
 
 
 SQLITE 
 
-create-view: column-list parameter not supported 
+create-view:  column-list parameter not supported 
+syntax:       doesn't support the sql SUBSTRING operator. 
index 9d8ef8d0b8ca4a4ce1f2be31b88b7f52e8ed1854..d45325479fa303df265a86442e5d2f97934249c4 100644 (file)
   (make-instance 'sql-relational-exp
                 :operator 'in :sub-expressions rest))
 
   (make-instance 'sql-relational-exp
                 :operator 'in :sub-expressions rest))
 
-(defsql sql-concat (:symbol "||") (&rest rest)
+;; (defsql sql-concat (:symbol "||") (&rest rest)
+;;   (make-instance 'sql-relational-exp
+;;              :operator '\|\| :sub-expressions rest))
+
+(defsql sql-concat (:symbol "concat") (&rest rest)
   (make-instance 'sql-relational-exp
                 :operator '\|\| :sub-expressions rest))
 
   (make-instance 'sql-relational-exp
                 :operator '\|\| :sub-expressions rest))
 
index 64f74739a0e33ca3bd6c586f3300bceab0544773..0a733aa81035c787e3a12d2c51bf0eb010b4f5a2 100644 (file)
@@ -71,7 +71,10 @@ default value of T, which specifies that minimum sizes are
 computed. The output stream is given by STREAM, which has a default
 value of T. This specifies that *STANDARD-OUTPUT* is used."
   (flet ((compute-sizes (data)
 computed. The output stream is given by STREAM, which has a default
 value of T. This specifies that *STANDARD-OUTPUT* is used."
   (flet ((compute-sizes (data)
-           (mapcar #'(lambda (x) (apply #'max (mapcar #'length x)))
+           (mapcar #'(lambda (x) 
+                       (apply #'max (mapcar #'(lambda (y) 
+                                                (if (null y) 3 (length y)))
+                                            x)))
                    (apply #'mapcar (cons #'list data))))
          (format-record (record control sizes)
            (format stream "~&~?" control
                    (apply #'mapcar (cons #'list data))))
          (format-record (record control sizes)
            (format stream "~&~?" control
@@ -80,7 +83,8 @@ value of T. This specifies that *STANDARD-OUTPUT* is used."
     (let* ((query-exp (etypecase query-exp
                         (string query-exp)
                         (sql-query (sql-output query-exp database))))
     (let* ((query-exp (etypecase query-exp
                         (string query-exp)
                         (sql-query (sql-output query-exp database))))
-           (data (query query-exp :database database))
+           (data (query query-exp :database database :result-types nil 
+                        :field-names nil))
            (sizes (if (or (null sizes) (listp sizes)) sizes 
                       (compute-sizes (if titles (cons titles data) data))))
            (formats (if (or (null formats) (not (listp formats)))
            (sizes (if (or (null sizes) (listp sizes)) sizes 
                       (compute-sizes (if titles (cons titles data) data))))
            (formats (if (or (null formats) (not (listp formats)))
index 5a713d0f20d6a4c6e75b41dbfafae8212e1abe5f..7a619f0c05b3b9ed848c2b977f8efdd51ed3ee82 100644 (file)
@@ -84,9 +84,11 @@ syntax is disabled."
 (defun sql-reader-open (stream char)
   (declare (ignore char))
   (let ((sqllist (read-delimited-list #\] stream t)))
 (defun sql-reader-open (stream char)
   (declare (ignore char))
   (let ((sqllist (read-delimited-list #\] stream t)))
-    (if (sql-operator (car sqllist))
-       (cons (sql-operator (car sqllist)) (cdr sqllist))
-      (apply #'generate-sql-reference sqllist))))
+    (cond ((string= (write-to-string (car sqllist)) "||")
+           (cons (sql-operator 'concat) (cdr sqllist)))
+          ((sql-operator (car sqllist))
+           (cons (sql-operator (car sqllist)) (cdr sqllist)))
+          (t (apply #'generate-sql-reference sqllist)))))
 
 ;; Internal function that disables the close syntax when leaving sql context.
 (defun disable-sql-close-syntax ()
 
 ;; Internal function that disables the close syntax when leaving sql context.
 (defun disable-sql-close-syntax ()
index 0286b2d807a0034efcb6831b7f1a9d98f291f00c..ca491ac957ca9560887809fdbfe28315e4acd1eb 100644 (file)
  ("Vlad" "Jose" "Leon" "Niki" "Leon" "Yuri" "Kons" "Mikh" "Bori" "Vlad"))
 
 (deftest :fdml/select/22 
  ("Vlad" "Jose" "Leon" "Niki" "Leon" "Yuri" "Kons" "Mikh" "Bori" "Vlad"))
 
 (deftest :fdml/select/22 
-  (clsql:select [\|\| [first-name] " " [last-name]] :from [employee]
+  (clsql:select [|| [first-name] " " [last-name]] :from [employee]
                 :flatp t :order-by [emplid] :field-names nil)
  ("Vladamir Lenin" "Josef Stalin" "Leon Trotsky" "Nikita Kruschev"
  "Leonid Brezhnev" "Yuri Andropov" "Konstantin Chernenko" "Mikhail Gorbachev"
                 :flatp t :order-by [emplid] :field-names nil)
  ("Vladamir Lenin" "Josef Stalin" "Leon Trotsky" "Nikita Kruschev"
  "Leonid Brezhnev" "Yuri Andropov" "Konstantin Chernenko" "Mikhail Gorbachev"
index ac8247ef45d903e4aa90938d310d94ae1a21a0cf..cd8d2ba1e4d08604800fe5c20d745b4f1620e472 100644 (file)
 
 
 (deftest :syntax/concat/1 
 
 
 (deftest :syntax/concat/1 
-    (clsql:sql [\|\| [foo] [bar] [baz]])
+    (clsql:sql [|| [foo] [bar] [baz]])
  "(FOO || BAR || BAZ)")
 
 
  "(FOO || BAR || BAZ)")