Skip to content

v0.2.0

Choose a tag to compare

@yogthos yogthos released this 11 Aug 23:56
· 13 commits to main since this release
6e3474a

jdbc.core is now the real clojure.jdbc, not a reimplementation of it.

This library supplies the java.sql surface clojure.jdbc drives (db.jdbc-shim) over the native libsqlite3 and libpq bindings, and pulls clojure.jdbc itself in as a dependency. Its documentation and semantics apply as written, and there is no second implementation here to drift from it.

Upgrading

Require db.jdbc once before jdbc.core, and before anything else that pulls it in. It registers the shim, which clojure.jdbc's namespaces resolve against as they compile, and points connection construction at the native drivers instead of DriverManager.

(require '[db.jdbc])
(require '[jdbc.core :as jdbc])

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. Generated keys come back through RETURNING, so ask for them explicitly.

(jdbc/insert! conn :p {:name "ada"})                     ; -> (1)
(jdbc/insert! conn :p {:name "ada"} {:returning true})   ; -> ({:id 1 :name "ada"})

last-insert-id is gone. It was ours, not clojure.jdbc's. Use {:returning ...}.

jolt v0.7.3 or newer is required. The shim needs three host fixes from that release — with-open on a reify, a parenthesised (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.

What you gain

The full clojure.jdbc surface, including prepared-statement, fetch-lazy and cursors, the :identifiers and :as-rows? result options, :returning, and the isolation-level and read-only connection options. Anything its docs describe now works here, because it is the same code.

next.jdbc is unchanged and still sits on top, so migratus keeps working.

Changes

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