Fix index validation for nested $and - #1014
Merged
Merged
Conversation
mango_selector:has_required_fields checks that a list of
indexed fields is covered by a given selector. The implementation
recurses through the selector, tracking fields that encounters.
Unfortunately, this skipped peers of combination operators. For
example,
"selector": {
"$and":[
"$and":[
"A": "foo"
],
"$and":[
"B": "bar"
]
]
}
would skip the first nested "$and" operator and only return "B"
as a covered field.
This commit explicitly handles this situation (the only combination
operator we care about is $and), so for the above selector we
would correctly indentify "A" and "B" as covered fields.
Member
Author
|
Thanks to @afinne for identifying the issue. The original bug report showed that the index / query combination at https://pastebin.com/WiQ5Edgu failed. |
3 tasks
Contributor
|
+1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
mango_selector:has_required_fields checks that a list of
indexed fields is covered by a given selector. The implementation
recurses through the selector, tracking fields that encounters.
Unfortunately, this skipped peers of combination operators. For
example,
would skip the first nested "$and" operator and only return "B"
as a covered field.
This commit explicitly handles this situation (the only combination
operator we care about is $and), so for the above selector we
would correctly identify "A" and "B" as covered fields.
Testing recommendations
Run the test suite. Test that Query selectors with nested
$andoperators correctly usejsonindexes that should cover them.Related Issues or Pull Requests
Checklist