Files
mongo/jstests/core/arrayfind5.js
Randolph Tan 5595b94560 SERVER-12127 migrate js tests to jscore suite when not related to writes
Moved test jstest/[a-i].js -> jstests/core/ and made changes to comply with write command api
2014-02-28 16:26:33 -05: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 );