diff options
author | Benety Goh <benety@mongodb.com> | 2014-02-20 13:20:49 -0500 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2014-02-21 17:46:58 -0500 |
commit | 90419483250ca79da13293b4cf3f234ed805bb9b (patch) | |
tree | 127c2653fb43e461117ad283760d3239276b4ec7 /src/mongo/db/query/canonical_query_test.cpp | |
parent | d073743e91afaae772385198c7c0819fb40cde20 (diff) | |
download | mongo-90419483250ca79da13293b4cf3f234ed805bb9b.tar.gz |
SERVER-12766 extended plan cache key to include geo coordinate types
Diffstat (limited to 'src/mongo/db/query/canonical_query_test.cpp')
-rw-r--r-- | src/mongo/db/query/canonical_query_test.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/mongo/db/query/canonical_query_test.cpp b/src/mongo/db/query/canonical_query_test.cpp index be7b4326be6..2faf6070fce 100644 --- a/src/mongo/db/query/canonical_query_test.cpp +++ b/src/mongo/db/query/canonical_query_test.cpp @@ -475,4 +475,29 @@ namespace { testGetPlanCacheKey("{$or: [{a: 1}]}", "{}", "{'a.$': 1}", "eqap1a.$"); } + // Cache keys for $geoWithin queries with legacy and GeoJSON coordinates should + // not be the same. + TEST(PlanCacheTest, GetPlanCacheKeyGeoWithin) { + // Legacy coordinates. + auto_ptr<CanonicalQuery> cqLegacy(canonicalize("{a: {$geoWithin: " + "{$box: [[-180, -90], [180, 90]]}}}")); + // GeoJSON coordinates. + auto_ptr<CanonicalQuery> cqNew(canonicalize("{a: {$geoWithin: " + "{$geometry: {type: 'Polygon', coordinates: " + "[[[0, 0], [0, 90], [90, 0], [0, 0]]]}}}}")); + ASSERT_NOT_EQUALS(cqLegacy->getPlanCacheKey(), cqNew->getPlanCacheKey()); + } + + // GEO_NEAR cache keys should include information on geometry and CRS in addition + // to the match type and field name. + TEST(PlanCacheTest, GetPlanCacheKeyGeoNear) { + testGetPlanCacheKey("{a: {$near: [0,0], $maxDistance:0.3 }}", "{}", "{}", + "gnanrfl"); + testGetPlanCacheKey("{a: {$nearSphere: [0,0], $maxDistance: 0.31 }}", "{}", "{}", + "gnansfl"); + testGetPlanCacheKey("{a: {$geoNear: {$geometry: {type: 'Point', coordinates: [0,0]}," + "$maxDistance:100}}}", "{}", "{}", + "gnanrsp"); + } + } |