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

UpdateOpsImpl does not respect fieldName annotations for maps #1123

Closed
VPriesnitz opened this issue Jan 11, 2017 · 0 comments
Closed

UpdateOpsImpl does not respect fieldName annotations for maps #1123

VPriesnitz opened this issue Jan 11, 2017 · 0 comments
Milestone

Comments

@VPriesnitz
Copy link
Contributor

VPriesnitz commented Jan 11, 2017

Hello,
This is a critical bug.

When updating a field of type Map that has a fieldName annotation (@Embedded or @Property), then an update on that field does not replace the field's name with the provided value.

POJO
class Payload {
@id
private ObjectId id;

    @Property("c")
    private final Map<String, String> content = new HashMap<String, String>();
}

Update
ds.createUpdateOperations(Payload.class) .set("content.key", "newValue");

results in mongo:
{ "_id": { "$oid": "587609d12e934813a926ec69" }, "c": { "key": "value" }, "content": { "key": "newValue" } }
Note that the Document contains now both "c" and "content". The update returns without error and subsequent retrievals will ignore this update.

This behaviour was introduced in commit d0d9e04

Attached is patch that contains a unitTest to reproduce the issue. (had to rename from .patch to .TXT got github )
testUpdatingMapFieldsAnnotatedWithFieldNames.TXT

@evanchooly evanchooly added this to the 1.4.0 milestone Jan 13, 2017
evanchooly pushed a commit that referenced this issue Jan 24, 2017
commit 97dcaf1
Author: Daniel Breitlauch <daniel.breitlauch@researchgate.net>
Date:   Wed Jan 11 16:02:07 2017 +0100

    always translate according to annotation + unit test to verify

fixes #1124
fixes #1123

(cherry picked from commit f571dad)
@evanchooly evanchooly modified the milestones: 1.4.0, 1.5.0 Oct 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants