[BUGFIX] ensure ManyArray state is in-sync with relationship state #5462
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.
This PR extracts the non-diff changes from #5269. In general this is just a nice cleanup PR.
It ideally would include a test to show the issue with ManyArray losing sync that it addresses; however, because we do not currently correctly diff when flushing canonical state (thereby losing local changes), this out-of-sync issue is very hard to manifest as in most scenarios we would be in the same incorrect state even though we were drawing our state from the incorrect source. To be out-of-sync required the currentState to be different from canonicalState post flushCanonical for more changes than just
isNew
records.I've taken the opportunity to port the tests from #5269 and converted them to
todo
. While fixing the ManyArray state won't resolve those tests, it will move our ability to fix "currentState" in ManyArray forward, and this fix was needed for the full solution in that PR.