datascript icon indicating copy to clipboard operation
datascript copied to clipboard

Pulling bad lookup refs fails instead of returning `nil` or `{:db/id nil}` (datomic behavior)

Open metasoarous opened this issue 9 years ago • 4 comments

It would be nice to mirror more closely here.

metasoarous avatar Jul 04 '16 07:07 metasoarous

A bit of context: In working with posh, lookup refs can be rather problematic, erroring out and not recovering when a posh query uses a lookup ref for data that isn't loaded yet. This can be worked around in posh, to some extent, by watching for this sort of situation and trying to handle gracefully, but it would be a lot easier if DS copied Datomic's behavior here, since client code can usually deal with {:db/id nil} gracefully a lot more easily. And also, I'd rather posh and DS be on the same page in how they handle edge cases like this (where possible).

In any case, I'm happy to try and help with this if it's something you're keen on. I would just need a little guidance about where it would be best to introduce a fix.

I don't recall at the moment whether this is a problem with q as well, but I can chime back here as I work around this.

metasoarous avatar Aug 22 '16 18:08 metasoarous

Yeah, this would be nice!

mpdairy avatar Aug 22 '16 18:08 mpdairy

Realized the Datomic behavior is slightly more nuanced than I realized.

When a lookup ref (or eid) can't be resolved, it return nil, unless the pull expression contains :db/id, in which case it returns {:db/id nil}.

metasoarous avatar Aug 22 '16 19:08 metasoarous

Is this being worked on?

ghost avatar Nov 15 '16 16:11 ghost