diff options
author | David Storch <david.storch@10gen.com> | 2016-10-03 11:48:27 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2016-10-06 11:19:24 -0400 |
commit | 4976eb401b3f16482fb35287ea60d7e8b33fe76d (patch) | |
tree | 3ab5cfaec3f76dc334b006f0b1eeb7162772d4d6 /src/mongo/db/matcher/expression_algo_test.cpp | |
parent | a2d34afd4330258e05c5ac1e9174338cfda29a10 (diff) | |
download | mongo-4976eb401b3f16482fb35287ea60d7e8b33fe76d.tar.gz |
SERVER-19153 push $match as far forward as possible
Diffstat (limited to 'src/mongo/db/matcher/expression_algo_test.cpp')
-rw-r--r-- | src/mongo/db/matcher/expression_algo_test.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/mongo/db/matcher/expression_algo_test.cpp b/src/mongo/db/matcher/expression_algo_test.cpp index e8fe53ddc93..c97d766679a 100644 --- a/src/mongo/db/matcher/expression_algo_test.cpp +++ b/src/mongo/db/matcher/expression_algo_test.cpp @@ -906,6 +906,28 @@ TEST(SplitMatchExpression, ComplexMatchExpressionSplitsCorrectly) { "{$eq: 1}}]}]}, {y: {$eq: 3}}]}]}]}")); } +TEST(SplitMatchExpression, ShouldNotExtractPrefixOfDottedPathAsIndependent) { + BSONObj matchPredicate = fromjson("{$and: [{a: 1}, {'a.b': 1}, {'a.c': 1}]}"); + const CollatorInterface* collator = nullptr; + StatusWithMatchExpression status = + MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator); + ASSERT_OK(status.getStatus()); + + std::pair<unique_ptr<MatchExpression>, unique_ptr<MatchExpression>> splitExpr = + expression::splitMatchExpressionBy(std::move(status.getValue()), {"a.b"}); + + ASSERT_TRUE(splitExpr.first.get()); + BSONObjBuilder firstBob; + splitExpr.first->serialize(&firstBob); + + ASSERT_TRUE(splitExpr.second.get()); + BSONObjBuilder secondBob; + splitExpr.second->serialize(&secondBob); + + ASSERT_BSONOBJ_EQ(firstBob.obj(), fromjson("{'a.c': {$eq: 1}}")); + ASSERT_BSONOBJ_EQ(secondBob.obj(), fromjson("{$and: [{a: {$eq: 1}}, {'a.b': {$eq: 1}}]}")); +} + TEST(MapOverMatchExpression, DoesMapOverLogicalNodes) { BSONObj matchPredicate = fromjson("{a: {$not: {$eq: 1}}}"); const CollatorInterface* collator = nullptr; |