From 5a9afd5337d9aad087e5d1c958772e8c09eade21 Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Fri, 1 Oct 2021 10:59:15 -0700 Subject: [PATCH] fixes #181 part 2 --- CHANGELOG.md | 2 +- src/next/jdbc.clj | 2 +- src/next/jdbc/default_options.clj | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4d1571..7faf3c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ Only accretive/fixative changes will be made from now on. * 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. * Update `build-clj` to v0.5.0. diff --git a/src/next/jdbc.clj b/src/next/jdbc.clj index 7395cdd..4e1a247 100644 --- a/src/next/jdbc.clj +++ b/src/next/jdbc.clj @@ -332,7 +332,7 @@ params))) ([connectable sql param-groups opts] (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)] (execute-batch! ps param-groups opts)) (with-open [con (get-connection connectable)] diff --git a/src/next/jdbc/default_options.clj b/src/next/jdbc/default_options.clj index 89f9d82..111f87e 100644 --- a/src/next/jdbc/default_options.clj +++ b/src/next/jdbc/default_options.clj @@ -8,6 +8,13 @@ (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 DefaultOptions (get-datasource [this]