Use the real clojure.jdbc instead of reimplementing it - #12
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The switchover the shim was built for.
clj/jdbc/core.cljis gone and clojure.jdbc comes in as a git dependency, sojdbc.coreis now the published library running ondb.jdbc-shimover 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-casecalls(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.cljreferencesodtbefore 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.jdbcstill worked showedinstance? java.sql.Connectionreturning false for its connection wrapper. jolt's contract for a registered instance check istrue | false | nil, where nil means "not mine, keep looking" and the first non-nil answer wins. The shim answeredfalsefor values it did not own, which silently overruled next.jdbc's own check — the one migratus uses to pick its Connection branch. It answerstrueornilnow.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-openon areify,(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.jdbcstill round-trips insert and query through the new stack and answersinstance?correctly. Also confirmedjdbc.core/prepared-statementresolves, which only the real clojure.jdbc has, so the dependency really is what is being exercised rather than a leftover copy.