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 collection notifications reporting modifications when sort/distinct has been applied #4573

Merged
merged 3 commits into from
Apr 6, 2021

Conversation

ironage
Copy link
Contributor

@ironage ironage commented Mar 26, 2021

When checking if an item has been modified in a collection, we should check the old indices reported by modifications instead of modifications_new. They will normally be the same, except on sorted collections, when the modification results in a change of the ordering.

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)

@ironage ironage requested a review from tgoyne March 26, 2021 22:46
@ironage ironage self-assigned this Mar 26, 2021
@tgoyne
Copy link
Member

tgoyne commented Mar 26, 2021

Using modifications_new rather than modifications should also produce incorrect results on unsorted collections when rows are deleted before the modified rows.

REQUIRE_INDICES(change.modifications, 0);
REQUIRE_INDICES(rchange.insertions);
REQUIRE_INDICES(rchange.deletions);
REQUIRE_INDICES(rchange.modifications, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to also check modifications_new whenever modifications gets checked? Just to make sure all four categories do look exactly as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated!

@ironage
Copy link
Contributor Author

ironage commented Apr 6, 2021

Using modifications_new rather than modifications should also produce incorrect results on unsorted collections when rows are deleted before the modified rows.

I added a test for this and unsorted collections appear to be ok. Turns out it is only collections with sort/distinct applied because otherwise a different code path is used: https://github.com/realm/realm-core/blob/master/src/realm/object-store/impl/results_notifier.cpp#L298-L300

@ironage ironage changed the title fix collection notifications with only modifications fix collection notifications reporting modifications when sort/distinct has been applied Apr 6, 2021
@ironage ironage merged commit a0b1629 into master Apr 6, 2021
@ironage ironage deleted the js/collection-notification-mods branch April 6, 2021 22:46
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2024
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.

3 participants