+(defun test-basic-initialize ()
+ (ignore-errors
+ (clsql:execute-command "DROP TABLE TYPE_TABLE"))
+ (clsql:execute-command
+ "CREATE TABLE TYPE_TABLE (t_int integer, t_float double precision, t_bigint BIGINT, t_str VARCHAR(30))")
+ (dotimes (i 11)
+ (let* ((test-int (- i 5))
+ (test-flt (transform-float-1 test-int)))
+ (clsql:execute-command
+ (format nil "INSERT INTO TYPE_TABLE VALUES (~a,~a,~a,'~a')"
+ test-int
+ (clsql-sys:number-to-sql-string test-flt)
+ (transform-bigint-1 test-int)
+ (clsql-sys:number-to-sql-string test-flt)
+ )))))
+
+(defun test-basic-forms ()
+ (append
+ (test-basic-forms-untyped)
+ '(
+ (deftest :BASIC/TYPE/1
+ (let ((results '()))
+ (dolist (row (query "select * from TYPE_TABLE" :result-types :auto)
+ results)
+ (destructuring-bind (int float bigint str) row
+ (push (list (integerp int)
+ (typep float 'double-float)
+ (if (and (eq :odbc *test-database-type*)
+ (eq :postgresql *test-database-underlying-type*))
+ ;; ODBC/Postgresql may return returns bigints as strings or integer
+ ;; depending upon the platform
+ t
+ (integerp bigint))
+ (stringp str))
+ results))))
+ ((t t t t) (t t t t) (t t t t) (t t t t) (t t t t) (t t t t) (t t t t) (t t t t) (t t t t) (t t t t) (t t t t)))
+
+ (deftest :BASIC/TYPE/2
+ (let ((results '()))
+ (dolist (row (query "select * from TYPE_TABLE" :result-types :auto)
+ results)
+ (destructuring-bind (int float bigint str) row
+ (setq results
+ (cons (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)))
+ )))
+
+(defun test-basic-forms-untyped ()
+ '((deftest :BASIC/SELECT/1
+ (let ((rows (query "select * from TYPE_TABLE" :result-types :auto)))
+ (values
+ (length rows)
+ (length (car rows))))
+ 11 4)
+
+ (deftest :BASIC/SELECT/2
+ (let ((results '()))
+ (dolist (row (query "select * from TYPE_TABLE" :result-types nil)
+ results)
+ (destructuring-bind (int float bigint str) row
+ (push (list (stringp int)
+ (stringp float)
+ (stringp bigint)
+ (stringp str))
+ results))))
+ ((t t t t) (t t t t) (t t t t) (t t t t) (t t t t) (t t t t) (t t t t) (t t t t) (t t t t) (t t t t) (t t t t)))
+
+ (deftest :BASIC/SELECT/3
+ (let ((results '()))
+ (dolist (row (query "select * from TYPE_TABLE" :result-types nil)
+ results)
+ (destructuring-bind (int float bigint str) row
+ (declare (ignore bigint))
+ (push (list (double-float-equal
+ (transform-float-1 (parse-integer int))
+ (parse-double float))
+ (double-float-equal
+ (parse-double str)
+ (parse-double float)))
+ results))))
+ ((t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t)))