r9228: add tests for result-types for map-query and do-query, ignore incorrect select...
authorKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 4 May 2004 20:58:47 +0000 (20:58 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 4 May 2004 20:58:47 +0000 (20:58 +0000)
ChangeLog
TODO
base/loop-extension.lisp
tests/test-basic.lisp

index 31920630427b4eed1eac8eac8e89c4648986fd65..d523e77b161109d082210c1e38798adae433987c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,8 +7,9 @@
        * base/basic-sql.lisp: Make :AUTO the default value for
        :RESULT-TYPES for MAP-QUERY and DO-QUERY.
        * sql/objects.lisp: Add bigint type
        * base/basic-sql.lisp: Make :AUTO the default value for
        :RESULT-TYPES for MAP-QUERY and DO-QUERY.
        * sql/objects.lisp: Add bigint type
-       * base/loop.lisp: Add placeholder (and warning) for object iteration
-       * TODO: Need results for result-types for map-query and do-query
+       * base/loop.lisp: Add placeholder for object iteration
+       * test/tests-basic.lisp: Add tests for :result-types for
+       MAP-QUERY and DO-QUERY
        
 4 May 2004 Marcus Pearce (m.t.pearce@city.ac.uk) 
        * Version 2.10.9
        
 4 May 2004 Marcus Pearce (m.t.pearce@city.ac.uk) 
        * Version 2.10.9
diff --git a/TODO b/TODO
index 7cff495150fc21226abd24332499c83c40c52a69..2a8c417fe5583e4c5662eaca4e54ae49c86148b4 100644 (file)
--- a/TODO
+++ b/TODO
@@ -12,7 +12,6 @@ TESTS TO ADD
 * Large object testing
 * Test bigint type
 * :db-constraint tests
 * Large object testing
 * Test bigint type
 * :db-constraint tests
-* Test result-types for MAP-QUERY and DO-QUERY
 
 COMMONSQL SPEC
 
 
 COMMONSQL SPEC
 
index a78086baf5adce1e12476b1959512ad61284251f..39a6dfd366461e74d5e3549fd2ffef031c25b81d 100644 (file)
@@ -51,8 +51,9 @@
       (setq from-phrase '(clsql-base:*default-database*)))
     (cond
       ;; Object query resulting in a list of returned object instances
       (setq from-phrase '(clsql-base:*default-database*)))
     (cond
       ;; Object query resulting in a list of returned object instances
-      ((consp in-phrase)
-       (error "object query not yet supported"))
+      #+ignore
+      ((consp (car in-phrase))
+       (ansi-loop::loop-error "object query not yet supported"))
       
       ((consp variable)
        (let ((query-var (ansi-loop::loop-gentemp 'loop-record-))
       
       ((consp variable)
        (let ((query-var (ansi-loop::loop-gentemp 'loop-record-))
 
     (cond
       ;; Object query resulting in a list of returned object instances
 
     (cond
       ;; Object query resulting in a list of returned object instances
-      ((consp in-phrase)
+      #+ignore
+      ((consp (car in-phrase))
        (error "Object query not yet supported."))
       
       ((consp iter-var)
        (error "Object query not yet supported."))
       
       ((consp iter-var)
index aff45cb6ffab18cabf7fd5b8c50185aea3446312..ba55fba6e008991044db75a168967a4c3b81efcb 100644 (file)
               (parse-double (second (nth i rows)))))
             results)))
       ((t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t)))
               (parse-double (second (nth i rows)))))
             results)))
       ((t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t)))
+    
+    (deftest :BASIC/MAP/3
+           (let ((results '())
+             (rows (map-query 'list #'list "select * from TYPE_TABLE" 
+                              :result-types :auto)))
+             (dotimes (i (length rows) results)
+               (push
+                (list
+                 (listp (nth i rows))
+                 (length (nth i rows))
+                 (eql (- i 5)
+                      (first (nth i rows)))
+                 (double-float-equal
+                  (transform-float-1 (first (nth i rows)))
+                  (second (nth i rows))))
+                results)))
+      ((t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t) (t 4 t t)))
 
     (deftest :BASIC/DO/1
        (let ((results '()))
 
     (deftest :BASIC/DO/1
        (let ((results '()))
-         (do-query ((int float bigint str) "select * from TYPE_TABLE")
+         (do-query ((int float bigint str) "select * from TYPE_TABLE" :result-types nil)
            (push (list (double-float-equal 
                         (transform-float-1 (parse-integer int))
                         (parse-double float))
            (push (list (double-float-equal 
                         (transform-float-1 (parse-integer int))
                         (parse-double float))
                  results))
          results)
       ((t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t)))
                  results))
          results)
       ((t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t)))
+    
+    (deftest :BASIC/DO/2
+       (let ((results '()))
+         (do-query ((int float bigint str) "select * from TYPE_TABLE" :result-types :auto)
+           (push (list (double-float-equal 
+                        (transform-float-1 int)
+                        float)
+                       (double-float-equal
+                        (parse-double str)
+                        float))
+                 results))
+         results)
+      ((t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t)))
     ))
 
 
     ))