seancorfield / next-jdbc

A modern low-level Clojure wrapper for JDBC-based access to databases.
https://cljdoc.org/d/com.github.seancorfield/next.jdbc/
Eclipse Public License 1.0
768 stars 90 forks source link

Add support for post-creation updates on Connection, PreparedStatement, etc #82

Closed seancorfield closed 4 years ago

seancorfield commented 4 years ago

The various JDBC classes have a number of setters that can be invoked directly via interop after next.jdbc has created them. However, this makes for somewhat ugly code since you need to explicitly create and use each object so that you can invoke setters on it:

(with-open [con (jdbc/get-connection ,,,)]
  (.setSomething con ,,,)
  (with-open [ps (jdbc/prepare con ,,,)]
    (.setThing ps ,,,)
    (jdbc/execute! ps)))

Given the new set-properties in org.clojure/java.data 0.1.5, it would be possible to pass connection and statement setter options via the top-level options map and have those applied automatically inside next.jdbc methods:

(jdbc/execute! ,,, [,,,] {:connection {:something ,,,} :prepared-statement {:thing ,,,}})

(actual names TBD)