Skip to content

Update path not correctly mapped when last segment is multi digit number #4426

@juzq

Description

@juzq

in UpdateMapperUnitTests#mapNestedIntegerFieldCorrectly, when change the last integer to grater than 10, like this:

    @Test
    void mapNestedIntegerFieldCorrectly() {

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

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

then add a 2rd field in EntityWithNestedMap, like this:

	static class EntityWithNestedMap {
		Map<String, Map<String, Map<String, Object>>> levelOne;
		Map<String, Map<String, Map<String, Object>>> levelOne2;
	}

then, the test fails.

Expected :{"$set"={"levelOne.0.1.32"="4"}}
Actual :{"$set"={"levelOne2.0"="4"}}

Activity

christophstrobl

christophstrobl commented on Jun 27, 2023

@christophstrobl
Member

@juzq thanks for reporting and the PR!

added 3 commits that reference this issue on Jun 28, 2023
82917db
0cd082e
5bb7364
changed the title [-]Bug: mapNestedIntegerFieldCorrectly test failed, when change the last integer to grater than 10[/-] [+]Update path not correctly mapped when last segment is multi digit number[/+] on Jun 28, 2023
added a commit that references this issue on May 20, 2024
2de00cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Participants

      @christophstrobl@juzq@spring-projects-issues

      Issue actions

        Update path not correctly mapped when last segment is multi digit number · Issue #4426 · spring-projects/spring-data-mongodb