0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-29 16:47:28 +01:00

empty field spec same as missing field spec for queries

This commit is contained in:
Aaron 2009-04-08 14:01:48 -04:00
parent b671ee788b
commit 495eaa8093
2 changed files with 17 additions and 0 deletions

View File

@ -162,6 +162,8 @@ namespace mongo {
if ( d.moreJSObjs() ) {
fields = auto_ptr< set<string> >(new set<string>());
d.nextJsObj().getFieldNames(*fields);
if ( fields->size() == 0 )
fields.reset();
}
queryOptions = d.msg().data->dataAsInt();
}

View File

@ -349,6 +349,20 @@ namespace QueryTests {
ASSERT( !error() );
}
};
class EmptyFieldSpec : public ClientBase {
public:
~EmptyFieldSpec() {
client().dropCollection( "querytests.EmptyFieldSpec" );
}
void run() {
const char *ns = "querytests.EmptyFieldSpec";
client().insert( ns, BSON( "a" << 1 ) );
ASSERT( !client().findOne( ns, "" ).isEmpty() );
BSONObj empty;
ASSERT( !client().findOne( ns, "", &empty ).isEmpty() );
}
};
class All : public UnitTest::Suite {
public:
@ -368,6 +382,7 @@ namespace QueryTests {
add< OplogReplayMode >();
add< ArrayId >();
add< UnderscoreNs >();
add< EmptyFieldSpec >();
}
};