diff options
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/query/query_planner.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/query/query_planner_geo_test.cpp | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/mongo/db/query/query_planner.cpp b/src/mongo/db/query/query_planner.cpp index 8cffd85bd5c..e027e00c086 100644 --- a/src/mongo/db/query/query_planner.cpp +++ b/src/mongo/db/query/query_planner.cpp @@ -666,7 +666,7 @@ Status QueryPlanner::plan(const CanonicalQuery& query, if (QueryPlannerCommon::hasNode(query.root(), MatchExpression::GEO_NEAR, &gnNode)) { // No index for GEO_NEAR? No query. RelevantTag* tag = static_cast<RelevantTag*>(gnNode->getTag()); - if (0 == tag->first.size() && 0 == tag->notFirst.size()) { + if (!tag || (0 == tag->first.size() && 0 == tag->notFirst.size())) { LOG(5) << "Unable to find index for $geoNear query." << endl; // Don't leave tags on query tree. query.root()->resetTag(); diff --git a/src/mongo/db/query/query_planner_geo_test.cpp b/src/mongo/db/query/query_planner_geo_test.cpp index 7129f01af73..8d64689960b 100644 --- a/src/mongo/db/query/query_planner_geo_test.cpp +++ b/src/mongo/db/query/query_planner_geo_test.cpp @@ -227,6 +227,12 @@ TEST_F(QueryPlannerTest, NearNoIndex) { runInvalidQuery(fromjson("{x:1, a: {$nearSphere: [0,0], $maxDistance: 0.31 }}")); } +TEST_F(QueryPlannerTest, NearEmptyPath) { + addIndex(BSON("" + << "2dsphere")); + runInvalidQuery(fromjson("{'': {$near: {$geometry: {type: 'Point', coordinates: [0, 0]}}}}")); +} + TEST_F(QueryPlannerTest, TwoDSphereNoGeoPred) { addIndex(BSON("x" << 1 << "a" << "2dsphere")); |