r9186: add attribute caching, improve inititialize-database-type
[clsql.git] / tests / test-fdml.lisp
index 81fea97ea306c2dddf4ae77d8d28e5bce6ad4bdf..8d87097e8db1b3de950c3c0197d870b1dcd60664 100644 (file)
 
 
 (deftest :fdml/query/1
-    (clsql:query "SELECT COUNT(*) FROM EMPLOYEE WHERE (EMAIL LIKE '%org')")
+    (clsql:query "SELECT COUNT(*) FROM EMPLOYEE WHERE (EMAIL LIKE '%org')" :field-names nil)
   (("10")))
 
 (deftest :fdml/query/2
-    (clsql:query
-     "SELECT FIRST_NAME,LAST_NAME FROM EMPLOYEE WHERE (EMPLID <= 5) ORDER BY LAST_NAME")
+    (multiple-value-bind (rows field-names)
+       (clsql:query
+        "SELECT FIRST_NAME,LAST_NAME FROM EMPLOYEE WHERE (EMPLID <= 5) ORDER BY LAST_NAME")
+      (values rows (mapcar 'string-upcase field-names)))
   (("Leonid" "Brezhnev") ("Nikita" "Kruschev") ("Vladamir" "Lenin")
- ("Josef" "Stalin") ("Leon" "Trotsky")))
+   ("Josef" "Stalin") ("Leon" "Trotsky"))
+  ("FIRST_NAME" "LAST_NAME"))
 
   
 (deftest :fdml/execute-command/1
 
 
 ;; compare min, max and average hieghts in inches (they're quite short
-;; these guys!) -- only works with pgsql 
+;; these guys!) 
 (deftest :fdml/select/1
-    (if (member *test-database-type* '(:postgresql-socket :postgresql))
-        (let ((max (clsql:select [function "floor"
-                                          [/ [* [max [height]] 100] 2.54]]
-                                :from [employee]
-                                :flatp t))
-              (min (clsql:select [function "floor"
-                                          [/ [* [min [height]] 100] 2.54]]
-                                :from [employee]
-                                :flatp t))
-              (avg (clsql:select [function "floor"
-                                          [avg [/ [* [height] 100] 2.54]]]
-                                :from [employee]
-                                :flatp t)))
-          (apply #'< (mapcar #'parse-integer (append min avg max))))
-        t)
+    (let ((max (clsql:select [function "floor"
+                            [/ [* [max [height]] 100] 2.54]]
+                            :from [employee]
+                            :flatp t))
+         (min (clsql:select [function "floor"
+                            [/ [* [min [height]] 100] 2.54]]
+                            :from [employee]
+                            :flatp t))
+         (avg (clsql:select [function "floor"
+                            [avg [/ [* [height] 100] 2.54]]]
+                            :from [employee]
+                            :flatp t)))
+      (apply #'< (mapcar #'(lambda (s) (parse-integer s :junk-allowed t))
+                        (append min avg max))))
   t)
 
 (deftest :fdml/select/2
   ("lenin@soviet.org"))
 
 (deftest :fdml/select/6
-    (if (member *test-database-type* '(:postgresql-socket :postgresql))
-        (mapcar #'parse-integer
-                (clsql:select [function "trunc" [height]] :from [employee]
-                             :flatp t))
-        (mapcar #'(lambda (s) (truncate (parse-integer s :junk-allowed t)))
-                (clsql:select [height] :from [employee] :flatp t)))
+    (if (db-type-has-fancy-math? *test-database-underlying-type*)
+        (mapcar #'(lambda (s) (parse-integer s :junk-allowed t))
+        (clsql:select [function "trunc" [height]] :from [employee]
+                      :flatp t))
+      (mapcar #'(lambda (s) (truncate (parse-integer s :junk-allowed t)))
+       (clsql:select [height] :from [employee] :flatp t)))
   (1 1 1 1 1 1 1 1 1 1))
 
 (deftest :fdml/select/7
                          :flatp t)
             results)
       (apply #'values (nreverse results)))
-  nil :COMMITTED nil ("lenin-nospam@soviet.org") :COMMITTED
+  nil :committed nil ("lenin-nospam@soviet.org") :committed
   nil ("lenin@soviet.org"))
 
 ;; runs a valid update and an invalid one within a transaction and checks