Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enhancement] Updating a row should respect jdbc/ISQLParameter and jdbc/ISQLValue protocols #385

Open
pqnelson opened this issue Aug 8, 2017 · 0 comments

Comments

@pqnelson
Copy link

pqnelson commented Aug 8, 2017

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)}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant