From 50623596fb62da49a2b1495d5e0cd852faf91f9f Mon Sep 17 00:00:00 2001 From: David Storch Date: Thu, 8 Jun 2017 17:47:22 -0400 Subject: SERVER-19402 Change find command semantics for sorting on an array field. This eliminates the behavior in which the lowest-valued in-bounds index key was chosen as the sort key. After this change, we instead choose the lowest key overall, which may or may not be in-bounds. This change prevents the sort order from depending on either the query predicate or the implementation details of the query planner. Note that it is no longer correct for a multikey index to provide a sort over an array field. However, a non-array field of a multikey index can provide a sort when that index has path-level multikeyness metadata. --- src/mongo/db/query/query_planner_geo_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/mongo/db/query/query_planner_geo_test.cpp') diff --git a/src/mongo/db/query/query_planner_geo_test.cpp b/src/mongo/db/query/query_planner_geo_test.cpp index 96b71acdb3d..a4efc42195b 100644 --- a/src/mongo/db/query/query_planner_geo_test.cpp +++ b/src/mongo/db/query/query_planner_geo_test.cpp @@ -708,7 +708,8 @@ TEST_F(QueryPlannerTest, CompoundGeoNoGeoPredicateMultikey) { "{sort: {pattern: {creationDate: 1}, limit: 0, node: {sortKeyGen: " "{node: {cscan: {dir: 1}}}}}}"); assertSolutionExists( - "{fetch: {node: {ixscan: {pattern: {creationDate: 1, 'foo.bar': '2dsphere'}}}}}"); + "{sort: {pattern: {creationDate: 1}, limit: 0, node: {sortKeyGen: {node: {fetch: {node: " + "{ixscan: {pattern: {creationDate: 1, 'foo.bar': '2dsphere'}}}}}}}}}"); } // Test that a 2dsphere index can satisfy a whole index scan solution if the query has a GEO -- cgit v1.2.1