I have the following macro:
(defmacro ss [x]
`(clojureql.core/select
(clojureql.core/table db "users_table")
(clojureql.core/where ~x)
)
)
(macroexpand '(ss '(= :type "special")))
: but it produces :
(clojureql.core/select (clojureql.core/table oe.db.dbcore/db "users_table") (clojureql.core/where '(= :type "special")))
: instead of :
(clojureql.core/select (clojureql.core/table oe.db.dbcore/db "users_table") (clojureql.core/where (= :type "special")))
: I realise that the problem is I am passing in a list '(= :type "special"), but how can I get this to unquote in the macro?
Update:
I finally got this working thanks to Mikera's answer by doing this:
(defn ss [x]
(clojureql.core/select
(clojureql.core/table db "users_table")
x
)
)
(macroexpand '(ss (eval `(clojureql.core/where ~'(= :type "special")))))
: although the output is slightly different it works as expected:
(ss (eval (clojure.core/seq (clojure.core/concat (clojure.core/list 'clojureql.core/where) (clojure.core/list '(= :type "special"))))))