Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix or neg matching reverse direction

  • Loading branch information...
commit a89d2e154ab31c2979593f40b2e38763a798a87d 1 parent bc61567
astaple authored July 20, 2010
2  db/queryutil.cpp
@@ -978,7 +978,7 @@ namespace mongo {
978 978
             }
979 979
             BSONElement kk = k.next();
980 980
             int number = (int) kk.number();
981  
-            bool forward = ( ( number >= 0 ? 1 : -1 ) * ( _direction >= 0 ? 1 : -1 ) > 0 ) >= 0;
  981
+            bool forward = ( number >= 0 ? 1 : -1 ) * ( _direction >= 0 ? 1 : -1 ) > 0;
982 982
             BSONElement e = obj.getField( kk.fieldName() );
983 983
             if ( e.eoo() ) {
984 984
                 e = staticNull.firstElement();
17  jstests/orb.js
... ...
@@ -0,0 +1,17 @@
  1
+// check neg direction index and negation
  2
+
  3
+var t = db.jstests_orb;
  4
+t.drop();
  5
+
  6
+t.save( {a:1} );
  7
+t.ensureIndex( {a:-1} );
  8
+
  9
+assert.eq.automsg( "1", "t.count( {$or: [ { a: { $gt:0,$lt:2 } }, { a: { $gt:-1,$lt:3 } } ] } )" );
  10
+
  11
+t.drop();
  12
+
  13
+t.save( {a:1,b:1} );
  14
+t.ensureIndex( {a:1,b:-1} );
  15
+
  16
+assert.eq.automsg( "1", "t.count( {$or: [ { a: { $gt:0,$lt:2 } }, { a: { $gt:-1,$lt:3 } } ] } )" );
  17
+assert.eq.automsg( "1", "t.count( {$or: [ { a:1, b: { $gt:0,$lt:2 } }, { a:1, b: { $gt:-1,$lt:3 } } ] } )" );

0 notes on commit a89d2e1

Please sign in to comment.
Something went wrong with that request. Please try again.