Skip to content
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

Fix minor issues after introducing incremental JSON_PATCH merge #284

Merged
merged 16 commits into from
Jul 27, 2023

Conversation

chrispader
Copy link
Contributor

@marcaaron

Details

Fixing some issues i encountered while testing the JSON_PATCH merge changes in the Expensify/App repo in this PR

When batching the changes from mergeQueue, top-level null values may not be omitted. Only when merging the final value, we can remove these null values.

Also added back a log line, that was removed in the other PR

Related Issues

Automated Tests

Linked PRs

@chrispader chrispader requested a review from a team as a code owner July 25, 2023 12:28
@melvin-bot melvin-bot bot requested review from tgolen and removed request for a team July 25, 2023 12:29
lib/Onyx.js Outdated Show resolved Hide resolved
lib/Onyx.js Outdated Show resolved Hide resolved
lib/Onyx.js Outdated Show resolved Hide resolved
lib/Onyx.js Outdated Show resolved Hide resolved
lib/Onyx.js Outdated Show resolved Hide resolved
lib/Onyx.js Outdated Show resolved Hide resolved
lib/Onyx.js Outdated Show resolved Hide resolved
@chrispader
Copy link
Contributor Author

@marcaaron @tgolen all review comments adressed! 👍

Copy link
Collaborator

@tgolen tgolen left a comment

Choose a reason for hiding this comment

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

Thanks for those changes. You'll get the hang of the comments in time, so keep working on them!

lib/Onyx.js Outdated Show resolved Hide resolved
lib/Onyx.js Show resolved Hide resolved
lib/Onyx.js Outdated Show resolved Hide resolved
lib/Onyx.js Outdated Show resolved Hide resolved
@marcaaron
Copy link
Contributor

+1 to @tgolen's comments about comments :)

don't we actually want to drop those keys from storage and not just set them to "null" or is it the same thing as far as SQLite is concerned?

Also, I think this is a part that could be better explained in the comments as well. JSON_PATCH() behavior will delete a top level key when the value is null like in this example...

2023-07-26_08-13-02

@chrispader
Copy link
Contributor Author

Also, I think this is a part that could be better explained in the comments as well. JSON_PATCH() behavior will delete a top level key when the value is null like in this example...

Ah i understand, didn't know, that that's why we added this manually for web. Gonna further explain this in the comments then!

@chrispader
Copy link
Contributor Author

If we are using this method to build the "batch of changes" then don't we actually want to drop those keys from storage and not just set them to "null" or is it the same thing as far as SQLite is concerned?

When building the batch of changes, we don't want to omit the null keys, because then this would happen:

Changes like [{key1: null, key2: null}, {key3: null}] turn into modifiedData: {}. Merging the existing object value with {} will not update it though, because merging {} is the same as merging nothing.

For creating the modifiedData we'll want to omit the keys, so they get removed from storage.

Copy link
Collaborator

@tgolen tgolen left a comment

Choose a reason for hiding this comment

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

Getting close!

lib/Onyx.js Outdated Show resolved Hide resolved
Co-authored-by: Tim Golen <[email protected]>
tgolen
tgolen previously approved these changes Jul 26, 2023
Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

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

One small thing that needs to be addressed. Looks good - thanks for the changes!

lib/Onyx.js Outdated Show resolved Hide resolved
lib/Onyx.js Outdated Show resolved Hide resolved
lib/Onyx.js Outdated Show resolved Hide resolved
@marcaaron
Copy link
Contributor

One last thing 🥲

@chrispader
Copy link
Contributor Author

One last thing 🥲

fixed!

Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

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

Thanks @tgolen and @marcaaron for pushing this forwards.

To unblock the other onyx caching PR, I am going to approve and merge this, given Tim already gave approval and the last changes requested by Marc has been addressed and they were just comments.

@mountiny mountiny merged commit c3c7ab5 into Expensify:main Jul 27, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants