datascript
datascript copied to clipboard
Pulling bad lookup refs fails instead of returning `nil` or `{:db/id nil}` (datomic behavior)
It would be nice to mirror more closely here.
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.
Yeah, this would be nice!
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}.
Is this being worked on?