Files
mongo/jstests/core/query/array/arrayfind5.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
597 B
JavaScript
Raw Normal View History

2011-07-31 08:45:26 -07:00
// Test indexed elemmatch of missing field.
let 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
2011-07-31 08:45:26 -07:00
}
t.save({a: [{}, {b: 1}]});
check(true);
t.createIndex({'a.b': 1});
check(true);
2011-07-31 08:45:26 -07:00
t.drop();
t.save({a: [5, {b: 1}]});
check(false);
t.createIndex({'a.b': 1});
check(false);