fix interpretation of non numberic index direction spec

This commit is contained in:
Aaron
2009-04-20 18:17:52 -04:00
parent d4ede794a9
commit 7d85516931
2 changed files with 14 additions and 1 deletions

View File

@@ -24,6 +24,12 @@
namespace mongo {
int elementDirection( const BSONElement &e ) {
if ( e.isNumber() )
return e.number();
return 1;
}
QueryPlan::QueryPlan( const FieldBoundSet &fbs, const BSONObj &order, const IndexDetails *index ) :
fbs_( fbs ),
order_( order ),
@@ -64,7 +70,7 @@ namespace mongo {
if ( !fbs.bound( ke.fieldName() ).equality() )
goto doneCheckOrder;
}
int d = oe.number() == ke.number() ? 1 : -1;
int d = elementDirection( oe ) == elementDirection( ke ) ? 1 : -1;
if ( direction_ == 0 )
direction_ = d;
else if ( direction_ != d )