This repository has been archived by the owner on Mar 20, 2022. It is now read-only.
Fixed denormalization skipping of falsy valued ids used in Object
schemas
#345
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Currently, if one has an
Object
schema that contains properties that are mapped to other entities, if the id of one of those mapped entities is0
or some other falsy value, it will be skipped during denormalization. Seeing that0
is not an uncommonly used id, it makes sense to allow non-null/non-undefined falsy values to be evaluated rather than skip them as if they were null or undefined.Here is an example schema that would not currently allow a
categoryOwner
with an id of0
to be denormalized, instead, denormalization ofcategoryOwner
would be skipped and the value ofcategoryOwner
would remain0
:Solution
The solution here was very simple. There is a check for see if an object's property evaluates to a falsy value; I simply changed this check from
if (object[key])
toif (object[key] != null)
so that onlynull
andundefined
values would be skipped.I also added a test to
Object.test.js
for the expected behavior.TODO