X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=tests%2Ftest-fddl.lisp;h=41e79d527441ec45745372bd748894dfd8852ef6;hb=f67c4e2a4e5b8371a1b7c1629828999ff909f538;hp=fde195db6d0e30990fb1bce8e26676f5e5b34742;hpb=3de42918143e5d6a2c88c1377647e4beed626b19;p=clsql.git diff --git a/tests/test-fddl.lisp b/tests/test-fddl.lisp index fde195d..41e79d5 100644 --- a/tests/test-fddl.lisp +++ b/tests/test-fddl.lisp @@ -1,23 +1,22 @@ ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- -;;;; ====================================================================== -;;;; File: test-fddl.lisp -;;;; Authors: Marcus Pearce and Kevin Rosenberg -;;;; Created: 30/03/2004 -;;;; Updated: $Id$ +;;;; ************************************************************************* +;;;; FILE IDENTIFICATION ;;;; -;;;; Tests for the CLSQL Functional Data Definition Language -;;;; (FDDL). +;;;; Name: test-fddl.lisp +;;;; Purpose: Tests for the CLSQL Functional Data Definition Language +;;;; Authors: Marcus Pearce and Kevin M. Rosenberg +;;;; Created: March 2004 ;;;; ;;;; This file is part of CLSQL. ;;;; ;;;; CLSQL users are granted the rights to distribute and use this software ;;;; as governed by the terms of the Lisp Lesser GNU Public License ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. -;;;; ====================================================================== +;;;; ************************************************************************* -(in-package #:clsql-tests) -#.(clsql:locally-enable-sql-reader-syntax) +(in-package #:clsql-tests) +(clsql-sys:file-enable-sql-reader-syntax) (def-dataset *ds-fddl* (:setup (lambda () @@ -33,15 +32,23 @@ "3,'matey','1992-02-29',0.0") (:cleanup "DROP TABLE ALPHA" "DROP TABLE BRAVO")) +(def-dataset *ds-fddl-parsing-oddities* + (:setup "CREATE TABLE ATEST ( +A varchar (32), +B varchar(32))") + (:cleanup "DROP TABLE ATEST")) + (setq *rt-fddl* '( ;; list current tables (deftest :fddl/table/1 (with-dataset *ds-fddl* - (sort (mapcar #'string-downcase - (clsql:list-tables )) - #'string<)) + (let ((tables (sort (mapcar #'string-downcase (clsql:list-tables)) + #'string<))) + ;; sqlite has a table for autoincrement sequences that we dont care about if + ;; it exists + (remove "sqlite_sequence" tables :test #'string-equal))) ("alpha" "bravo")) ;; create a table, test for its existence, drop it and test again @@ -100,7 +107,7 @@ (progn (let ((*backend-warning-behavior* (if (member *test-database-type* - '(:postgresql :postgresql-socket)) + '(:postgresql :postgresql-socket :postgresql-socket3)) :ignore :warn))) (case *test-database-underlying-type* @@ -122,7 +129,7 @@ (progn (let ((*backend-warning-behavior* (if (member *test-database-type* - '(:postgresql :postgresql-socket)) + '(:postgresql :postgresql-socket :postgresql-socket3)) :ignore :warn))) (clsql:create-table [foo] '(([bar] integer :not-null) @@ -163,12 +170,14 @@ (with-dataset *ds-fddl* (multiple-value-bind (type length scale nullable) (clsql:attribute-type [c] [alpha]) - (values (clsql-sys:in type :varchar :varchar2) length scale nullable))) + (values (clsql-sys:in type :varchar :varchar2 :nvarchar) + length scale nullable))) t 30 nil 1) (deftest :fddl/attributes/5 (with-dataset *ds-fddl* - (and (member (clsql:attribute-type [d] [alpha]) '(:datetime :timestamp :date)) t)) + (and (member (clsql:attribute-type [d] [alpha]) + '(:datetime :timestamp :date :smalldatetime)) t)) t) (deftest :fddl/attributes/6 @@ -181,6 +190,14 @@ (and (member (clsql:attribute-type [t_bigint] [TYPE_BIGINT]) '(:bigint :int8)) t)) t) +(deftest :fddl/attributes/8 + ;;this is mostly from sqlite3 sending back + (with-dataset *ds-fddl-parsing-oddities* + (values + (clsql-sys:in (clsql:attribute-type [a] [atest]) :varchar :varchar2) + (clsql-sys:in (clsql:attribute-type [b] [atest]) :varchar :varchar2))) + t t) + ;; create a view, test for existence, drop it and test again (deftest :fddl/view/1 @@ -222,7 +239,7 @@ (let ((result (list ;; Shouldn't exist - (clsql:select [a] [c] + (clsql:select [a] [c] :from [v1] :where [= [a] -1]) ;; Should exist @@ -249,11 +266,11 @@ (clsql:list-attributes [v1])) #'string<) ;; Shouldn't exist - (clsql:select [x] [y] + (clsql:select [x] [y] :from [v1] :where [= [x] -1]) ;; Should exist - (car (clsql:select [x] [y] + (car (clsql:select [x] [y] :from [v1] :where [= [x] 1]))))) @@ -388,7 +405,7 @@ (clsql:index-exists-p [bar] ) (clsql:index-exists-p [bar] :owner *test-database-user*) (clsql:index-exists-p [bar] :owner *test-false-database-user*) - + (length (clsql-sys:list-indexes :on [alpha])) (length (clsql-sys:list-indexes :on [alpha] :owner *test-database-user*)) (length (clsql-sys:list-indexes :on [alpha] :owner *test-false-database-user*)) @@ -407,7 +424,7 @@ (clsql:sequence-exists-p [foo]) (clsql:sequence-exists-p [foo] :owner *test-database-user*) (clsql:sequence-exists-p [foo] :owner *test-false-database-user*) - + (progn (clsql:drop-sequence [foo] :if-does-not-exist :ignore) (clsql:sequence-exists-p [foo] )))) @@ -435,5 +452,3 @@ (nil (t nil) t (t nil))) )) - -#.(clsql:restore-sql-reader-syntax-state)