Merge pull request #112 from seancorfield/java.data-next
Switch to new java.data version
This commit is contained in:
commit
6de53525d0
2 changed files with 8 additions and 9 deletions
2
deps.edn
2
deps.edn
|
|
@ -1,6 +1,6 @@
|
||||||
{:paths ["src"]
|
{:paths ["src"]
|
||||||
:deps {org.clojure/clojure {:mvn/version "1.10.1"}
|
:deps {org.clojure/clojure {:mvn/version "1.10.1"}
|
||||||
org.clojure/java.data {:mvn/version "1.0.64"}}
|
org.clojure/java.data {:mvn/version "1.0.73"}}
|
||||||
:aliases
|
:aliases
|
||||||
{:test {:extra-paths ["test"]
|
{:test {:extra-paths ["test"]
|
||||||
:extra-deps {org.clojure/test.check {:mvn/version "1.0.0"}
|
:extra-deps {org.clojure/test.check {:mvn/version "1.0.0"}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
are navigable to produce fully-realized datafiable result sets.
|
are navigable to produce fully-realized datafiable result sets.
|
||||||
* `java.sql.ResultSetMetaData` -- datafies as a vector of column descriptions."
|
* `java.sql.ResultSetMetaData` -- datafies as a vector of column descriptions."
|
||||||
(:require [clojure.core.protocols :as core-p]
|
(:require [clojure.core.protocols :as core-p]
|
||||||
|
[clojure.java.data :as j]
|
||||||
[next.jdbc.result-set :as rs])
|
[next.jdbc.result-set :as rs])
|
||||||
(:import (java.sql Connection
|
(:import (java.sql Connection
|
||||||
DatabaseMetaData
|
DatabaseMetaData
|
||||||
|
|
@ -63,10 +64,9 @@
|
||||||
:unknown))
|
:unknown))
|
||||||
:signed (fn [^ParameterMetaData o i] (.isSigned o i))})
|
:signed (fn [^ParameterMetaData o i] (.isSigned o i))})
|
||||||
|
|
||||||
(defn- safe-bean [o]
|
(defn- safe-bean [o opts]
|
||||||
(try
|
(try
|
||||||
;; ensure we return a basic hash map:
|
(j/from-java-shallow o (assoc opts :add-class true))
|
||||||
(merge {} (bean o))
|
|
||||||
(catch Throwable t
|
(catch Throwable t
|
||||||
(let [dex (juxt type (comp str ex-message))
|
(let [dex (juxt type (comp str ex-message))
|
||||||
cause (ex-cause t)]
|
cause (ex-cause t)]
|
||||||
|
|
@ -90,10 +90,10 @@
|
||||||
|
|
||||||
(extend-protocol core-p/Datafiable
|
(extend-protocol core-p/Datafiable
|
||||||
Connection
|
Connection
|
||||||
(datafy [this] (safe-bean this))
|
(datafy [this] (safe-bean this {}))
|
||||||
DatabaseMetaData
|
DatabaseMetaData
|
||||||
(datafy [this]
|
(datafy [this]
|
||||||
(with-meta (let [data (safe-bean this)]
|
(with-meta (let [data (safe-bean this {})]
|
||||||
(cond-> data
|
(cond-> data
|
||||||
(not (:exception (meta data)))
|
(not (:exception (meta data)))
|
||||||
(assoc :all-tables [])))
|
(assoc :all-tables [])))
|
||||||
|
|
@ -135,8 +135,7 @@
|
||||||
(datafy-result-set-meta-data this)
|
(datafy-result-set-meta-data this)
|
||||||
(let [s (.getStatement this)
|
(let [s (.getStatement this)
|
||||||
c (when s (.getConnection s))]
|
c (when s (.getConnection s))]
|
||||||
(cond-> (safe-bean this)
|
(cond-> (safe-bean this {})
|
||||||
c (assoc :rows (rs/datafiable-result-set this c {}))))))
|
c (assoc :rows (rs/datafiable-result-set this c {}))))))
|
||||||
Statement
|
Statement
|
||||||
;; danger: .getMoreResults() is a mutating function!
|
(datafy [this] (safe-bean this {:omit #{:moreResults}})))
|
||||||
(datafy [this] (safe-bean this)))
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue