Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.2.x-4502-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Spring Data MongoDB</name>
Expand Down
2 changes: 1 addition & 1 deletion spring-data-mongodb-benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.2.x-4502-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-data-mongodb-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.2.x-4502-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-data-mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.2.x-4502-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1471,26 +1471,29 @@ protected String mapPropertyName(MongoPersistentProperty property) {
}

String nextToken = nextToken();
if (isPositionalParameter(nextToken)) {
if (property.isMap()) {

mappedName.append(".").append(nextToken);
currentIndex += 2;
return mappedName.toString();
}

if (property.isMap()) {

int i = 1;
while (isPositionalParameter(nextToken)) {
mappedName.append(".").append(nextToken);
currentIndex += 2;
return mappedName.toString();
i++;
nextToken = currentIndex + i < pathParts.size() ? pathParts.get(currentIndex + i) : "";
}

currentIndex++;
currentIndex += i;
return mappedName.toString();
}

static boolean isPositionalParameter(String partial) {

if(!StringUtils.hasText(partial)) {
return false;
}

if ("$".equals(partial)) {
return true;
}
Expand All @@ -1500,12 +1503,12 @@ static boolean isPositionalParameter(String partial) {
return true;
}

try {
Long.valueOf(partial);
return true;
} catch (NumberFormatException e) {
return false;
for (int i = 0; i < partial.length(); i++) {
if (!Character.isDigit(partial.charAt(i))) {
return false;
}
}
return true;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,17 @@ void updateConsidersValueConverterWhenPresent() {
assertThat(mappedUpdate).isEqualTo("{ $set : { 'text' : 'eulav' } }");
}

@ParameterizedTest // GH-4502
@ValueSource(strings = {"levelOne.levelTwo.1", "levelOne.levelTwo.1.0", "levelOne.levelTwo.2.0",})
void objectNestedIntegerFieldCorrectly(String path) {

Update update = new Update().set(path, "4");
Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
context.getPersistentEntity(EntityWithNestedObject1.class));

assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document(path, "4")));
}

static class DomainTypeWrappingConcreteyTypeHavingListOfInterfaceTypeAttributes {
ListModelWrapper concreteTypeWithListAttributeOfInterfaceType;
}
Expand Down Expand Up @@ -1818,4 +1829,12 @@ static class WithPropertyValueConverter {
@ValueConverter(ReversingValueConverter.class)
String text;
}

static class EntityWithNestedObject1 {
EntityWithNestedObject2 levelOne;
}

static class EntityWithNestedObject2 {
Integer levelTwo;
}
}