Skip to content

Commit

Permalink
Tread entities nested in arrays like PUT for merge patch requests.
Browse files Browse the repository at this point in the history
Fixes GH-2358.
  • Loading branch information
odrotbohm committed Jan 19, 2024
1 parent 6cec482 commit 41de5ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ private boolean handleArrayNode(ArrayNode array, Collection<Object> collection,
if (ObjectNode.class.isInstance(jsonNode)) {

nestedObjectFound = true;
doMerge((ObjectNode) jsonNode, next, mapper);
readPut((ObjectNode) jsonNode, next, mapper);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,9 @@ void doesNotApplyInputToReadOnlyFields() throws Exception {
assertThat(reader.readPut(node, sample, mapper).createdDate).isEqualTo(reference);
}

@Test // DATAREST-931
void readsPatchForEntityNestedInCollection() throws Exception {
@Test // DATAREST-931, GH-2358
// https://datatracker.ietf.org/doc/html/rfc7386#section-2
void handlesEntityNestedInAnArrayLikePutForPatchRequest() throws Exception {

Phone phone = new Phone();
phone.creationDate = new GregorianCalendar();
Expand All @@ -251,7 +252,7 @@ void readsPatchForEntityNestedInCollection() throws Exception {

User result = reader.read(source, user, new ObjectMapper());

assertThat(result.phones.get(0).creationDate).isNotNull();
assertThat(result.phones.get(0).creationDate).isNull();
}

@Test // DATAREST-919
Expand Down

0 comments on commit 41de5ad

Please sign in to comment.