Skip to content

Commit

Permalink
Fixes it but needs a better concept
Browse files Browse the repository at this point in the history
  • Loading branch information
christophstrobl committed Sep 26, 2023
1 parent 949409a commit cbed334
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1470,11 +1470,15 @@ protected String mapPropertyName(MongoPersistentProperty property) {
return mappedName.toString();
}

String nextToken = nextToken();
if (isPositionalParameter(nextToken)) {

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

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;
}
}

0 comments on commit cbed334

Please sign in to comment.