Skip to content

Nested data structure update (numeric keys) #3652

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

Closed
MarcoFlo opened this issue May 17, 2021 · 3 comments
Closed

Nested data structure update (numeric keys) #3652

MarcoFlo opened this issue May 17, 2021 · 3 comments
Labels
status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-feedback We need additional information before we can continue

Comments

@MarcoFlo
Copy link

When I try to update a nested data structure with numeric keys, the operation doesn't turn out as expected and the nested structure is not preserved.

An example:
new org.springframework.data.mongodb.core.query.Update().set("node.1.59.21", dataEntity)
insert_err

This behaviour was not present in spring-boot-starter-data-mongodb/2.3.9.RELEASE, but from that version onwards yes (2.3.10.RELEASE and 2.4.5 tested)

The java driver (4.0.5, 4.0.6, 4.1.2) itself has been excluded, due to the fact
com.mongodb.client.model.Updates.set("node.1.59.21", dataEntity.toDocument())
works as expected and it's my current workaround.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 17, 2021
@christophstrobl
Copy link
Member

Thanks for reporting.
Can you please share the context this is used in. The domain types and the actual update invocation. A Minimal, Reproducible Example would be ideal.

The following seems to work as expected with spring-data-mongodb:3.1.8 used by spring-boot:2.4.5.

Update update = new Update().set("node.1.59.21", new Document("the", "value"));
Document mappedUpdate = updateMapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(Model.class));
assertThat(mappedUpdate).isEqualTo(Document.parse("{ '$set' : { 'node.1.59.21' : {'the' : 'value' }}}"));

@christophstrobl christophstrobl added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels May 17, 2021
@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label May 24, 2021
@MarcoFlo
Copy link
Author

@christophstrobl I'm not really able to pin point the reason, but I'm no more able to reproduce this behaviour and now it's all working as expected.

I suppose the issue can be closed.
Sorry for the late and kind of response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-feedback We need additional information before we can continue
Projects
None yet
Development

No branches or pull requests

3 participants