Created
June 21, 2010 13:40
-
-
Save spariev/446863 to your computer and use it in GitHub Desktop.
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
(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