2011-07-31 08:45:26 -07:00
|
|
|
// 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() );
|
2013-05-19 19:44:29 -04:00
|
|
|
assert.eq( nullElemMatch ? 1 : 0 , t.find( {'a.b':null} ).itcount() );
|
2011-07-31 08:45:26 -07:00
|
|
|
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 );
|