Details
-
Bug
-
Resolution: Done
-
Minor - P4
-
None
-
2.1.0
-
None
-
ALL
Description
When using the "scope" option with a function that has formed a closure, the map function will break this closure and throw a ReferenceError when the supplied function is invoked.
This may be done intentionally... the docs are a bit sparse with regards to the "scope" option.
See the following:
|
test.js |
> db.collection.save({})
|
|
|
> fn = function(){ var x = 1; return function(){ return x; }}()
|
function () {
|
return x;
|
}
|
|
|
> fn()
|
1
|
|
|
> db.collection.mapReduce(function(){fn()}, function(){}, {out:'inline', scope:{fn:fn}})
|
Fri Mar 23 12:52:59 uncaught exception: map reduce failed:{
|
"assertion" : "map invoke failed: JS Error: ReferenceError: x is not defined nofile_b:1",
|
"assertionCode" : 9014,
|
"errmsg" : "db assertion failure",
|
"ok" : 0
|
}
|
>
|