sql

All things SQL and JDBC...
teodorlu 2020-02-17T10:07:55.211700Z

Hello! I'm trying to set up automatic Clojure maps <-> org.postgresql.util.PGobject conversion for a JSON column. I found [1], which seems to work with clojure.java.jdbc, but not jdbc.next. Is there anything like clojure.java.jdbc/ISQLParameter in jdbc.next? [1]: https://github.com/remodoy/clj-postgresql

orestis 2020-02-17T14:55:42.212200Z

(extend-protocol next.jdbc.result-set/ReadableColumn
  java.sql.Array
  (read-column-by-label [^java&lt;.sql.Array v label]
    (sql-array-&gt;java v))
  (read-column-by-index [^java.sql.Array v rs-meta idx]
    (sql-array-&gt;java v)))

(extend-protocol next.jdbc.prepare/SettableParameter
  java.time.Instant
  (set-parameter [^java.time.Instant v ^java.sql.PreparedStatement ps ^long i]
    (.setTimestamp ps i (java.sql.Timestamp/from v)))
  java.util.Date
  (set-parameter [^java.time.Instant v ^java.sql.PreparedStatement ps ^long i]
    (.setTimestamp ps i (java.sql.Timestamp/from v))))

orestis 2020-02-17T14:56:01.212600Z

first protocol is when you get values out of postgres, second procotol is when you set values in statements

orestis 2020-02-17T14:56:09.212800Z

@teodorlu ^

teodorlu 2020-02-17T15:07:21.213100Z

Great, thanks!