Permalink
Browse files

fix hint1.js and minkey for date which is now tricky as we support a …

…couple different compare semantics for V0 and V1 indexes
  • Loading branch information...
1 parent 020a5f1 commit 89581c108f6419973d154374a5f33febe04f1a32 @dwight dwight committed Jun 6, 2011
Showing with 14 additions and 4 deletions.
  1. +3 −1 db/jsobj.cpp
  2. +2 −0 db/queryutil.cpp
  3. +9 −3 jstests/hint1.js
View
@@ -1115,7 +1115,9 @@ namespace mongo {
}
case Bool: appendBool( fieldName , false); return;
case Date:
- appendDate( fieldName , numeric_limits<long long>::min() );
+ // min varies with V0 and V1 indexes, so we go one type lower.
+ appendBool(fieldName, true);
+ //appendDate( fieldName , numeric_limits<long long>::min() );
return;
case jstNULL: appendNull( fieldName ); return;
case Symbol:
View
@@ -408,6 +408,8 @@ namespace mongo {
upper = addObj( b.obj() ).firstElement();
}
else if ( lower.type() == MinKey && upper.type() != MaxKey && upper.isSimpleType() ) { // TODO: get rid of isSimpleType
+ if( upper.type() == Date )
+ lowerInclusive = false;
BSONObjBuilder b;
b.appendMinForType( upper.fieldName() , upper.type() );
lower = addObj( b.obj() ).firstElement();
View
@@ -5,6 +5,12 @@ p.drop();
p.save( { ts: new Date( 1 ), cls: "entry", verticals: "alleyinsider", live: true } );
p.ensureIndex( { ts: 1 } );
-e = p.find( { live: true, ts: { $lt: new Date( 1234119308272 ) }, cls: "entry", verticals: " alleyinsider" } ).sort( { ts: -1 } ).hint( { ts: 1 } ).explain();
-assert.eq( e.indexBounds.ts[0][0].getTime(), new Date( 1234119308272 ).getTime() , "A" );
-assert.eq( 0 , e.indexBounds.ts[0][1].getTime() , "B" );
+e = p.find( { live: true, ts: { $lt: new Date( 1234119308272 ) }, cls: "entry", verticals: "alleyinsider" } ).sort( { ts: -1 } ).hint( { ts: 1 } ).explain();
+assert.eq(e.indexBounds.ts[0][0].getTime(), new Date(1234119308272).getTime(), "A");
+
+//printjson(e);
+
+assert.eq( /*just below min date is bool true*/true, e.indexBounds.ts[0][1], "B");
+
+assert.eq(1, p.find({ live: true, ts: { $lt: new Date(1234119308272) }, cls: "entry", verticals: "alleyinsider" }).sort({ ts: -1 }).hint({ ts: 1 }).count());
+

0 comments on commit 89581c1

Please sign in to comment.