I would prefer the behavior described in the docs, which is useful when "rebasing" entities by their id across different databases (i.e., one can use keep or other Clojure nil punning fns to discard any entities that may have been removed in a derived database).
Happy to submit a patch if maintainers agree that the documented behavior is, in fact, the desired one.
The docs suggest that
entity
should returnnil
when the provided id doesn't actually correspond to an entity in the database:https://github.com/tonsky/datascript/blob/1a405721cb2226a28678066b176a5326c264153e/src/datascript/core.cljc#L31-L33
but in fact it always returns an entity. E.g., with datascript 1.4.1 on JVM Clojure:
The only check seems to be that the number isn't above
emax
https://github.com/tonsky/datascript/blob/1a405721cb2226a28678066b176a5326c264153e/src/datascript/db.cljc#L1042-L1044
I would prefer the behavior described in the docs, which is useful when "rebasing" entities by their id across different databases (i.e., one can use
keep
or other Clojure nil punning fns to discard any entities that may have been removed in a derived database).Happy to submit a patch if maintainers agree that the documented behavior is, in fact, the desired one.