summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/query_planner_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query/query_planner_test.cpp')
-rw-r--r--src/mongo/db/query/query_planner_test.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/mongo/db/query/query_planner_test.cpp b/src/mongo/db/query/query_planner_test.cpp
index b47e3106ada..c325cadd76d 100644
--- a/src/mongo/db/query/query_planner_test.cpp
+++ b/src/mongo/db/query/query_planner_test.cpp
@@ -59,7 +59,8 @@ namespace {
//
void setIndex(BSONObj keyPattern) {
- keyPatterns.push_back(keyPattern);
+ // false means not multikey.
+ keyPatterns.push_back(IndexEntry(keyPattern, false));
}
//
@@ -162,7 +163,7 @@ namespace {
BSONObj queryObj;
CanonicalQuery* cq;
- vector<BSONObj> keyPatterns;
+ vector<IndexEntry> keyPatterns;
vector<QuerySolution*> solns;
};
@@ -356,6 +357,26 @@ namespace {
cout << indexedSolution->toString() << endl;
}
+ TEST_F(SingleIndexTest, AndWithUnindexedOrChild) {
+ setIndex(BSON("a" << 1));
+ runQuery(fromjson("{a:20, $or: [{b:1}, {c:7}]}"));
+ ASSERT_EQUALS(getNumSolutions(), 2U);
+ QuerySolution* indexedSolution = NULL;
+ getPlanByType(STAGE_FETCH, &indexedSolution);
+ cout << indexedSolution->toString() << endl;
+ }
+
+
+ TEST_F(SingleIndexTest, AndWithOrWithOneIndex) {
+ setIndex(BSON("b" << 1));
+ setIndex(BSON("a" << 1));
+ runQuery(fromjson("{$or: [{b:1}, {c:7}], a:20}"));
+ ASSERT_EQUALS(getNumSolutions(), 2U);
+ QuerySolution* indexedSolution = NULL;
+ getPlanByType(STAGE_FETCH, &indexedSolution);
+ cout << indexedSolution->toString() << endl;
+ }
+
//
// Tree operations that require simple tree rewriting.
//
@@ -520,6 +541,13 @@ namespace {
ASSERT_EQUALS(getNumSolutions(), 2U);
}
+ TEST_F(SingleIndexTest, ElemMatchCompoundTwoFields) {
+ setIndex(BSON("a.b" << 1 << "a.c" << 1));
+ runQuery(fromjson("{a : {$elemMatch: {b:1, c:1}}}"));
+ dumpSolutions();
+ ASSERT_EQUALS(getNumSolutions(), 2U);
+ }
+
// STOPPED HERE - need to hook up machinery for multiple indexed predicates
// second is not working (until the machinery is in place)
//