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

Fix conversion of types when mapping Aggregation pipeline #4723

Closed
wants to merge 3 commits into from

Conversation

christophstrobl
Copy link
Member

This PR makes sure to apply conversion to non native mongo types when the context does not expose fields.

Resolves: #4722

This change makes sure to apply conversion to non native mongo types when the context does not expose fields.
@@ -62,7 +62,7 @@ static List<Document> toDocument(List<AggregationOperation> operations, Aggregat
if (operation instanceof InheritsFieldsAggregationOperation || exposedFieldsOperation.inheritsFields()) {
contextToUse = contextToUse.inheritAndExpose(fields);
} else {
contextToUse = fields.exposesNoFields() ? DEFAULT_CONTEXT
contextToUse = fields.exposesNoFields() ? ConverterAwareNoOpContext.instance(rootContext)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow why we have this distinction here. Switching to contextToUse = contextToUse.expose(fields); also lets all the tests pass.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might cause the mapping to consider filenames of follow up stages to be object to field name mapping which should not be done. if no tests fail, we should make sure that we have coverage there and do not hit a blank spot.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, then this one needs to wait for the next service release as we supposedly do not have sufficient test coverage.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirmed, we're missing a test here - like if we have an operation that forces field mapping to back off (like the replaceRoot one) a strict context would fail because of the missing exposure.

@moldo1997
Copy link

Hello @christophstrobl ,
Do you have an expected time for which this ticket will be merged?
Thanks,
Cristian

@moldo1997
Copy link

Hello @christophstrobl ,

Are there any updates regarding this ticket?

Was the test necessary for the ticket to be merged added?

Thank you,
Cristian

@mp911de mp911de changed the title Fix conversion of types when mapping Aggregation pipeline. Fix conversion of types when mapping Aggregation pipeline Oct 8, 2024
@mp911de mp911de added the type: bug A general bug label Oct 8, 2024
@mp911de mp911de added this to the 4.2.11 (2023.1.11) milestone Oct 8, 2024
mp911de pushed a commit that referenced this pull request Oct 8, 2024
This change makes sure to apply conversion to non native mongo types when the context does not expose fields.

Closes: #4722
Original pull request: #4723
mp911de added a commit that referenced this pull request Oct 8, 2024
See: #4722
Original pull request: #4723
mp911de pushed a commit that referenced this pull request Oct 8, 2024
This change makes sure to apply conversion to non native mongo types when the context does not expose fields.

Closes: #4722
Original pull request: #4723
mp911de added a commit that referenced this pull request Oct 8, 2024
See: #4722
Original pull request: #4723
mp911de pushed a commit that referenced this pull request Oct 8, 2024
This change makes sure to apply conversion to non native mongo types when the context does not expose fields.

Closes: #4722
Original pull request: #4723
mp911de added a commit that referenced this pull request Oct 8, 2024
See: #4722
Original pull request: #4723
@mp911de mp911de closed this Oct 8, 2024
@mp911de mp911de deleted the issue/4722 branch October 8, 2024 09:14
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 this pull request may close these issues.

Aggregation pipeline breaks if $replaceRoot stage is present
3 participants