diff options
author | David Storch <david.storch@10gen.com> | 2017-11-08 10:23:21 -0500 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2017-11-10 10:12:52 -0500 |
commit | 69ab9781d7a646a6029e5c46d340685e80e404fa (patch) | |
tree | e766e96057dbcc3f191dc28f1f8ff228d851aba6 /jstests/core | |
parent | bf53cbe298bc6724b1f2b5bf16afbd9e3876c623 (diff) | |
download | mongo-69ab9781d7a646a6029e5c46d340685e80e404fa.tar.gz |
SERVER-31858 Fix explodeForSort() path to handle multikeyness correctly.
Diffstat (limited to 'jstests/core')
-rw-r--r-- | jstests/core/sort_array.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/jstests/core/sort_array.js b/jstests/core/sort_array.js index c3028039d53..d432bae538c 100644 --- a/jstests/core/sort_array.js +++ b/jstests/core/sort_array.js @@ -161,4 +161,18 @@ testAggAndFindSort( {filter: {}, sort: {"d.e.g": 1}, project: {_id: 1}, expected: [{_id: 1}, {_id: 0}]}); + + // Test a sort over the trailing field of a compound index, where the two fields of the index + // share a path prefix. This is designed as a regression test for SERVER-31858. + coll.drop(); + assert.writeOK(coll.insert({_id: 2, a: [{b: 1, c: 2}, {b: 2, c: 3}]})); + assert.writeOK(coll.insert({_id: 0, a: [{b: 2, c: 0}, {b: 1, c: 4}]})); + assert.writeOK(coll.insert({_id: 1, a: [{b: 1, c: 5}, {b: 2, c: 1}]})); + assert.commandWorked(coll.createIndex({"a.b": 1, "a.c": 1})); + testAggAndFindSort({ + filter: {"a.b": 1}, + project: {_id: 1}, + sort: {"a.c": 1}, + expected: [{_id: 0}, {_id: 1}, {_id: 2}] + }); }()); |