You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can probably support this use case, although it will not use the :filter keyword to query. It would need to use a different keyword, perhaps :eval-filter, because otherwise it'll be impossible to distinguish between the following two uses:
(query:kind Order :filter (=:type"book"))
(query:kind Order :filter (filterexpand params))
I understand the appeal, though, and I'll keep this ticket open as a feature request for a future version. In the meanwhile, if you really need this, you can hack something together: you would need to construct the entire (query ...) expression as a list and eval it.
I have tried but ended up in a "Can't eval locals" error. It's very likely you stumble upon the same error.
Anyway, why not make it simple: if no operator recognized after :filter (no =, <, >, etc.), then just assume that there's an expression there that needs evaluation. In other words, just make :eval-filter an else-branch of :filter.
Hi,
I'm trying to generate the filter expression dynamically. It does not seem possible with the current implementation of query. Take following function
(defn filterexpand [params]
(map #(list '= (key %) (val %)) params))
Using it like this is not possible:
(defn search-orders [params]
(let [o (ds/query :kind Order (filterexpand params))]
(map-xml-list o)))
I also tried with a macro version of filterexpand:
(defmacro filterexpand [body]
(let [p (eval body)]
(map #(list '= (key %) (val%)) p)))
Can such usage of query be made possible?
Razvan
The text was updated successfully, but these errors were encountered: