So, I can specify how jdbc should transform a clojure value into a sql value using the ISQLValue and ISQLParameter protocols. If I try this and use korma, inserting values works fine...but updating ignores these protocols, for whatever reason.
For example, a minimal (almost)-working example:
;; store UUIDs as strings
(extend-protocol jdbc/ISQLValue
java.util.UUID
(sql-value [uuid]
(str uuid)))
(defn new-uuid [] (java.util.UUID/randomUUID))
;; dangerous, but just to illustrate my point
;; throws an error, cannot set varchar to type uuid
(korma/update my-table (korma/set-fields {:my-id (new-uuid)}))
;; ...but this works exactly as expected
(korma/insert my-table (korma/values {:my-id (new-uuid)}))
So, I can specify how
jdbc
should transform a clojure value into a sql value using theISQLValue
andISQLParameter
protocols. If I try this and use korma, inserting values works fine...but updating ignores these protocols, for whatever reason.For example, a minimal (almost)-working example: