From ebfa7f4dffe513c639b84b28135c5bbc92d43d61 Mon Sep 17 00:00:00 2001 From: Marcus Pearce Date: Mon, 12 Jul 2004 23:45:58 +0000 Subject: [PATCH] r9758: Add tests for syntax and fddl. --- ChangeLog | 12 +++++++++- tests/test-fddl.lisp | 50 +++++++++++++++++++++++++++++++++++++++++- tests/test-fdml.lisp | 7 ++++++ tests/test-init.lisp | 4 ++++ tests/test-syntax.lisp | 3 +++ 5 files changed, 74 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1c7215c..2841a0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ +12 Jul 2004 Marcus Pearce + * tests/test-syntax.lisp, tests/test-fdml.lisp: add tests for escaping + of single quotes. + * tests/test-fddl.lisp: add tests for column and table constraints + in CREATE-TABLE. Add test for OWNER keyword parameter to + LIST-TABLES (assuming same underlying machinery in other FDDL + functions). + * tests/test-init.lisp: restrict above test to postgresql and oracle. + 12 Jul 2004 Kevin Rosenberg - * db-sqlite/sqlite-sql.lisp: Fix condition as reported by Aurelio Bignoli. + * db-sqlite/sqlite-sql.lisp: Fix condition as reported by Aurelio + Bignoli. 11 Jul 2004 Kevin Rosenberg * sql/oodml.lisp, sql/package.lisp, doc/ref-ooddl.lisp, db-mysql/mysql-objects.lisp: Add tinyint type diff --git a/tests/test-fddl.lisp b/tests/test-fddl.lisp index c5c305b..55b2977 100644 --- a/tests/test-fddl.lisp +++ b/tests/test-fddl.lisp @@ -79,6 +79,43 @@ (clsql:drop-table "MyMixedCase")) ((5) (6))) +(deftest :fddl/table/6 + (values + (clsql:table-exists-p [foo]) + (progn + (let ((*backend-warning-behavior* + (if (member *test-database-type* + '(:postgresql :postgresql-socket)) + :ignore + :warn))) + (clsql:create-table [foo] + '(([bar] integer :not-null :unique :primary-key) + ([baz] string :not-null :unique)))) + (clsql:table-exists-p [foo])) + (progn + (clsql:drop-table [foo]) + (clsql:table-exists-p [foo]))) + nil t nil) + +(deftest :fddl/table/7 + (values + (clsql:table-exists-p [foo]) + (progn + (let ((*backend-warning-behavior* + (if (member *test-database-type* + '(:postgresql :postgresql-socket)) + :ignore + :warn))) + (clsql:create-table [foo] '(([bar] integer :not-null) + ([baz] string :not-null)) + :constraints '("UNIQUE (bar,baz)" + "PRIMARY KEY (bar)"))) + (clsql:table-exists-p [foo])) + (progn + (clsql:drop-table [foo]) + (clsql:table-exists-p [foo]))) + nil t nil) + (deftest :fddl/attributes/1 (apply #'values (sort @@ -289,7 +326,18 @@ (return nil)))))) 555 t) - +(deftest :fddl/owner/1 + (and + ;; user tables are an improper subset of all tables + (= (length (intersection (clsql:list-tables :owner nil) + (clsql:list-tables :owner :all) + :test #'string=)) + (length (clsql:list-tables :owner nil))) + ;; user tables are a proper subset of all tables + (> (length (clsql:list-tables :owner :all)) + (length (clsql:list-tables :owner nil)))) + t) + )) #.(clsql:restore-sql-reader-syntax-state) diff --git a/tests/test-fdml.lisp b/tests/test-fdml.lisp index 344e6c5..c28632d 100644 --- a/tests/test-fdml.lisp +++ b/tests/test-fdml.lisp @@ -478,6 +478,13 @@ :flatp t :result-types nil :field-names nil))) ("Lenin" "Stalin" "Trotsky" "Kruschev")) +;; test escaping of single quotes +(deftest :fdml/select/35 + (clsql:select "What's up doc?" :from [employee] :flatp t :field-names nil) + ("What's up doc?" "What's up doc?" "What's up doc?" "What's up doc?" + "What's up doc?" "What's up doc?" "What's up doc?" "What's up doc?" + "What's up doc?" "What's up doc?")) + (deftest :fdml/do-query/1 (let ((result '())) (clsql:do-query ((name) [select [last-name] :from [employee] diff --git a/tests/test-init.lisp b/tests/test-init.lisp index cb1cec5..2da19aa 100644 --- a/tests/test-init.lisp +++ b/tests/test-init.lisp @@ -595,6 +595,10 @@ ((and (eq *test-database-type* :oracle) (clsql-sys:in test :fdml/query/8 :fdml/select/21)) (push (cons test "syntax not supported") skip-tests)) + ((and (not (member *test-database-underlying-type* + '(:postgresql :oracle))) + (clsql-sys:in test :fddl/owner/1)) + (push (cons test "table ownership not supported") skip-tests)) (t (push test-form test-forms))))) (values (nreverse test-forms) (nreverse skip-tests)))) diff --git a/tests/test-syntax.lisp b/tests/test-syntax.lisp index 69265fe..04ea99c 100644 --- a/tests/test-syntax.lisp +++ b/tests/test-syntax.lisp @@ -40,6 +40,9 @@ (clsql:sql ["SELECT FOO,BAR FROM BAZ"]) "SELECT FOO,BAR FROM BAZ") +(deftest :syntax/generic/6 + (clsql:sql "What's up Doc?") + "'What''s up Doc?'") (deftest :syntax/ident/1 (clsql:sql [foo]) -- 2.34.1