Permalink
Browse files

SERVER-3375 test

  • Loading branch information...
1 parent ec1ea9c commit fb01e867bff48cc6591eb4c227fca4b624a64ecc @astaple astaple committed Jul 31, 2011
Showing with 23 additions and 0 deletions.
  1. +23 −0 jstests/arrayfind5.js
View
@@ -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( 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 );

0 comments on commit fb01e86

Please sign in to comment.