fix: restore old behavior in deprecation #9364
Merged
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.
Description
This is a fix for the deprecation @ https://deprecations.emberjs.com/ember-data/v5.x/#toc_ember-data-deprecate-relationship-remote-update-clearing-local-state
In the case of a remote update with a local change, I think we want to have the remote state as the local state in the old way.
@runspired Does this make sense? Just encountered this issue in our upgrade from v4 => v5. Perhaps this is a copy/paste issue from the deprecation warning in line #89...
In v4 we run into this branch:
https://github.com/emberjs/data/blob/v4.12.7/packages/graph/src/-private/graph/operations/replace-related-record.ts#L131
In v5 we run into this branch:
https://github.com/emberjs/data/blob/v5.3.3/packages/graph/src/-private/operations/replace-related-record.ts#L168
Example:
We change a relationship from record "1" to "null" and on save, the server returns a record "99" for this relationship.
In v4 and v5 we have the following state:
In v4 we end up with '99' as the new local state (
relationship.localState = remoteState
).In v5 we end up with '1' as the new local state (
relationship.localState = existingState
). But in my understanding it should be '99' in the old way.Notes for the release