Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 3567de373bb7ff6afb58251e6dfb5e334f7d87d9 1 parent 5b96c6d
@erh erh authored
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" );
Please sign in to comment.
Something went wrong with that request. Please try again.