blob: 3fba886b83a371c32b4b11f8b8b6184d557d5362 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
// Test indexed elemmatch of missing field.
t = db.jstests_arrayfind5;
t.drop();
function check(nullElemMatch) {
assert.eq(1, t.find({'a.b': 1}).itcount());
assert.eq(1, t.find({a: {$elemMatch: {b: 1}}}).itcount());
assert.eq(nullElemMatch ? 1 : 0, t.find({'a.b': null}).itcount());
assert.eq(nullElemMatch ? 1 : 0,
t.find({a: {$elemMatch: {b: null}}}).itcount()); // see SERVER-3377
}
t.save({a: [{}, {b: 1}]});
check(true);
t.ensureIndex({'a.b': 1});
check(true);
t.drop();
t.save({a: [5, {b: 1}]});
check(false);
t.ensureIndex({'a.b': 1});
check(false);
|