Closed roookeee closed 5 years ago
Maybe add a nullsafe()
function that turns all map
calls etc. into implicit null safe variants. This looks like the most elegant solution, but we lose explicitness and pay a slight performance penalty for any subsequent intra-step map
s that don't need to handle null.
EDIT: Thinking about it: when nullsafe()
is used all subsequent steps have to be null safe too so this argument is void
Add a mapNullsafe()
(bad name, just an example) ? It's quite verbose but has no other drawbacks compared to the aforementioned variant.
On the other hand: once you have done one mapNullSafe()
all the following steps have to be nullsafe too which makes this approach less appealing
A working implementaion is in PR #22. Instead of adding a boolean flag for the implicit null checking I opted for an extendable enum to not break the public APIs as easily in the future
Will probably do a 1.3.0 release this weekend that includes this feature as it's quite useful
This feature will be released tomorrow after a local review
Released
As much as datus is about explicitness: traversing nested objects which can be null is quite cumbersome as it stands.
We have to find a way to avoid something like this:
I personally would like to veto any variant that would make every mapping step of a mapping definition nullsafe - it's too implicit.