fixes #181 part 2

This commit is contained in:
Sean Corfield 2021-10-01 10:59:15 -07:00
parent 2cef41d9ae
commit 5a9afd5337
3 changed files with 9 additions and 2 deletions

View file

@ -3,7 +3,7 @@
Only accretive/fixative changes will be made from now on. Only accretive/fixative changes will be made from now on.
* 1.2.next in progress * 1.2.next in progress
* Fix #181 by supporting option-wrapped connection in `execute-batch!`. * Fix #181 by supporting option-wrapped connectables in `execute-batch!`.
* Address #179 by improving documentation around connection pool initialization. * Address #179 by improving documentation around connection pool initialization.
* Update `build-clj` to v0.5.0. * Update `build-clj` to v0.5.0.

View file

@ -332,7 +332,7 @@
params))) params)))
([connectable sql param-groups opts] ([connectable sql param-groups opts]
(if (or (instance? java.sql.Connection connectable) (if (or (instance? java.sql.Connection connectable)
(instance? next.jdbc.default_options.DefaultOptions connectable)) (opts/wrapped-connection? connectable))
(with-open [ps (prepare connectable [sql] opts)] (with-open [ps (prepare connectable [sql] opts)]
(execute-batch! ps param-groups opts)) (execute-batch! ps param-groups opts))
(with-open [con (get-connection connectable)] (with-open [con (get-connection connectable)]

View file

@ -8,6 +8,13 @@
(defrecord DefaultOptions [connectable options]) (defrecord DefaultOptions [connectable options])
(defn wrapped-connection?
"Used internally to detect that a connectable is wrapped
in options and contains a Connection object."
[connectable]
(and (instance? DefaultOptions connectable)
(instance? java.sql.Connection (:connectable connectable))))
(extend-protocol p/Sourceable (extend-protocol p/Sourceable
DefaultOptions DefaultOptions
(get-datasource [this] (get-datasource [this]