Preserve numeric keys that exceed Long range when mapping Updates.

This commit makes sure we preserve map keys no matter what.

Closes #3552.
Original pull request: #3565.
This commit is contained in:
Christoph Strobl
2021-02-19 10:30:20 +01:00
committed by Mark Paluch
parent bcb5628840
commit a5e209379c
2 changed files with 23 additions and 2 deletions

View File

@@ -1329,9 +1329,9 @@ public class QueryMapper {
String partial = iterator.next();
boolean isPositional = (isPositionalParameter(partial) && (property.isMap() || property.isCollectionLike()));
boolean isPositional = isPositionalParameter(partial) && property.isCollectionLike();
if (isPositional) {
if (isPositional || property.isMap()) {
mappedName.append(".").append(partial);
}

View File

@@ -1159,6 +1159,27 @@ class UpdateMapperUnitTests {
new Document("prefix-stringValue", "updated").append("prefix-listValue", Arrays.asList("val-1", "val-2")))));
}
@Test // GH-3552
void numericKeyForMap() {
Update update = new Update().set("map.601218778970110001827396", "testing");
Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
context.getPersistentEntity(EntityWithObjectMap.class));
assertThat(mappedUpdate).isEqualTo(Document.parse("{\"$set\": {\"map.601218778970110001827396\": \"testing\"}}"));
}
@Test // GH-3552
void numericKeyInMapOfNestedPath() {
Update update = new Update().set("map.601218778970110001827396.value", "testing");
Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
context.getPersistentEntity(EntityWithObjectMap.class));
assertThat(mappedUpdate)
.isEqualTo(Document.parse("{\"$set\": {\"map.601218778970110001827396.value\": \"testing\"}}"));
}
static class DomainTypeWrappingConcreteyTypeHavingListOfInterfaceTypeAttributes {
ListModelWrapper concreteTypeWithListAttributeOfInterfaceType;
}