r9361: Support for qualified sql identifiers with aliased table names.
authorMarcus Pearce <m.t.pearce@city.ac.uk>
Sat, 15 May 2004 13:07:11 +0000 (13:07 +0000)
committerMarcus Pearce <m.t.pearce@city.ac.uk>
Sat, 15 May 2004 13:07:11 +0000 (13:07 +0000)
ChangeLog
sql/classes.lisp
tests/test-fdml.lisp
tests/test-syntax.lisp

index 6fe98ecbcacda12332dfa92b70bc9f39d4de5aa9..ada36bdd6d6c3a1dc58267c309bfb65a51e5c11e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,10 @@
 15 May 2004 Marcus Pearce (m.t.pearce@city.ac.uk) 
        * sql/classes.lisp: SELECT now accepts table identifiers as strings 
-       for CommonSQL compliance. 
-       * tests/test-fdml.lisp: added test for table identifiers as strings 
-       in SELECT. 
+       for CommonSQL compliance. Add support for qualified sql identifiers 
+       with aliased table names. 
+       * tests/test-fdml.lisp: added tests for table identifiers as strings 
+       in SELECT and for aliased definitions. 
+       * tests/test-syntax.lisp: added tests for alias definitions. 
 
 15 May 2004 Marcus Pearce (m.t.pearce@city.ac.uk) 
        * sql/sql.lisp: PRINT-QUERY now calls QUERY with result-types and 
index 4e697caf0cfb7a51cfd402682d8d35dba733da1e..872830f7ebf1bba5e39e66fb5e568a73c77eb35a 100644 (file)
                (convert-to-db-default-case (symbol-name type) database)))
       (format *sql-stream* "~@[~A.~]~A"
              (when qualifier
-               (convert-to-db-default-case (sql-escape qualifier) database))
+                (typecase qualifier 
+                  (string (format nil "~s" qualifier))
+                  (t (convert-to-db-default-case (sql-escape qualifier) 
+                                                 database))))
              (sql-escape (convert-to-db-default-case name database))))
     t))
 
@@ -581,7 +584,9 @@ uninclusive, and the args from that keyword to the end."
       (write-string " FROM " *sql-stream*)
       (typecase from 
         (list (output-sql (apply #'vector from) database))
-        (string (write-string from *sql-stream*))
+        (string (write-string 
+                 (sql-escape 
+                  (convert-to-db-default-case from database)) *sql-stream*))
         (t (output-sql from database))))
     (when inner-join
       (write-string " INNER JOIN " *sql-stream*)
index 8f9fd3f63980c88fcd0e7b35a80ddb8b70125636..33267a52f33d580866d7017f513fa09b7d8cc942 100644 (file)
  ("Boris" "Josef" "Konstantin" "Leon" "Leonid" "Mikhail" "Nikita" "Vladamir"
   "Yuri"))
 
+(deftest :fdml/select/26
+ (clsql:select ["table" first-name] ["table" last-name] 
+  :from '([employee "table"] [employee "join"])
+  :where [and [= ["table" first-name] 
+                 ["join" first-name]]
+              [not [= ["table" emplid] 
+                      ["join" emplid]]]]
+  :order-by '(["table" last-name])
+  :result-types nil :field-names nil)
+ (("Vladamir" "Lenin") ("Vladamir" "Putin")))
+  
 ;(deftest :fdml/select/11
 ;    (clsql:select [emplid] :from [employee]
 ;                :where [= [emplid] [any [select [companyid] :from [company]]]]
index cd8d2ba1e4d08604800fe5c20d745b4f1620e472..8d1a86382a668680e53dba26247753cb3941dbe9 100644 (file)
   "FOO.BAR")
 
 (deftest :syntax/ident/3
-    (clsql:sql ["foo" bar])
-  "FOO.BAR")
-
-;(deftest :syntax/ident/4
-;    (clsql:sql [foo "bar"])
-;  "FOO \"bar\"")
-
-(deftest :syntax/ident/5
     (clsql:sql [foo :integer])
   "FOO")
 
-(deftest :syntax/ident/6
+(deftest :syntax/ident/4
     (clsql:sql [foo bar :integer])
   "FOO.BAR")
 
+(deftest :syntax/ident/5
+    (clsql:sql [foo "bar"])
+  "FOO \"bar\"")
+
+(deftest :syntax/ident/6
+    (clsql:sql ["foo" bar])
+ "\"foo\".BAR")
+
 (deftest :syntax/ident/7
     (clsql:sql ["foo" bar :integer])
-  "FOO.BAR")
+ "\"foo\".BAR")
+
 
 
 (deftest :syntax/subquery/1