Files
mongo/jstests/arrayfind5.js
Eliot Horowitz 705872c7e3 SERVER-6400: This switches from MatcherOld to Matcher2
This commit also has all semantic changes encompassed in this switch
2013-05-19 19:44:29 -04:00

24 lines
601 B
JavaScript

// 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 );