This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-09
Channels
- # announcements (3)
- # babashka (17)
- # beginners (75)
- # calva (43)
- # cider (1)
- # clj-kondo (54)
- # cljdoc (8)
- # cljs-dev (70)
- # clojure (83)
- # clojure-europe (27)
- # clojure-nl (4)
- # clojure-norway (4)
- # clojure-spec (8)
- # clojure-uk (13)
- # clojured (2)
- # clojurescript (47)
- # community-development (4)
- # conjure (2)
- # cursive (3)
- # datomic (5)
- # emacs (5)
- # events (3)
- # fulcro (13)
- # graalvm-mobile (19)
- # helix (2)
- # introduce-yourself (1)
- # jobs (2)
- # jobs-discuss (28)
- # kaocha (9)
- # livestream (11)
- # malli (15)
- # meander (24)
- # nextjournal (8)
- # off-topic (26)
- # pathom (1)
- # pedestal (8)
- # polylith (2)
- # portal (31)
- # re-frame (4)
- # reagent (10)
- # reitit (8)
- # remote-jobs (3)
- # sci (1)
- # shadow-cljs (66)
- # spacemacs (20)
- # testing (6)
- # vim (15)
- # xtdb (7)
Greetings everyone ☀️
Is there any reason why pull-many
seems to conj a`nil` to the returned coll, when one (or more) of the given eids
is not found?
(xt/pull-many (xt/db node) '[*] [:I'm-here')
returns
[{:... :xt/id :I'm-here!}]
and
(xt/pull-many (xt/db node) '[*] [:I-don't-exist :me-neither :I'm-here!])
returns
[{ ... :xt/id :I'm-here!} nil]
Thanks!Hey there 🌞
This looks like a consequence of the way that pull-many
is currently implemented:
• a single query is used, which means the results are turned into a set (i.e. duplicates are ellided) https://github.com/xtdb/xtdb/blob/1d304e60b4b488f840494911d173e6698546a629/core/src/xtdb/query.clj#L2048-L2055
• nil
is returned when a document is not found https://github.com/xtdb/xtdb/blob/013cdfd599795183efef82d58d61ad9fb8155115/core/test/xtdb/pull_test.clj#L250-L258
Would you instead expect to have a vector of documents/nils returns that match the order you provide? Or something else?
It looks like that's how DataScript does things https://github.com/tonsky/datascript/blob/9de5f962d0498819de51addb65247907ad99cde5/test/datascript/test/pull_api.cljc#L436-L448 :thinking_face:
Thanks @U899JBRPF — not sure. The presence of a nil
in the returned set is an indication that some eid
were not found, saving us to compare count
on both sets.
I believe the behavior is okay as long we users are aware of it.
Just checked, Datomic would output something like (where :xt/db
is :db/id
)
[{ ... :xt/id :I'm-here!}
{:xt/id :I-don't-exist}
{:xt/id :me-neither}]