Skip to content

Instantly share code, notes, and snippets.

Avatar
🕵️‍♂️
investigating

trinityXmontoya

🕵️‍♂️
investigating
View GitHub Profile
View keybase.md

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:

@trinityXmontoya
trinityXmontoya / sql.clj
Created Apr 23, 2016
dynamic sql generation in clojure
View sql.clj
(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) "]")))