diff options
Diffstat (limited to 'jstests/arrayfind5.js')
-rw-r--r-- | jstests/arrayfind5.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/jstests/arrayfind5.js b/jstests/arrayfind5.js new file mode 100644 index 00000000000..9ff6e2b8a5f --- /dev/null +++ b/jstests/arrayfind5.js @@ -0,0 +1,23 @@ +// 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 ); |