Closed seancorfield closed 2 years ago
Describe the bug If you use execute-batch! on the result of with-options inside a Connection context, such as with-transaction, you get a protocol implementation error because it tries to call get-datasource on the underlying Connection.
execute-batch!
with-options
Connection
with-transaction
get-datasource
To Reproduce
user=> (require '[next.jdbc :as jdbc]) nil user=> (require '[next.jdbc.connection :as conn]) nil user=> (def db-spec {:dbtype "mysql" :dbname "worldsingles" :user "..." :password "..."}) #'user/db-spec user=> (def ds (conn/->pool com.mchange.v2.c3p0.ComboPooledDataSource db-spec)) #'user/ds user=> (def dso (jdbc/with-options ds {})) #'user/dso user=> (jdbc/with-transaction [tx dso] #_=> (let [ds (jdbc/with-options tx {})] #_=> (jdbc/execute-batch! ds "some SQL" [] {}))) Execution error (IllegalArgumentException) at next.jdbc.protocols/eval7116$fn$G (protocols.clj:14). No implementation of method: :get-datasource of protocol: #'next.jdbc.protocols/Sourceable found for class: com.mchange.v2.c3p0.impl.NewProxyConnection
Expected behavior It should create a PreparedStatement from the DefaultOptions-wrapped Connection.
PreparedStatement
DefaultOptions
Reported ClojureVerse: next.jdbc applying defaults on transaction causes execute-batch! to fail when using c3p0 connection pool
next.jdbc
Describe the bug If you use
execute-batch!
on the result ofwith-options
inside aConnection
context, such aswith-transaction
, you get a protocol implementation error because it tries to callget-datasource
on the underlyingConnection
.To Reproduce
Expected behavior It should create a
PreparedStatement
from theDefaultOptions
-wrappedConnection
.Reported ClojureVerse:
next.jdbc
applying defaults on transaction causesexecute-batch!
to fail when using c3p0 connection pool