Fix protocols vs namespace for datafy
This commit is contained in:
parent
6a6e42e9af
commit
332cf4a3ed
3 changed files with 19 additions and 16 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
;; copyright (c) 2018-2020 Sean Corfield, all rights reserved
|
;; copyright (c) 2020 Sean Corfield, all rights reserved
|
||||||
|
|
||||||
(ns next.jdbc.datafy
|
(ns next.jdbc.datafy
|
||||||
"This namespace provides datafication of several JDBC object types:
|
"This namespace provides datafication of several JDBC object types:
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
for implementations of `ReadableColumn` that provide automatic
|
for implementations of `ReadableColumn` that provide automatic
|
||||||
conversion of some SQL data types to Java Time objects."
|
conversion of some SQL data types to Java Time objects."
|
||||||
(:require [clojure.core.protocols :as core-p]
|
(:require [clojure.core.protocols :as core-p]
|
||||||
|
[clojure.datafy :as d]
|
||||||
[next.jdbc.prepare :as prepare]
|
[next.jdbc.prepare :as prepare]
|
||||||
[next.jdbc.protocols :as p])
|
[next.jdbc.protocols :as p])
|
||||||
(:import (java.sql Clob
|
(:import (java.sql Clob
|
||||||
|
|
@ -427,7 +428,7 @@
|
||||||
InspectableMapifiedResultSet
|
InspectableMapifiedResultSet
|
||||||
(row-number [this] (.getRow rs))
|
(row-number [this] (.getRow rs))
|
||||||
(column-names [this] (:cols @builder))
|
(column-names [this] (:cols @builder))
|
||||||
(metadata [this] (core-p/datafy (:rsmeta @builder)))
|
(metadata [this] (d/datafy (:rsmeta @builder)))
|
||||||
|
|
||||||
clojure.lang.IPersistentMap
|
clojure.lang.IPersistentMap
|
||||||
(assoc [this k v]
|
(assoc [this k v]
|
||||||
|
|
@ -509,7 +510,7 @@
|
||||||
;; that they can be thrown when the actual functions are called
|
;; that they can be thrown when the actual functions are called
|
||||||
(let [row (try (.getRow rs) (catch Throwable t t))
|
(let [row (try (.getRow rs) (catch Throwable t t))
|
||||||
cols (try (:cols @builder) (catch Throwable t t))
|
cols (try (:cols @builder) (catch Throwable t t))
|
||||||
meta (try (core-p/datafy (:rsmeta @builder)) (catch Throwable t t))]
|
meta (try (d/datafy (:rsmeta @builder)) (catch Throwable t t))]
|
||||||
(with-meta
|
(with-meta
|
||||||
(row-builder @builder)
|
(row-builder @builder)
|
||||||
{`core-p/datafy
|
{`core-p/datafy
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,16 @@
|
||||||
;; copyright (c) 2019-2020 Sean Corfield, all rights reserved
|
;; copyright (c) 2020 Sean Corfield, all rights reserved
|
||||||
|
|
||||||
(ns next.jdbc.datafy-test
|
(ns next.jdbc.datafy-test
|
||||||
"Tests for the datafy extensions over JDBC types."
|
"Tests for the datafy extensions over JDBC types."
|
||||||
(:require [clojure.core.protocols :as core-p]
|
(:require [clojure.datafy :as d]
|
||||||
[clojure.set :as set]
|
[clojure.set :as set]
|
||||||
[clojure.string :as str]
|
|
||||||
[clojure.test :refer [deftest is testing use-fixtures]]
|
[clojure.test :refer [deftest is testing use-fixtures]]
|
||||||
[next.jdbc :as jdbc]
|
[next.jdbc :as jdbc]
|
||||||
[next.jdbc.datafy]
|
[next.jdbc.datafy]
|
||||||
|
[next.jdbc.specs :as specs]
|
||||||
[next.jdbc.test-fixtures :refer [with-test-db db ds
|
[next.jdbc.test-fixtures :refer [with-test-db db ds
|
||||||
derby?
|
derby?]])
|
||||||
mssql?]]
|
(:import (java.sql DatabaseMetaData)))
|
||||||
[next.jdbc.specs :as specs])
|
|
||||||
(:import (java.sql ResultSet)))
|
|
||||||
|
|
||||||
(set! *warn-on-reflection* true)
|
(set! *warn-on-reflection* true)
|
||||||
|
|
||||||
|
|
@ -33,15 +31,19 @@
|
||||||
(testing "basic datafication"
|
(testing "basic datafication"
|
||||||
(if (derby?)
|
(if (derby?)
|
||||||
(is (= #{:exception :cause} ; at least one property not supported
|
(is (= #{:exception :cause} ; at least one property not supported
|
||||||
(set (keys (core-p/datafy (jdbc/get-connection (ds)))))))
|
(set (keys (d/datafy (jdbc/get-connection (ds)))))))
|
||||||
(let [data (set (keys (core-p/datafy (jdbc/get-connection (ds)))))]
|
(let [data (set (keys (d/datafy (jdbc/get-connection (ds)))))]
|
||||||
(when-let [diff (seq (set/difference data basic-connection-keys))]
|
(when-let [diff (seq (set/difference data basic-connection-keys))]
|
||||||
(println (:dbtype (db)) (sort diff)))
|
(println (:dbtype (db)) (sort diff)))
|
||||||
(is (= basic-connection-keys
|
(is (= basic-connection-keys
|
||||||
(set/intersection basic-connection-keys data))))))
|
(set/intersection basic-connection-keys data))))))
|
||||||
(testing "nav to metadata yields object"
|
(testing "nav to metadata yields object"
|
||||||
(when-not (derby?)
|
(when-not (derby?)
|
||||||
(is (instance? java.sql.DatabaseMetaData
|
(is (instance? DatabaseMetaData
|
||||||
(core-p/nav (core-p/datafy (jdbc/get-connection (ds)))
|
(d/nav (d/datafy (jdbc/get-connection (ds)))
|
||||||
:metaData
|
:metaData
|
||||||
nil))))))
|
nil))))))
|
||||||
|
|
||||||
|
(deftest database-metadata-datafy-tests)
|
||||||
|
|
||||||
|
(deftest result-set-metadata-datafy-tests)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue