Fork me on GitHub

Is there an easy way to construct the where clause for a query? Like conditionaly i want this where clause or this one.


cond-> and a steady hand


is it not an appropriate use for a or or rule?


gotcha. I was trying to remember how programmatic queries worked.


The other options you mentioned might work to for my case.


but not always. ad-hoc filters is one case where it’s just easier and more predictable performance to add/remove clauses


but keep clause order deterministic, so you can still leverage caching


@U0DJ4T5U1 you want backtick

(let [needle "foo"]
    [[(clojure.string/includes? ?name ~needle)]]))
=> [[(clojure.string/includes? ?name "foo")]]
Yes be sure that you aren’t blowing out number of static queries, parameterize them appropriately if possible, injecting a string constant in this way would be a really bad idea, but injecting a clause based on a predicate would be fine as it emits only two possible queries


What i feel i need to express is the idea of conditionally picking the part of the where clauses. d/q [:find ?x :where [?a :fname "drew"] (if some-conditional [?a :lname "verlee"] [?a :age 15] I think i need to insert the entire clause(s) as opposed to just an entity, attribute or value.


is this because you have a multiparameter search interface, and some fields can be unused?


Just wondering what your use case is. What you wrote here is possible but not the best--parameterization is better; conditionally emitting clauses can sometimes be ok but still using parameterization