diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-08-06 15:55:16 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-08-06 15:55:16 -0400 |
commit | 3567de373bb7ff6afb58251e6dfb5e334f7d87d9 (patch) | |
tree | 2f9359b43f0ae91bf244f28fa7d1ddbeabf703ad | |
parent | 5b96c6de6a124835e2036e12bffc3fc778bc2991 (diff) | |
download | mongo-3567de373bb7ff6afb58251e6dfb5e334f7d87d9.tar.gz |
fix $ne/$nin on non-matches SERVER-198
-rw-r--r-- | db/matcher.cpp | 4 | ||||
-rw-r--r-- | jstests/not1.js | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/db/matcher.cpp b/db/matcher.cpp index 27faa45432d..9bde6b7a655 100644 --- a/db/matcher.cpp +++ b/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. diff --git a/jstests/not1.js b/jstests/not1.js index 42aa3fb2e66..f99a8490170 100644 --- a/jstests/not1.js +++ b/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" ); |