Add in jTDS tests

This commit is contained in:
Sean Corfield 2020-06-06 14:30:27 -07:00
parent 4342bb76da
commit 73aea0ceef
4 changed files with 22 additions and 9 deletions

View file

@ -9,8 +9,9 @@
[next.jdbc.datafy]
[next.jdbc.result-set :as rs]
[next.jdbc.specs :as specs]
[next.jdbc.test-fixtures :refer [with-test-db db ds
derby? mysql? postgres? sqlite?]]))
[next.jdbc.test-fixtures
:refer [with-test-db db ds
derby? jtds? mysql? postgres? sqlite?]]))
(set! *warn-on-reflection* true)
@ -32,7 +33,11 @@
(with-open [con (jdbc/get-connection (ds))]
(let [reference-keys (cond-> basic-connection-keys
(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)))]
(when-let [diff (seq (set/difference data reference-keys))]
(println (:dbtype (db)) :connection (sort diff)))
@ -72,6 +77,9 @@
(testing "database metadata datafication"
(with-open [con (jdbc/get-connection (ds))]
(let [reference-keys (cond-> basic-database-metadata-keys
(jtds?) (-> (disj :clientInfoProperties :rowIdLifetime)
(conj :clientInfoProperties/exception
:rowIdLifetime/exception))
(postgres?) (-> (disj :rowIdLifetime)
(conj :rowIdLifetime/exception))
(sqlite?) (-> (disj :clientInfoProperties :rowIdLifetime)
@ -86,6 +94,7 @@
(with-open [con (jdbc/get-connection (ds))]
(let [data (d/datafy (.getMetaData con))]
(doseq [k (cond-> #{:catalogs :clientInfoProperties :schemas :tableTypes :typeInfo}
(jtds?) (disj :clientInfoProperties)
(sqlite?) (disj :clientInfoProperties))]
(let [rs (d/nav data k nil)]
(is (vector? rs))

View file

@ -8,7 +8,8 @@
`execute-batch!` here."
(:require [clojure.test :refer [deftest is testing use-fixtures]]
[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.specs :as specs]))
@ -73,7 +74,7 @@ INSERT INTO fruit (name, appearance) VALUES (?,?)
(conj result (count (jdbc/execute! t ["select * from fruit"]))))))))
(is (= 4 (count (jdbc/execute! (ds) ["select * from fruit"])))))
(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]
(jdbc/with-transaction [t (ds) {:rollback-only true}]
(with-open [ps (jdbc/prepare t ["

View file

@ -7,7 +7,7 @@
[next.jdbc.sql :as sql]
[next.jdbc.test-fixtures
: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)
@ -67,6 +67,7 @@
(deftest test-insert-delete
(let [new-key (cond (derby?) :1
(jtds?) :ID
(maria?) :insert_id
(mssql?) :GENERATED_KEYS
(mysql?) :GENERATED_KEY

View file

@ -48,6 +48,8 @@
(defn derby? [] (= "derby" (:dbtype @test-db-spec)))
(defn jtds? [] (= "jtds" (:dbtype @test-db-spec)))
(defn maria? [] (= "mariadb" (:dbtype @test-db-spec)))
(defn mssql? [] (= "mssql" (:dbtype @test-db-spec)))