Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(defmacro execute-query
"Wrapper around with-connection & with-query-results"
[results query & body]
`(do
(debug (str "[SQL] " ~query))
(with-connection {:datasource (data-source)}
(with-query-results ~results [~query] ~@body))))
(defmacro with-items-in
[ids options & body]
`(let [ids-cond# (str-utils2/join "," ~ids)
query# ~(options :query)
table# ~(options :table)]
(do
(info ~(options :msg))
(execute-query
`items
(str query#
" WHERE " table# ".id IN (" ids-cond#
") GROUP BY " table# ".id ORDER BY NULL")
~@body))))
;; with `items at line 17 it gives
;; Unsupported binding form: (quote tm.search.utils/items)
;; and with quote removed I receive
;; Can't use qualified name as parameter: tm.search.utils/items
;; [Thrown class java.lang.Exception]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.