0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

Merge branch 'master' of github.com:mongodb/mongo

This commit is contained in:
Aaron 2010-02-17 22:24:12 -08:00
commit 9548999295
3 changed files with 34 additions and 13 deletions

View File

@ -40,7 +40,7 @@ namespace mongo {
// returns the key value for o
BSONObj getKeyFromObject(BSONObj o) {
return o.extractFields(pattern);
return o.extractFields(pattern,true);
}
};

View File

@ -1,20 +1,38 @@
t = db.sort6;
t.drop();
t.insert({_id:1})
t.insert({_id:2})
t.insert({_id:3,c:1})
t.insert({_id:4,c:2})
function get( x ){
return t.find().sort( { c : x } ).map( function(z){ return z._id; } );
}
//assert.eq( [4,3,2,1] , get( -1 ) , "A1" )
assert.eq( [1,2,3,4] , get( 1 ) , "A2" )
// part 1
t.drop();
t.insert({_id:1,c:null})
t.insert({_id:2,c:1})
t.insert({_id:3,c:2})
assert.eq( [3,2,1] , get( -1 ) , "A1" ) // SERVER-635
assert.eq( [1,2,3] , get( 1 ) , "A2" )
t.ensureIndex( { c : 1 } );
assert.eq( [4,3,2,1] , get( -1 ) , "B1" )
assert.eq( [1,2,3,4] , get( 1 ) , "B2" )
assert.eq( [3,2,1] , get( -1 ) , "B1" )
assert.eq( [1,2,3] , get( 1 ) , "B2" )
// part 2
t.drop();
t.insert({_id:1})
t.insert({_id:2,c:1})
t.insert({_id:3,c:2})
assert.eq( [3,2,1] , get( -1 ) , "C1" ) // SERVER-635
assert.eq( [1,2,3] , get( 1 ) , "C2" )
t.ensureIndex( { c : 1 } );
assert.eq( [3,2,1] , get( -1 ) , "D1" )
assert.eq( [1,2,3] , get( 1 ) , "X2" )

View File

@ -112,7 +112,9 @@ int mongo::Tool::main( int argc , char ** argv ){
}
}
if ( ! hasParam( "dbpath" ) ) {
bool useDirectClient = hasParam( "dbpath" );
if ( ! useDirectClient ) {
_host = "127.0.0.1";
if ( _params.count( "host" ) )
_host = _params["host"].as<string>();
@ -178,7 +180,8 @@ int mongo::Tool::main( int argc , char ** argv ){
if ( currentClient.get() )
currentClient->shutdown();
dbexit( EXIT_CLEAN );
if ( useDirectClient )
dbexit( EXIT_CLEAN );
return ret;
}