Fork me on GitHub
#xtdb
<
2021-12-29
>
match3706:12:26

Will this library make writing queries a bit easier? https://github.com/brandonbloom/backtick

refset18:12:21

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)))

refset18:12:15

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

match3718:12:27

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
match3718:12:32

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

refset18:12:06

> 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
refset18:12:15

another aspect to consider is this other caveat about query planning when using :in https://github.com/xtdb/xtdb/issues/1447

👍 1
match3719:12:57

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: https://github.com/xtdb/xtdb/issues/1680

🙏 1