mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
$where fix
This commit is contained in:
parent
bf904dc9ec
commit
4a01d610ad
@ -1,5 +1,4 @@
|
||||
|
||||
db = connect("test");
|
||||
t = db.getCollection( "where1" );
|
||||
t.drop();
|
||||
|
||||
@ -7,4 +6,8 @@ t.save( { a : 1 } );
|
||||
t.save( { a : 2 } );
|
||||
t.save( { a : 3 } );
|
||||
|
||||
assert.eq( 1 , t.find( function(){ return this.a == 2; } ).length() );
|
||||
assert.eq( 1 , t.find( function(){ return this.a == 2; } ).length() , "A" );
|
||||
|
||||
assert.eq( 1 , t.find( { $where : "this.a == 2" } ).toArray().length , "B" );
|
||||
|
||||
assert.eq( 1 , t.find( "this.a == 2" ).toArray().length , "C" );
|
||||
|
@ -167,7 +167,10 @@ Local<v8::Object> mongoToV8( BSONObj & m , bool array ){
|
||||
void v8ToMongoElement( BSONObjBuilder & b , v8::Handle<v8::String> name , const string sname , v8::Handle<v8::Value> value ){
|
||||
|
||||
if ( value->IsString() ){
|
||||
b.append( sname.c_str() , toSTLString( value ).c_str() );
|
||||
if ( sname == "$where" )
|
||||
b.appendCode( sname.c_str() , toSTLString( value ).c_str() );
|
||||
else
|
||||
b.append( sname.c_str() , toSTLString( value ).c_str() );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ DBCollection.prototype._massageObject = function( q ){
|
||||
if ( q.length == 24 )
|
||||
return { _id : q };
|
||||
|
||||
throw "don't know how to handle string [" + q + "]";
|
||||
return { $where : q };
|
||||
}
|
||||
|
||||
throw "don't know how to massage : " + type;
|
||||
|
Loading…
Reference in New Issue
Block a user