From fd11963eb2f46ffac6da2b18fab3d7ff2a4390cf Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Tue, 4 May 2004 20:58:47 +0000 Subject: [PATCH] r9228: add tests for result-types for map-query and do-query, ignore incorrect select for LOOP macro --- ChangeLog | 5 +++-- TODO | 1 - base/loop-extension.lisp | 8 +++++--- tests/test-basic.lisp | 32 +++++++++++++++++++++++++++++++- 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3192063..d523e77 100644 --- 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/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 diff --git a/TODO b/TODO index 7cff495..2a8c417 100644 --- a/TODO +++ b/TODO @@ -12,7 +12,6 @@ TESTS TO ADD * Large object testing * Test bigint type * :db-constraint tests -* Test result-types for MAP-QUERY and DO-QUERY COMMONSQL SPEC diff --git a/base/loop-extension.lisp b/base/loop-extension.lisp index a78086b..39a6dfd 100644 --- a/base/loop-extension.lisp +++ b/base/loop-extension.lisp @@ -51,8 +51,9 @@ (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-)) @@ -148,7 +149,8 @@ (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) diff --git a/tests/test-basic.lisp b/tests/test-basic.lisp index aff45cb..ba55fba 100644 --- a/tests/test-basic.lisp +++ b/tests/test-basic.lisp @@ -140,10 +140,27 @@ (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 '())) - (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)) @@ -153,6 +170,19 @@ 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))) )) -- 2.34.1