Clean up multi-rs results
Accept that PostgreSQL does not support this yet.
This commit is contained in:
parent
9d6e7ab145
commit
0cfbb58b2e
2 changed files with 28 additions and 10 deletions
|
|
@ -55,6 +55,8 @@
|
|||
|
||||
(defn derby? [] (= "derby" (:dbtype @test-db-spec)))
|
||||
|
||||
(defn hsqldb? [] (= "hsqldb" (:dbtype @test-db-spec)))
|
||||
|
||||
(defn jtds? [] (= "jtds" (:dbtype @test-db-spec)))
|
||||
|
||||
(defn maria? [] (= "mariadb" (:dbtype @test-db-spec)))
|
||||
|
|
@ -120,7 +122,7 @@
|
|||
(reset! test-datasource (jdbc/get-datasource db)))
|
||||
(let [fruit (if (mysql?) "fruit" "FRUIT") ; MySQL is case sensitive!
|
||||
auto-inc-pk
|
||||
(cond (or (derby?) (= "hsqldb" (:dbtype db)))
|
||||
(cond (or (derby?) (hsqldb?))
|
||||
(str "GENERATED ALWAYS AS IDENTITY"
|
||||
" (START WITH 1, INCREMENT BY 1)"
|
||||
" PRIMARY KEY")
|
||||
|
|
@ -165,11 +167,11 @@ CREATE TABLE " fruit " (
|
|||
(let [[begin end] (if (postgres?) ["$$" "$$"] ["BEGIN" "END"])]
|
||||
(try
|
||||
(do-commands con [(str "
|
||||
CREATE PROCEDURE FRUITP" (cond (= "hsqldb" (:dbtype db)) "() READS SQL DATA DYNAMIC RESULT SETS 2 "
|
||||
CREATE PROCEDURE FRUITP" (cond (hsqldb?) "() READS SQL DATA DYNAMIC RESULT SETS 2 "
|
||||
(mssql?) " AS "
|
||||
(postgres?) "() LANGUAGE SQL AS "
|
||||
:else "() ") "
|
||||
" begin " " (if (= "hsqldb" (:dbtype db))
|
||||
" begin " " (if (hsqldb?)
|
||||
(str "ATOMIC
|
||||
DECLARE result1 CURSOR WITH RETURN FOR SELECT * FROM " fruit " WHERE COST < 90;
|
||||
DECLARE result2 CURSOR WITH RETURN FOR SELECT * FROM " fruit " WHERE GRADE >= 90.0;
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@
|
|||
[clojure.test :refer [deftest is testing use-fixtures]]
|
||||
[next.jdbc :as jdbc]
|
||||
[next.jdbc.connection :as c]
|
||||
[next.jdbc.test-fixtures :refer [with-test-db db ds column
|
||||
[next.jdbc.test-fixtures
|
||||
:refer [with-test-db db ds column
|
||||
default-options stored-proc?
|
||||
derby? jtds? mssql? mysql? postgres?]]
|
||||
derby? hsqldb? jtds? mssql? mysql? postgres?]]
|
||||
[next.jdbc.prepare :as prep]
|
||||
[next.jdbc.result-set :as rs]
|
||||
[next.jdbc.specs :as specs])
|
||||
|
|
@ -320,10 +321,25 @@ VALUES ('Pear', 'green', 49, 47)
|
|||
(when (stored-proc?)
|
||||
(testing "stored proc; multiple result sets"
|
||||
(try
|
||||
(println "====" (:dbtype (db)) "====")
|
||||
(clojure.pprint/pprint
|
||||
(jdbc/execute! (ds) [(if (mssql?) "EXEC FRUITP" "CALL FRUITP()")]
|
||||
{:multi-rs true}))
|
||||
(let [multi-rs
|
||||
(jdbc/execute! (ds)
|
||||
[(if (mssql?) "EXEC FRUITP" "CALL FRUITP()")]
|
||||
{:multi-rs true})
|
||||
zero-updates [{:next.jdbc/update-count 0}]]
|
||||
(cond (postgres?) ; does not support multiple result sets yet
|
||||
(do
|
||||
(is (= 1 (count multi-rs)))
|
||||
(is (= zero-updates (first multi-rs))))
|
||||
(hsqldb?)
|
||||
(do
|
||||
(is (= 3 (count multi-rs)))
|
||||
(is (= zero-updates (first multi-rs))))
|
||||
(mysql?)
|
||||
(do
|
||||
(is (= 3 (count multi-rs)))
|
||||
(is (= zero-updates (last multi-rs))))
|
||||
:else
|
||||
(is (= 2 (count multi-rs)))))
|
||||
(catch Throwable t
|
||||
(println 'call-proc (:dbtype (db)) (ex-message t) (some-> t (ex-cause) (ex-message))))))))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue