Fork me on GitHub
#xtdb
<
2022-02-09
>
fugbix08:02:17

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!

refset10:02:37

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-L2055nil 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?

fugbix13:02:11

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.

fugbix13:02:17

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}]

😄 1
refset14:02:03

> the behavior is okay as long we users are aware of it A clearer docstring at a minimum is a good idea. Thanks for the feedback though - we'll give it some thought soon 🙏