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