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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove null values in nested objects #353
Remove null values in nested objects #353
Changes from 17 commits
abd16fa
3a7d969
255893e
5b69984
b3d1873
71891de
3650021
df8f94b
053672b
be7d97d
2e0c967
ce61889
328265c
a70b43c
6b87144
d6c4e4a
a4dcbb0
05f19be
cf3da96
3b2f7eb
383bb08
25318f7
372d442
2e48152
b298ad6
3bb6ef2
1f50b0a
9462121
606cdf7
231fa65
1a3a14f
7a9453d
ef8f2c4
f272eab
f188dd9
b86d500
cde461f
c28c741
64ada0d
b5a0ba8
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add tests when
undefined
is passed instead ofnull
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marcaaron similar question about
undefined
values as here:Should we also ignore nested
undefined
values and not overwrite the current value or should the current value be overwritten?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have an existing test for OnyxCache, which expects
utils.fastMerge
to do nothing, when a nestedundefined
is passed:react-native-onyx/tests/unit/onyxCacheTest.js
Lines 312 to 322 in eeebcb3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @marcaaron
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think we would just filter them out? Undefined is the kind of the same as an object with no property (maybe it's arguable these are not the same or there should be some other behavior).
WRT how Onyx should work - I think these are equivalent and both would leave the source object unchanged
It can work however we want - this is mainly just my opinion because I'd prefer to see consistency and intentionality applied when deleting values or objects fields. If you pass
undefined
somewhere (intentionally or unintentionally) - I'm not really sure what you're trying to achieve. If you passnull
I can see it right away. 🤷♂️