summaryrefslogtreecommitdiff
path: root/jstests/core/or6.js
blob: 2a8263e298faaf6aec3fc9241c402bd16e2aa46e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// A few rooted $or cases.

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

t.ensureIndex({a: 1, c: 1});
t.ensureIndex({b: 1, c: 1});

t.save({a: 1, c: 9});
t.save({a: 1, c: 10});
t.save({b: 2, c: 8});
t.save({b: 2, c: 7});

// This can be answered using a merge sort. See SERVER-13715.
var cursor = t.find({$or: [{a: 1}, {b: 2}]}).sort({c: 1});
for (var i = 7; i < 11; i++) {
    assert.eq(i, cursor.next()["c"]);
}
assert(!cursor.hasNext());

// SERVER-13715
assert.eq(4, t.find({$or: [{a: 1}, {b: 2}]}).sort({a: 1}).itcount());