0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00

findOne fix

This commit is contained in:
Aaron 2009-02-25 15:59:01 -05:00
parent bcb1b24bd6
commit 181a200309
2 changed files with 15 additions and 1 deletions

View File

@ -92,7 +92,6 @@ namespace mongo {
QueryPlanSet s( ns, query, emptyObj );
FindOne original( requireIndex );
shared_ptr< FindOne > res = s.runOp( original );
massert( res->exceptionMessage(), res->complete() );
if ( res->one().isEmpty() )
return false;
result = res->one();

View File

@ -479,6 +479,7 @@ namespace QueryOptimizerTests {
~Base() {
if ( !nsd() )
return;
clearQueryCache( ns() );
string s( ns() );
dropNS( s );
}
@ -816,6 +817,19 @@ namespace QueryOptimizerTests {
};
};
class FindOne : public Base {
public:
void run() {
BSONObj one = BSON( "a" << 1 );
theDataFileMgr.insert( ns(), one );
BSONObj result;
ASSERT( Helpers::findOne( ns(), BSON( "a" << 1 ), result ) );
ASSERT( !Helpers::findOne( ns(), BSON( "a" << 1 ), result, true ) );
Helpers::ensureIndex( ns(), BSON( "a" << 1 ), "a_1" );
ASSERT( Helpers::findOne( ns(), BSON( "a" << 1 ), result, true ) );
}
};
} // namespace QueryPlanSetTests
class All : public UnitTest::Suite {
@ -866,6 +880,7 @@ namespace QueryOptimizerTests {
add< QueryPlanSetTests::AllException >();
add< QueryPlanSetTests::SaveGoodIndex >();
add< QueryPlanSetTests::TryAllPlansOnErr >();
add< QueryPlanSetTests::FindOne >();
}
};