Replace linkable associations when merging existing array elements for merge patch - #2597
Open
ogawa-takeshi wants to merge 1 commit into
Open
Replace linkable associations when merging existing array elements for merge patch#2597ogawa-takeshi wants to merge 1 commit into
ogawa-takeshi wants to merge 1 commit into
Conversation
…r merge patch. Since spring-projects#2358, an object nested in an array is applied to the existing element at the same index via readPut(…) to obtain PUT semantics as defined by RFC 7386. mergeForPut(…) however skips linkable associations, which is intended for top-level PUT requests where associations are managed through association resources. Nested elements are not exposed as association resources, so the request body is the only place to express them. As a result, non-association properties of an existing element were updated while its associations kept their previous values, whereas appended elements and elements written into an empty collection resolved them properly. We now merge existing array elements through a dedicated path that forwards linkable associations to the merging property handler, which replaces the reference with the one contained in the payload instead of merging the source state into the referenced instance. Closes spring-projects#2596. Signed-off-by: OGAWA, Takeshi <29126253+ogawa-takeshi@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #2596.
Since #2358, an object nested in an array is applied to the existing element at the same index via
readPut(…)to obtain PUT semantics (RFC 7386).mergeForPut(…)skips linkable associations, which is intended for top-levelPUTrequests where associations are managed through association resources. Nested elements have no association resource, so the request body is the only place to express them. As a result, non-association properties of an existing element were updated while its associations kept their previous values, whereas appended elements and elements written into an empty collection resolved them properly.This change
merges existing array elements through a dedicated path (
mergeArrayElement) that forwards linkable associations toMergingPropertyHandler,makes
MergingPropertyHandlerreplace a linkable association with the reference contained in the payload instead of merging the source state into the referenced instance,leaves the top-level
PUTpath (readPut/mergeForPut) unchanged,adds
patchReplacesReferenceOfEntityNestedInArraytoDomainObjectReaderUnitTests(fails onmain, passes with this change;handlesEntityNestedInAnArrayLikePutForPatchRequestfrom Nested arrays of entities need to get PUT semantics applied for merge patch #2358 keeps passing).You have read the Spring Data contribution guidelines.
You use the code formatters provided here and have them applied to your changes. Don't submit any formatting related changes.
You submit test cases (unit or integration tests) that back your changes.
You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).