Permalink
Browse files

fix $ne/$nin on non-matches SERVER-198

  • Loading branch information...
1 parent 5b96c6d commit 3567de373bb7ff6afb58251e6dfb5e334f7d87d9 @erh erh committed Aug 6, 2009
Showing with 5 additions and 3 deletions.
  1. +3 −1 db/matcher.cpp
  2. +2 −2 jstests/not1.js
View
4 db/matcher.cpp
@@ -336,7 +336,9 @@ namespace mongo {
int JSMatcher::matchesNe(const char *fieldName, const BSONElement &toMatch, const BSONObj &obj, const BasicMatcher& bm, bool *deep) {
int ret = matchesDotted( fieldName, toMatch, obj, BSONObj::Equality, bm, deep );
- return -ret;
+ if ( ret <= 0 )
+ return 1;
+ return 0;
}
/* Check if a particular field matches.
View
4 jstests/not1.js
@@ -10,9 +10,9 @@ t.insert({})
function test( name ){
assert.eq( 3 , t.find().count() , name + "A" );
assert.eq( 1 , t.find( { a : 1 } ).count() , name + "B" );
- //assert.eq( 2 , t.find( { a : { $ne : 1 } } ).count() , name + "C" ); // SERVER-198
+ assert.eq( 2 , t.find( { a : { $ne : 1 } } ).count() , name + "C" ); // SERVER-198
assert.eq( 1 , t.find({a:{$in:[1]}}).count() , name + "D" );
- //assert.eq( 2 , t.find({a:{$nin:[1]}}).count() , name + "E" ); // SERVER-198
+ assert.eq( 2 , t.find({a:{$nin:[1]}}).count() , name + "E" ); // SERVER-198
}
test( "no index" );

0 comments on commit 3567de3

Please sign in to comment.