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

emit an $addFields stage before $sort with safe aliases if necessary #109

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hallettj
Copy link
Collaborator

This fixes sorting on field names that contain dollar signs or dots. It also provides a framework that we can use to sort on aggregation results.

Unlike $match (which has the $expr operator), the $sort stage does not have any way to express arbitrary expressions. That is necessary to use the $getField operator which is what we use to reference field names that need to be escaped. So what this PR does is to inject an $addFields stage before the $sort stage if necessary that creates aliases that are safe to use as keys in $sort.

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.

1 participant