mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
make return parsing smarter SERVER-864
This commit is contained in:
parent
16718fe785
commit
44237031b1
10
jstests/where3.js
Normal file
10
jstests/where3.js
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
t = db.where3;
|
||||
t.drop()
|
||||
|
||||
t.save( { returned_date : 5 } );
|
||||
t.save( { returned_date : 6 } );
|
||||
|
||||
assert.eq( 1 , t.find( function(){ return this.returned_date == 5; } ).count() , "A" );
|
||||
assert.eq( 1 , t.find( { $where : "return this.returned_date == 5;" } ).count() , "B" );
|
||||
assert.eq( 1 , t.find( { $where : "this.returned_date == 5;" } ).count() , "C" );
|
@ -382,8 +382,14 @@ namespace mongo {
|
||||
}
|
||||
|
||||
bool isSimpleStatement( const string& code ){
|
||||
if ( code.find( "return" ) != string::npos )
|
||||
return false;
|
||||
{
|
||||
size_t x = code.find( "return" );
|
||||
if ( x != string::npos ){
|
||||
if ( ( x == 0 || ! isalpha( code[x-1] ) ) &&
|
||||
! isalpha( code[x+6] ) )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( code.find( ";" ) != string::npos &&
|
||||
code.find( ";" ) != code.rfind( ";" ) )
|
||||
|
Loading…
Reference in New Issue
Block a user