Add in jTDS tests
This commit is contained in:
parent
4342bb76da
commit
73aea0ceef
4 changed files with 22 additions and 9 deletions
|
|
@ -9,8 +9,9 @@
|
||||||
[next.jdbc.datafy]
|
[next.jdbc.datafy]
|
||||||
[next.jdbc.result-set :as rs]
|
[next.jdbc.result-set :as rs]
|
||||||
[next.jdbc.specs :as specs]
|
[next.jdbc.specs :as specs]
|
||||||
[next.jdbc.test-fixtures :refer [with-test-db db ds
|
[next.jdbc.test-fixtures
|
||||||
derby? mysql? postgres? sqlite?]]))
|
:refer [with-test-db db ds
|
||||||
|
derby? jtds? mysql? postgres? sqlite?]]))
|
||||||
|
|
||||||
(set! *warn-on-reflection* true)
|
(set! *warn-on-reflection* true)
|
||||||
|
|
||||||
|
|
@ -32,7 +33,11 @@
|
||||||
(with-open [con (jdbc/get-connection (ds))]
|
(with-open [con (jdbc/get-connection (ds))]
|
||||||
(let [reference-keys (cond-> basic-connection-keys
|
(let [reference-keys (cond-> basic-connection-keys
|
||||||
(derby?) (-> (disj :networkTimeout)
|
(derby?) (-> (disj :networkTimeout)
|
||||||
(conj :networkTimeout/exception)))
|
(conj :networkTimeout/exception))
|
||||||
|
(jtds?) (-> (disj :clientInfo :networkTimeout :schema)
|
||||||
|
(conj :clientInfo/exception
|
||||||
|
:networkTimeout/exception
|
||||||
|
:schema/exception)))
|
||||||
data (set (keys (d/datafy con)))]
|
data (set (keys (d/datafy con)))]
|
||||||
(when-let [diff (seq (set/difference data reference-keys))]
|
(when-let [diff (seq (set/difference data reference-keys))]
|
||||||
(println (:dbtype (db)) :connection (sort diff)))
|
(println (:dbtype (db)) :connection (sort diff)))
|
||||||
|
|
@ -72,11 +77,14 @@
|
||||||
(testing "database metadata datafication"
|
(testing "database metadata datafication"
|
||||||
(with-open [con (jdbc/get-connection (ds))]
|
(with-open [con (jdbc/get-connection (ds))]
|
||||||
(let [reference-keys (cond-> basic-database-metadata-keys
|
(let [reference-keys (cond-> basic-database-metadata-keys
|
||||||
|
(jtds?) (-> (disj :clientInfoProperties :rowIdLifetime)
|
||||||
|
(conj :clientInfoProperties/exception
|
||||||
|
:rowIdLifetime/exception))
|
||||||
(postgres?) (-> (disj :rowIdLifetime)
|
(postgres?) (-> (disj :rowIdLifetime)
|
||||||
(conj :rowIdLifetime/exception))
|
(conj :rowIdLifetime/exception))
|
||||||
(sqlite?) (-> (disj :clientInfoProperties :rowIdLifetime)
|
(sqlite?) (-> (disj :clientInfoProperties :rowIdLifetime)
|
||||||
(conj :clientInfoProperties/exception
|
(conj :clientInfoProperties/exception
|
||||||
:rowIdLifetime/exception)))
|
:rowIdLifetime/exception)))
|
||||||
data (set (keys (d/datafy (.getMetaData con))))]
|
data (set (keys (d/datafy (.getMetaData con))))]
|
||||||
(when-let [diff (seq (set/difference data reference-keys))]
|
(when-let [diff (seq (set/difference data reference-keys))]
|
||||||
(println (:dbtype (db)) :db-meta (sort diff)))
|
(println (:dbtype (db)) :db-meta (sort diff)))
|
||||||
|
|
@ -86,6 +94,7 @@
|
||||||
(with-open [con (jdbc/get-connection (ds))]
|
(with-open [con (jdbc/get-connection (ds))]
|
||||||
(let [data (d/datafy (.getMetaData con))]
|
(let [data (d/datafy (.getMetaData con))]
|
||||||
(doseq [k (cond-> #{:catalogs :clientInfoProperties :schemas :tableTypes :typeInfo}
|
(doseq [k (cond-> #{:catalogs :clientInfoProperties :schemas :tableTypes :typeInfo}
|
||||||
|
(jtds?) (disj :clientInfoProperties)
|
||||||
(sqlite?) (disj :clientInfoProperties))]
|
(sqlite?) (disj :clientInfoProperties))]
|
||||||
(let [rs (d/nav data k nil)]
|
(let [rs (d/nav data k nil)]
|
||||||
(is (vector? rs))
|
(is (vector? rs))
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@
|
||||||
`execute-batch!` here."
|
`execute-batch!` here."
|
||||||
(:require [clojure.test :refer [deftest is testing use-fixtures]]
|
(:require [clojure.test :refer [deftest is testing use-fixtures]]
|
||||||
[next.jdbc :as jdbc]
|
[next.jdbc :as jdbc]
|
||||||
[next.jdbc.test-fixtures :refer [with-test-db ds postgres? sqlite?]]
|
[next.jdbc.test-fixtures
|
||||||
|
:refer [with-test-db ds jtds? postgres? sqlite?]]
|
||||||
[next.jdbc.prepare :as prep]
|
[next.jdbc.prepare :as prep]
|
||||||
[next.jdbc.specs :as specs]))
|
[next.jdbc.specs :as specs]))
|
||||||
|
|
||||||
|
|
@ -73,7 +74,7 @@ INSERT INTO fruit (name, appearance) VALUES (?,?)
|
||||||
(conj result (count (jdbc/execute! t ["select * from fruit"]))))))))
|
(conj result (count (jdbc/execute! t ["select * from fruit"]))))))))
|
||||||
(is (= 4 (count (jdbc/execute! (ds) ["select * from fruit"])))))
|
(is (= 4 (count (jdbc/execute! (ds) ["select * from fruit"])))))
|
||||||
(testing "large batch insert"
|
(testing "large batch insert"
|
||||||
(when-not (or (postgres?) (sqlite?))
|
(when-not (or (jtds?) (postgres?) (sqlite?))
|
||||||
(is (= [1 1 1 1 1 1 1 1 1 13]
|
(is (= [1 1 1 1 1 1 1 1 1 13]
|
||||||
(jdbc/with-transaction [t (ds) {:rollback-only true}]
|
(jdbc/with-transaction [t (ds) {:rollback-only true}]
|
||||||
(with-open [ps (jdbc/prepare t ["
|
(with-open [ps (jdbc/prepare t ["
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
[next.jdbc.sql :as sql]
|
[next.jdbc.sql :as sql]
|
||||||
[next.jdbc.test-fixtures
|
[next.jdbc.test-fixtures
|
||||||
:refer [with-test-db ds column default-options
|
:refer [with-test-db ds column default-options
|
||||||
derby? maria? mssql? mysql? postgres? sqlite?]]))
|
derby? jtds? maria? mssql? mysql? postgres? sqlite?]]))
|
||||||
|
|
||||||
(set! *warn-on-reflection* true)
|
(set! *warn-on-reflection* true)
|
||||||
|
|
||||||
|
|
@ -67,6 +67,7 @@
|
||||||
|
|
||||||
(deftest test-insert-delete
|
(deftest test-insert-delete
|
||||||
(let [new-key (cond (derby?) :1
|
(let [new-key (cond (derby?) :1
|
||||||
|
(jtds?) :ID
|
||||||
(maria?) :insert_id
|
(maria?) :insert_id
|
||||||
(mssql?) :GENERATED_KEYS
|
(mssql?) :GENERATED_KEYS
|
||||||
(mysql?) :GENERATED_KEY
|
(mysql?) :GENERATED_KEY
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,8 @@
|
||||||
|
|
||||||
(defn derby? [] (= "derby" (:dbtype @test-db-spec)))
|
(defn derby? [] (= "derby" (:dbtype @test-db-spec)))
|
||||||
|
|
||||||
|
(defn jtds? [] (= "jtds" (:dbtype @test-db-spec)))
|
||||||
|
|
||||||
(defn maria? [] (= "mariadb" (:dbtype @test-db-spec)))
|
(defn maria? [] (= "mariadb" (:dbtype @test-db-spec)))
|
||||||
|
|
||||||
(defn mssql? [] (= "mssql" (:dbtype @test-db-spec)))
|
(defn mssql? [] (= "mssql" (:dbtype @test-db-spec)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue