summaryrefslogtreecommitdiff
path: root/jstests/core/server9547.js
blob: 5e2d6aba5668eecb3af1736caf87c5a947515bb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// SERVER-9547
// Test that sorting with .max() and .min() doesn't crash.

var t = db.server9547;
t.drop();

for (var i = 0; i < 10; i++) {
    t.save({a: i});
}

t.createIndex({a: 1});

// note: max() value is exclusive upper bound
assert.eq(4, t.find({}).max({a: 4}).hint({a: 1}).toArray().length, "no order");

// Ascending order is fine.
assert.eq(4, t.find({}).max({a: 4}).sort({a: 1}).hint({a: 1}).toArray().length, "ascending");

// Descending order is fine.
assert.eq(4, t.find({}).max({a: 4}).sort({a: -1}).hint({a: 1}).toArray().length, "descending");