Skip to content

AddFieldsOperationBuilder.addFieldWithValueOf should treat String value as Field reference #4933

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

Open
crmky opened this issue Apr 2, 2025 · 1 comment
Assignees
Labels
type: bug A general bug

Comments

@crmky
Copy link

crmky commented Apr 2, 2025

The current implementation treat String value as Fields instead of Field. However org.springframework.data.mongodb.core.aggregation.DocumentEnhancingOperation.computeValue(Object, AggregationOperationContext) doesn't support Fields but only Field, the generated BSON document is incorrect.

I think change this line from:

valueMap.put(field, value instanceof String stringValue ? Fields.fields(stringValue) : value);

to

valueMap.put(field, value instanceof String stringValue ? Fields.field(stringValue) : value);

should fix that issue.

@christophstrobl
Copy link
Member

Good catch @crmky - thanks for reporting.

@christophstrobl christophstrobl added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 14, 2025
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

No branches or pull requests

3 participants