Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make return parsing smarter SERVER-864

  • Loading branch information...
commit 44237031b1c0edec4ffc931aad1b8914de53ad5e 1 parent 16718fe
@erh erh authored
Showing with 18 additions and 2 deletions.
  1. +10 −0 jstests/where3.js
  2. +8 −2 scripting/engine_spidermonkey.cpp
View
10 jstests/where3.js
@@ -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" );
View
10 scripting/engine_spidermonkey.cpp
@@ -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( ";" ) )
Please sign in to comment.
Something went wrong with that request. Please try again.