Skip to content

Use the real clojure.jdbc instead of reimplementing it - #12

Merged
yogthos merged 1 commit into
mainfrom
use-clojure-jdbc
Aug 11, 2026
Merged

Use the real clojure.jdbc instead of reimplementing it#12
yogthos merged 1 commit into
mainfrom
use-clojure-jdbc

Conversation

@yogthos

@yogthos yogthos commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

The switchover the shim was built for. clj/jdbc/core.clj is gone and clojure.jdbc comes in as a git dependency, so jdbc.core is now the published library running on db.jdbc-shim over the native drivers. Its own documentation and semantics apply as written rather than being approximated here.

Dependencies

clojure.jdbc at v0.9.3, and jolt-lang/time because jdbc.util/lower-case calls (Locale/US), which that library provides rather than jolt core (RFC 0008) and which sits in the path of every insert.

The time dependency is pinned past the sha its own README advertises. That one predates Declare the two forward-referenced vars, without which the library no longer compiles: zoned.clj references odt before it is defined, and jolt stopped late-binding a forward reference inside a nested scope. Worth a heads-up for that repo, since its README example is now broken on current jolt.

Test suite

Moved to clojure.jdbc's contract where it differed from ours. insert! returns one result per row rather than a bare id — a seq of generated keys where the driver has them, of update counts where it does not — so the blob and bytea round-trips now ask for the id with {:returning true}. Everything else was already the same API and needed no change, which is a decent sign the shim is faithful.

A real bug this turned up

Checking that next.jdbc still worked showed instance? java.sql.Connection returning false for its connection wrapper. jolt's contract for a registered instance check is true | false | nil, where nil means "not mine, keep looking" and the first non-nil answer wins. The shim answered false for values it did not own, which silently overruled next.jdbc's own check — the one migratus uses to pick its Connection branch. It answers true or nil now.

That one would not have shown up in the suite. It needed actually driving next.jdbc through the new stack.

Requirements

jolt v0.7.3 or newer, and the README now says why rather than just stating a floor: the shim leans on three host fixes from that release (with-open on a reify, (Class/FIELD) reading the field, and a protocol extended to a library-declared class dispatching at all). On an older jolt this fails at load or at the first connection.

Verification

93 checks pass on sqlite and against postgres 16. next.jdbc still round-trips insert and query through the new stack and answers instance? correctly. Also confirmed jdbc.core/prepared-statement resolves, which only the real clojure.jdbc has, so the dependency really is what is being exercised rather than a leftover copy.

The switchover the shim was built for. clj/jdbc/core.clj is gone and clojure.jdbc
comes in as a git dependency, so jdbc.core is now the published library running on
db.jdbc-shim over the native drivers, and its own documentation and semantics
apply as written rather than being approximated here.

Two dependencies. clojure.jdbc at v0.9.3, and jolt-lang/time because
jdbc.util/lower-case calls (Locale/US), which that library provides rather than
jolt core, and which sits in the path of every insert. The time dependency is
pinned past its README's example sha: that one predates "Declare the two
forward-referenced vars", without which the library no longer compiles, since jolt
stopped late-binding a forward reference inside a nested scope.

The suite moved to clojure.jdbc's contract where it differed from ours. insert!
returns one result per row rather than a bare id, which is a seq of generated keys
where the driver has them and of update counts where it does not, so the blob and
bytea round-trips ask for the id with {:returning true} instead. Everything else
was already the same API and needed no change.

Fixed a real bug in the shim while checking next.jdbc still worked: the instance
check answered false for values it did not own, where jolt's contract is true,
false or nil with nil meaning "not mine, keep looking" and the first non-nil
winning. next.jdbc registers its own check so its connection wrapper answers
instance? java.sql.Connection, which is how migratus picks its Connection branch,
and ours was silently overruling it. It answers true or nil now.

Requires jolt v0.7.3 or newer, and the README says why: the shim leans on three
host fixes from that release, so an older jolt fails at load or first connection.

93 checks pass on sqlite and against postgres 16, and next.jdbc still round-trips
through the new stack.
@yogthos
yogthos merged commit 6e3474a into main Aug 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant