LauJensen/clojureql — Issue #125: How to build a query with 'or' using another function call? 
Author: ariel123
Created: 2012-02-07 20:20:30+00:00
State: open

Here's the sql that I'd like to form:

(clojureql.core/join (clojureql.core/table db :tableA) (clojureql.core/table db :tableA)
(clojureql.core/where (apply and (= :tableA.id :tableB.id)
[(apply or [(clojureql.predicates/in :tableA.id [1 2])
(clojureql.predicates/in :tableA.id [3 4])])])))

I'd like to call another function for the "apply or" form, something like this:

(clojureql.core/join (clojureql.core/table db :tableA) (clojureql.core/table db :tableA)
(clojureql.core/where (apply and (= :tableA.id :tableB.id)
[(my-or-f)])))

where my-of-f function is:

(defn my-or-f []
(apply or [(clojureql.predicates/in :tableA.id [1 2])
(clojureql.predicates/in :tableA.id [3 4])]))

however this function throws this exception:

#

I've also tried using a macro for my-or-f. It compiles but it throws the same exception when I try running the query using this macro

(defmacro my-or-f []
`(apply or [(clojureql.predicates/in :tableA.id [1 2])
(clojureql.predicates/in :tableA.id [3 4])]))

Is there another way that I could use the "apply or"?

Thanks.