X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=tests%2Ftest-fddl.lisp;h=a1044045a2b2035f51e16370081379def3a11042;hb=d22f943ae95f7421218d74e68179b773c63c0635;hp=067088c486894910e1f71f0f8d10de70ae3ec161;hpb=704367c500a9fac40e97663f794fa4042df1512a;p=clsql.git diff --git a/tests/test-fddl.lisp b/tests/test-fddl.lisp index 067088c..a104404 100644 --- a/tests/test-fddl.lisp +++ b/tests/test-fddl.lisp @@ -33,6 +33,12 @@ "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* '( @@ -40,7 +46,7 @@ (deftest :fddl/table/1 (with-dataset *ds-fddl* (sort (mapcar #'string-downcase - (clsql:list-tables :owner *test-database-user*)) + (clsql:list-tables )) #'string<)) ("alpha" "bravo")) @@ -52,10 +58,10 @@ ([name] (string 24)) ([comments] longchar))) (values - (clsql:table-exists-p [foo] :owner *test-database-user*) + (clsql:table-exists-p [foo]) (progn (clsql:drop-table [foo] :if-does-not-exist :ignore) - (clsql:table-exists-p [foo] :owner *test-database-user*)))) + (clsql:table-exists-p [foo])))) t nil) ;; create a table, list its attributes and drop it @@ -140,7 +146,7 @@ (with-dataset *ds-fddl* (sort (mapcar #'string-downcase - (clsql:list-attributes [alpha] :owner *test-database-user*)) + (clsql:list-attributes [alpha] )) #'string<))) "a" "c" "d" "f") @@ -149,8 +155,7 @@ (apply #'values (sort (mapcar #'(lambda (a) (string-downcase (car a))) - (clsql:list-attribute-types [alpha] - :owner *test-database-user*)) + (clsql:list-attribute-types [alpha])) #'string<))) "a" "c" "d" "f") @@ -182,6 +187,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 @@ -268,11 +281,11 @@ (progn (clsql:create-index [bar] :on [alpha] :attributes '([a] [c]) :unique t) (values - (clsql:index-exists-p [bar] :owner *test-database-user*) + (clsql:index-exists-p [bar] ) (progn (clsql:drop-index [bar] :on [alpha] :if-does-not-exist :ignore) - (clsql:index-exists-p [bar] :owner *test-database-user*))))) + (clsql:index-exists-p [bar]))))) t nil) ;; create indexes with names as strings, symbols and in square brackets @@ -282,7 +295,7 @@ (result '())) (dolist (name names) (clsql:create-index name :on [alpha] :attributes '([a])) - (push (clsql:index-exists-p name :owner *test-database-user*) result) + (push (clsql:index-exists-p name ) result) (clsql:drop-index name :on [alpha] :if-does-not-exist :ignore)) (apply #'values result))) t t t) @@ -303,7 +316,7 @@ (sort (mapcar #'string-downcase - (clsql:list-indexes :on [i3test] :owner *test-database-user*)) + (clsql:list-indexes :on [i3test])) #'string-lessp) (progn (clsql:drop-index [bar] :on [i3test]) @@ -316,10 +329,10 @@ (deftest :fddl/sequence/1 (progn (clsql:create-sequence [foo]) (values - (clsql:sequence-exists-p [foo] :owner *test-database-user*) + (clsql:sequence-exists-p [foo]) (progn (clsql:drop-sequence [foo] :if-does-not-exist :ignore) - (clsql:sequence-exists-p [foo] :owner *test-database-user*)))) + (clsql:sequence-exists-p [foo])))) t nil) ;; create and increment a sequence @@ -357,6 +370,65 @@ (length (clsql:list-tables :owner nil))))) t) +(deftest :fddl/owner/table + (with-dataset *ds-fddl* + (values + (clsql-sys:table-exists-p [alpha]) + (clsql-sys:table-exists-p [alpha] :owner *test-database-user*) + (clsql-sys:table-exists-p [alpha] :owner *test-false-database-user*))) + t t nil) + +(deftest :fddl/owner/attributes + (with-dataset *ds-fddl* + (values + (length (clsql-sys:list-attributes [alpha])) + (length (clsql-sys:list-attributes [alpha] :owner *test-database-user*)) + (length (clsql-sys:list-attributes [alpha] :owner *test-false-database-user*)))) + 4 4 0) + +(deftest :fddl/owner/attribute-types + (with-dataset *ds-fddl* + (values + (length (clsql:list-attribute-types [alpha])) + (length (clsql:list-attribute-types [alpha] :owner *test-database-user*)) + (length (clsql:list-attribute-types [alpha] :owner *test-false-database-user*)))) + 4 4 0) + +(deftest :fddl/owner/index + (with-dataset *ds-fddl* + (progn (clsql:create-index [bar] :on [alpha] + :attributes '([a] [c])) + (values + (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*)) + (progn + (clsql:drop-index [bar] :on [alpha] + :if-does-not-exist :ignore) + (clsql:index-exists-p [bar] :owner *test-database-user*)) + (clsql:index-exists-p [bar] )))) + t t nil + 1 1 0 + nil nil) + +(deftest :fddl/owner/sequence + (progn (clsql:create-sequence [foo]) + (values + (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] )))) + t t nil nil) + + + (deftest :fddl/cache-table-queries/1 (with-dataset *ds-fddl* (list