Skip to content

Instantly share code, notes, and snippets.

View trinityXmontoya's full-sized avatar
🕵️‍♂️
investigating

trinityXmontoya

🕵️‍♂️
investigating
View GitHub Profile
@trinityXmontoya
trinityXmontoya / sql.clj
Created April 23, 2016 14:46
dynamic sql generation in clojure
(require '[cheshire.core :as json]
'[clojure.string :as string]
'[yesql.core :as yesql])
(defmulti ->sql "converts a given val to Postgres-compatible SQL" class)
(defmethod to->sql :default ([f] f))
(defmethod to->sql String (str "'" f "'"))
(defmethod to->sql org.joda.time.DateTime ([f] ((str "CAST('" f "' AS TIMESTAMP)")))
(defmethod to->sql clojure.lang.PersistentVector ([f] (str "ARRAY[" (string/join ", " f) "]")))

Keybase proof

I hereby claim:

  • I am trinityXmontoya on github.
  • I am trinity (https://keybase.io/trinity) on keybase.
  • I have a public key whose fingerprint is 10A6 4417 E7BE 13F2 2BAA DDBA 54D2 7587 3556 71DC

To claim this, I am signing this object: