Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix or neg matching reverse direction

  • Loading branch information...
commit a89d2e154ab31c2979593f40b2e38763a798a87d 1 parent bc61567
@astaple astaple authored
Showing with 18 additions and 1 deletion.
  1. +1 −1  db/queryutil.cpp
  2. +17 −0 jstests/orb.js
View
2  db/queryutil.cpp
@@ -978,7 +978,7 @@ namespace mongo {
}
BSONElement kk = k.next();
int number = (int) kk.number();
- bool forward = ( ( number >= 0 ? 1 : -1 ) * ( _direction >= 0 ? 1 : -1 ) > 0 ) >= 0;
+ bool forward = ( number >= 0 ? 1 : -1 ) * ( _direction >= 0 ? 1 : -1 ) > 0;
BSONElement e = obj.getField( kk.fieldName() );
if ( e.eoo() ) {
e = staticNull.firstElement();
View
17 jstests/orb.js
@@ -0,0 +1,17 @@
+// check neg direction index and negation
+
+var t = db.jstests_orb;
+t.drop();
+
+t.save( {a:1} );
+t.ensureIndex( {a:-1} );
+
+assert.eq.automsg( "1", "t.count( {$or: [ { a: { $gt:0,$lt:2 } }, { a: { $gt:-1,$lt:3 } } ] } )" );
+
+t.drop();
+
+t.save( {a:1,b:1} );
+t.ensureIndex( {a:1,b:-1} );
+
+assert.eq.automsg( "1", "t.count( {$or: [ { a: { $gt:0,$lt:2 } }, { a: { $gt:-1,$lt:3 } } ] } )" );
+assert.eq.automsg( "1", "t.count( {$or: [ { a:1, b: { $gt:0,$lt:2 } }, { a:1, b: { $gt:-1,$lt:3 } } ] } )" );
Please sign in to comment.
Something went wrong with that request. Please try again.