Skip to content

Commit

Permalink
Preserve class keyword as Map key during update mapping.
Browse files Browse the repository at this point in the history
This commit makes sure to skip the class property ob Object when mapping maps and their keys inside an Update.

Closes #3566
Original pull request: #3577.
  • Loading branch information
christophstrobl authored and mp911de committed Mar 2, 2021
1 parent 22ed860 commit c3b4f61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,8 @@ private PropertyPath forName(String path) {

private boolean isPathToJavaLangClassProperty(PropertyPath path) {

if (path.getType().equals(Class.class) && path.getLeafProperty().getOwningType().getType().equals(Class.class)) {
if ((path.getType() == Class.class || path.getType().equals(Object.class))
&& path.getLeafProperty().getType() == Class.class) {
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,17 @@ void numericKeyInMapOfNestedPath() {
.isEqualTo("{\"$set\": {\"map.601218778970110001827396.value\": \"testing\"}}");
}

@Test // GH-3566
void mapsObjectClassPropertyFieldInMapValueTypeAsKey() {

Update update = new Update().set("map.class", "value");
Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
context.getPersistentEntity(EntityWithObjectMap.class));

assertThat(mappedUpdate)
.isEqualTo("{\"$set\": {\"map.class\": \"value\"}}");
}

static class DomainTypeWrappingConcreteyTypeHavingListOfInterfaceTypeAttributes {
ListModelWrapper concreteTypeWithListAttributeOfInterfaceType;
}
Expand Down

0 comments on commit c3b4f61

Please sign in to comment.