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

Open
wants to merge 3 commits into
base: main
Choose a base branch
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Aggregation pipeline breaks if $replaceRoot stage is present
2 participants