Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Fix store null values in lists #424

Merged
merged 5 commits into from
Dec 27, 2018
Merged

Fix store null values in lists #424

merged 5 commits into from
Dec 27, 2018

Conversation

T4rk1n
Copy link
Contributor

@T4rk1n T4rk1n commented Dec 26, 2018

Assert that both old and new data is not null when checking if the data needs update.

Part of fix for #422.

@rmarren1 please review.

@T4rk1n T4rk1n requested a review from rmarren1 December 26, 2018 19:48
@rmarren1
Copy link
Contributor

💃

if (R.isNil(old) || R.isNil(data)) {
const oldNull = R.isNil(old);
const newNull = R.isNil(data);
if ((oldNull || newNull) && !(oldNull && newNull)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this a bit hard to read... how about if (oldNull !== newNull) ? Or I suppose you could short-circuit the logic below with something like if (oldNull || newNull) { return oldNull !== newNull; }

Separately, it looks to me as though the checks below implicitly assume old and data have the same type, and may fail if for example data is an Array and old is an Object. Should we include a step if (R.type(old) !== type) { return false; }?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separately, it looks to me as though the checks below implicitly assume old and data

That's the second part of #422, I'll add a test and fix it in another PR. Initial implementation assumed data was of the same shape.

// Assuming data and old are of the same type.

@T4rk1n T4rk1n merged commit 51f04a3 into master Dec 27, 2018
@T4rk1n T4rk1n deleted the fix-store-null branch December 27, 2018 18:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants