Forked from avescodes/gist:e5d1acbb007f47655508
Last active
February 20, 2016 21:52
-
-
Save rcanepa/830e3844c08e143a2ecc to your computer and use it in GitHub Desktop.
Great little snippet for using Postgres enum types inside clojure.java.jdbc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn str->pg-enum | |
"Convert a string value into an enum-compatible object." | |
[enum-type s] | |
(doto (org.postgresql.util.PGobject.) | |
(.setType enum-type) | |
(.setValue s))) | |
(def str->status | |
"Convert a string status into a something_status enum object" | |
(partial string->pg-enum "something_status")) | |
;; Use it: | |
(str->status :accepted) | |
; -> #<PGobject accepted> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment