Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Mapper test failed with object nested integer field #4502

Open
juzq opened this issue Sep 13, 2023 · 2 comments · May be fixed by #4514
Open

Update Mapper test failed with object nested integer field #4502

juzq opened this issue Sep 13, 2023 · 2 comments · May be fixed by #4514
Assignees
Labels
type: bug A general bug

Comments

@juzq
Copy link

juzq commented Sep 13, 2023

when add following test code in UpdateMapperUnitTests.java, test would fail for parameter "levelOne.levelTwo.1.0" and "levelOne.levelTwo.2.0".

@ParameterizedTest
@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 EntityWithNestedObject1 {
    EntityWithNestedObject2 levelOne;
}

static class EntityWithNestedObject2 {
    Integer levelTwo;
}

test result:

expected: {"$set"={"levelOne.levelTwo.1.0"="4"}}
 but was: {"$set"={"levelOne.levelTwo.1"="4"}}

expected: {"$set"={"levelOne.levelTwo.2.0"="4"}}
 but was: {"$set"={"levelOne.levelTwo.2"="4"}}

yes, the last ".0" was lost, but parameter "levelOne.levelTwo.1" will test success.

the test code was pushed to my repository: https://github.com/juzq/spring-data-mongodb

@christophstrobl
Copy link
Member

@juzq thanks for reporting and the test - we're working on a solution.

@juzq
Copy link
Author

juzq commented Nov 23, 2023

@mp911de need to merge #4514 to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants