X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=tests%2Ftest-fdml.lisp;h=0286b2d807a0034efcb6831b7f1a9d98f291f00c;hp=df9f28faf52bd6f90be6749dcd83e8d528ba3d6f;hb=8a8ee2d7d791b7a3efaed06420802a925d16fca3;hpb=aced01441ccf8a826de544ed34bed4d8616a14ee diff --git a/tests/test-fdml.lisp b/tests/test-fdml.lisp index df9f28f..0286b2d 100644 --- a/tests/test-fdml.lisp +++ b/tests/test-fdml.lisp @@ -40,7 +40,7 @@ (progn (clsql:insert-records :into [employee] :attributes '(emplid groupid first_name last_name - email companyid managerid) + email ecompanyid managerid) :values '(11 1 "Yuri" "Gagarin" "gagarin@soviet.org" 1 1)) (values @@ -58,7 +58,7 @@ (first_name "Yuri") (last_name "Gagarin") (email "gagarin@soviet.org") - (companyid 1) (managerid 1))) + (ecompanyid 1) (managerid 1))) (values (clsql:select [first-name] [last-name] [email] :from [employee] :where [= [emplid] 11]) @@ -154,6 +154,31 @@ 'float) t) +(deftest :fdml/query/5 + (clsql:query (clsql:sql [select [first-name] [sum [emplid]] :from [employee]] + [group-by [first-name]] [order-by [sum [emplid]]]) + :field-names nil :result-types nil) + (("Josef" "2") ("Leon" "3") ("Nikita" "4") ("Leonid" "5") ("Yuri" "6") + ("Konstantin" "7") ("Mikhail" "8") ("Boris" "9") ("Vladamir" "11"))) + +(deftest :fdml/query/6 + (clsql:query (clsql:sql [union [select [emplid] :from [employee]] + [select [groupid] :from [company]]]) + :field-names nil :result-types nil :flatp t) + ("1" "2" "3" "4" "5" "6" "7" "8" "9" "10")) + +(deftest :fdml/query/7 + (clsql:query (clsql:sql [intersect [select [emplid] :from [employee]] + [select [groupid] :from [company]]]) + :field-names nil :result-types nil :flatp t) + ("1")) + +(deftest :fdml/query/8 + (clsql:query (clsql:sql [except [select [emplid] :from [employee]] + [select [groupid] :from [company]]]) + :field-names nil :result-types nil :flatp t) + ("2" "3" "4" "5" "6" "7" "8" "9" "10")) + (deftest :fdml/execute-command/1 (values (clsql:table-exists-p [foo] :owner *test-database-user*) @@ -223,7 +248,7 @@ ("lenin@soviet.org")) (deftest :fdml/select/6 - (if (db-type-has-fancy-math? *test-database-underlying-type*) + (if (clsql-sys:db-type-has-fancy-math? *test-database-underlying-type*) (mapcar #'(lambda (s) (parse-integer s :junk-allowed t)) (clsql:select [function "trunc" [height]] :from [employee] :result-types nil @@ -290,7 +315,7 @@ (deftest :fdml/select/15 (multiple-value-bind (rows field-names) (clsql:select [addressid] [street-number] [street-name] [city_field] [zip] - :from [address] + :from [addr] :where [= 1 [addressid]]) (values rows @@ -313,6 +338,42 @@ :field-names nil) (("1" "Lenin"))) +(deftest :fdml/select/19 + (clsql:select [emplid] :from [employee] :order-by [emplid] + :where [between [* [emplid] 10] [* 5 10] [* 10 10]] + :field-names nil :result-types nil :flatp t) + ("5" "6" "7" "8" "9" "10")) + +(deftest :fdml/select/20 + (clsql:select [emplid] :from [employee] :order-by [emplid] + :where [not [between [* [emplid] 10] [* 5 10] [* 10 10]]] + :field-names nil :result-types nil :flatp t) + ("1" "2" "3" "4")) + +(deftest :fdml/select/21 + (clsql:select [substr [first-name] 1 4] :from [employee] + :flatp t :order-by [emplid] :field-names nil) + ("Vlad" "Jose" "Leon" "Niki" "Leon" "Yuri" "Kons" "Mikh" "Bori" "Vlad")) + +(deftest :fdml/select/22 + (clsql:select [\|\| [first-name] " " [last-name]] :from [employee] + :flatp t :order-by [emplid] :field-names nil) + ("Vladamir Lenin" "Josef Stalin" "Leon Trotsky" "Nikita Kruschev" + "Leonid Brezhnev" "Yuri Andropov" "Konstantin Chernenko" "Mikhail Gorbachev" + "Boris Yeltsin" "Vladamir Putin")) + +(deftest :fdml/select/23 + (clsql:select [emplid] :from [employee] :where [in [emplid] '(1 2 3 4)] + :flatp t :order-by [emplid] :field-names nil + :result-types nil) + ("1" "2" "3" "4")) + +(deftest :fdml/select/24 + (clsql:select [distinct [first-name]] :from [employee] :flatp t + :order-by [first-name] :field-names nil :result-types nil) + ("Boris" "Josef" "Konstantin" "Leon" "Leonid" "Mikhail" "Nikita" "Vladamir" + "Yuri")) + ;(deftest :fdml/select/11 ; (clsql:select [emplid] :from [employee] ; :where [= [emplid] [any [select [companyid] :from [company]]]] @@ -354,14 +415,14 @@ (deftest :fdml/loop/2 (loop for (addressid) being each tuple in - [select [addressid] :from [address] :order-by [addressid]] + [select [addressid] :from [addr] :order-by [addressid]] collect addressid) (1 2)) (deftest :fdml/loop/3 (loop for addressid being each tuple in - [select [addressid] :from [address] :order-by [addressid]] + [select [addressid] :from [addr] :order-by [addressid]] collect addressid) (1 2))