This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-13
Channels
- # announcements (18)
- # babashka (52)
- # beginners (47)
- # calva (45)
- # clj-kondo (31)
- # clojure (18)
- # clojure-brasil (2)
- # clojure-europe (3)
- # clojure-sweden (25)
- # clojurescript (19)
- # cursive (15)
- # datalevin (11)
- # defnpodcast (2)
- # duct (1)
- # editors (1)
- # emacs (6)
- # gratitude (1)
- # introduce-yourself (6)
- # jobs-discuss (11)
- # leiningen (3)
- # lsp (10)
- # luminus (2)
- # off-topic (4)
- # podcasts-discuss (2)
- # reitit (2)
- # shadow-cljs (10)
- # sql (9)
- # xtdb (4)
when I have a collection input variable being used in not clause, seems it only check one value in the collection. Below query still returns entities with attribute :tag8 with value tag8-9. If I change the arg to only has tag8-9, results exclude those. Appreciate for suggestions! Example query:
(xt/q (xt/db node) '{:find [(pull v? [*]) tag8?] :in [ [arg-tag8s-0 ...] ] :where [[v? :x/type :v] [(get-attr v? :v/tag8 "") [tag8? ...]] (not [v? :v/tag8 arg-tag8s-0])] :limit 10} ["tag8-8" "tag8-9"])
also created discuss topic: https://discuss.xtdb.com/t/issue-in-collection-literal-used-in-not-clause/76
I played around with this for a minute and I think there are two issues: one is query will return a document if it has tags that do not overlap with the input vector (instead of checking for all), and the second issue is that it seems :limit 10
changes the semantics of the query somehow.
I changed the input to pass a set and am checking directly with a predicate. So this query returns all documents that contain none of the supplied tags:
(xt/submit-tx xtdb-node (mapv #(do [::xt/put %])
[{:xt/id 1 :x/type :v :v/tag8 ["tag8-8" "tag8-9"]}
{:xt/id 2 :x/type :v :v/tag8 ["not-tag8-8" "another"]}
{:xt/id 3 :x/type :v :v/tag8 ["not-tag8-8" "second-tag"]}] ) )
(xt/q (xt/db xtdb-node) '{:find [v?]
:in [arg-tag8s-0]
:where [[v? :x/type :v]
[v? :v/tag8 ?tags]
(not [(contains? arg-tag8s-0 ?tags)])]
;:limit 10
}
#{"tag8-8" "tag8-9"})
=> #{[3] [2]}
if you include the :limit 10
however I get:
=> [[2] [2] [3] [3]]
which is still not 1 at least.
I am not sure if that helps at all, but hope it does