Permalink
Browse files

fix $all with an empty arraty SERVER-143

  • Loading branch information...
1 parent 59255f4 commit e6aee429a9e77798d3e871112bcfaad11a3d7488 @erh erh committed Jul 10, 2009
Showing with 8 additions and 1 deletion.
  1. +1 −1 db/matcher.cpp
  2. +7 −0 jstests/all.js
View
@@ -319,7 +319,7 @@ namespace mongo {
if ( bm.myset->count( e ) )
matches.insert( e );
}
- if ( bm.myset->size() == matches.size() ) {
+ if ( matches.size() > 0 && bm.myset->size() == matches.size() ) {
if ( deep )
*deep = true;
return true;
View
@@ -30,6 +30,13 @@ doTest = function() {
t.save( { a: { b: [ 20, 30 ] } } );
assert.eq( 1, t.find( { 'a.b': { $all: [ 20 ] } } ).count() );
assert.eq( 1, t.find( { 'a.b': { $all: [ 20, 30 ] } } ).count() );
+
+
+ assert.eq( 5 , t.find( { a : { $all : [1] } } ).count() , "E1" );
+ assert.eq( 0 , t.find( { a : { $all : [19] } } ).count() , "E2" );
+ assert.eq( 0 , t.find( { a : { $all : [] } } ).count() , "E3" );
+
+
}
doTest();

0 comments on commit e6aee42

Please sign in to comment.