summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/query_planner_wildcard_index_test.cpp
diff options
context:
space:
mode:
authoryarai <yuta.arai@10gen.com>2018-10-10 18:01:52 -0400
committeryarai <yuta.arai@10gen.com>2018-10-15 12:05:32 -0400
commitc2b08fc7c1228402663d166074176c314664befe (patch)
treeb5f78262d5d9ae1db8368dc31244900a3cabd344 /src/mongo/db/query/query_planner_wildcard_index_test.cpp
parente62512d50329877c84a7b2404c8c6158479efede (diff)
downloadmongo-c2b08fc7c1228402663d166074176c314664befe.tar.gz
SERVER-37503 Support $type with wildcard index
Diffstat (limited to 'src/mongo/db/query/query_planner_wildcard_index_test.cpp')
-rw-r--r--src/mongo/db/query/query_planner_wildcard_index_test.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/mongo/db/query/query_planner_wildcard_index_test.cpp b/src/mongo/db/query/query_planner_wildcard_index_test.cpp
index 025f1ce9fa5..03af6b93227 100644
--- a/src/mongo/db/query/query_planner_wildcard_index_test.cpp
+++ b/src/mongo/db/query/query_planner_wildcard_index_test.cpp
@@ -1817,4 +1817,27 @@ TEST_F(QueryPlannerWildcardTest, ContainedOrPushdownWorksWithWildcardIndex) {
"{$_path: [['a','a',true,true]], a:[[1,1,true,true]]}}}}}");
}
+TEST_F(QueryPlannerWildcardTest, TypeOfObjectWithWildcardIndex) {
+ addWildcardIndex(BSON("$**" << 1));
+ runQuery(fromjson("{a: {$type: 'object'}}"));
+
+ assertNumSolutions(1U);
+ assertSolutionExists(
+ "{fetch: {filter: {a: {$type: [3]}}, node:"
+ "{ixscan: {filter: null, pattern: {$_path: 1, a: 1}, bounds:"
+ "{$_path: [['a','a',true,true], ['a.','a/', true, false]], "
+ "a:[['MinKey','MaxKey',true,true]]}}}}}");
+}
+
+TEST_F(QueryPlannerWildcardTest, TypeOfArrayWithWildcardIndex) {
+ addWildcardIndex(BSON("$**" << 1));
+ runQuery(fromjson("{a: {$type: 'array'}}"));
+
+ assertNumSolutions(1U);
+ assertSolutionExists(
+ "{fetch: {filter: {a: {$type: [4]}}, node:"
+ "{ixscan: {filter: null, pattern: {$_path: 1, a: 1}, bounds:"
+ "{$_path: [['a','a',true,true], ['a.','a/', true, false]], "
+ "a:[['MinKey','MaxKey',true,true]]}}}}}");
+}
} // namespace mongo