Skip to content

Instantly share code, notes, and snippets.

@fogus
Forked from alandipert/sql.clj
Last active August 29, 2015 14:16
Show Gist options
  • Save fogus/6f0bba78a6969bd614f2 to your computer and use it in GitHub Desktop.
Save fogus/6f0bba78a6969bd614f2 to your computer and use it in GitHub Desktop.
(require '[clojure.core.strint :as si] ;[org.clojure/core.incubator "0.1.3"]
'[clojure.string :as str])
(defn deterpolate
[s]
(let [inter (@#'si/interpolate s)]
(vec (list* (str/join "?" (filter string? inter))
(filter (complement string?) inter)))))
(defmacro <?
[q]
`(j/query (get-connection) ~(deterpolate q)))
(mapv #(<? "select * from foop where id = ~{%}") [1 2 3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment