Fork me on GitHub

Will this library make writing queries a bit easier?


Potentially 🙂 generally speaking, I've always found standard literal quoting and the ability to operate on quoted forms ergonomic enough (e.g. (assoc '{:find [...] :where [...]} :in (vector 'x 'y 'z)))


are you thinking about this for generating queries? or for maintaining hand-written queries?


Yeah. Agree with you. I'm doing hard-written queries. I had a clause to check if an attribute is in a set. I used '[[e? :a v?] [(contains vs v?)]], with the vs part of :in . Then I thought it's better to do: '[[e? :a vs]] I can also do [['e? :a vs]] without having vs part of :in . Am I correct here?

👍 1

I guess having it as part of :in make it easier though. just quote the whole thing.


> I can also do `[['e? :a vs]]` without having vs part of :in . Am I correct here? yep that works too, there's a slight compilation performance cost with query caching (since technically it's a new query each time!) but that's usually far from being a bottleneck

👍 1

another aspect to consider is this other caveat about query planning when using :in

👍 1

Is this a bug? I have a models passed in but not used in the query. It returns different results with different models passed in.

user=> (xt/q  (xt/db node) {:find  '[(pull v? [*]) ] :where [['v? :x/type :v] '[(get-attr v? :v/model "") [model? ...]]   ] :in '[[models ...]]} [])

user=> (xt/q  (xt/db node) {:find  '[(pull v? [*]) ] :where [['v? :x/type :v] '[(get-attr v? :v/model "") [model? ...]]   ] :in '[[models ...]]} [""])
#{... }  ; some records returned
To answer my own question: if I remove the unused collection arg from :in, it works as expected. Though I feel unused param should not affect returned results instead of returns no results. Submitted jira:

🙏 1