summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/query_planner_test_lib.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query/query_planner_test_lib.cpp')
-rw-r--r--src/mongo/db/query/query_planner_test_lib.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mongo/db/query/query_planner_test_lib.cpp b/src/mongo/db/query/query_planner_test_lib.cpp
index 2cfcc54985b..809945049b2 100644
--- a/src/mongo/db/query/query_planner_test_lib.cpp
+++ b/src/mongo/db/query/query_planner_test_lib.cpp
@@ -79,8 +79,13 @@ bool filterMatches(const BSONObj& testFilter,
if (!statusWithMatcher.isOK()) {
return false;
}
- const std::unique_ptr<MatchExpression> root = std::move(statusWithMatcher.getValue());
+ std::unique_ptr<MatchExpression> root = std::move(statusWithMatcher.getValue());
CanonicalQuery::sortTree(root.get());
+ if (root->matchType() == mongo::MatchExpression::NOT) {
+ // Ideally we would optimize() everything, but some of the tests depend on structural
+ // equivalence of single-arg $or expressions.
+ root = MatchExpression::optimize(std::move(root));
+ }
std::unique_ptr<MatchExpression> trueFilter(trueFilterNode->filter->shallowClone());
CanonicalQuery::sortTree(trueFilter.get());
return trueFilter->equivalent(root.get());