Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-4051

Map functions have unusual scoping rules

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • None
    • None
    • ALL

    Description

      The following code, when pasted into the shell, yields the error message "map invoke failed: JS Error: ReferenceError: qqqqqq is not defined nofile_b:1" even though the variable "qqqqqq" has the value "Clem" when the map function is run.

      example.js

      var m = function(qqqqqq) {
          return function() {
              emit("foo", qqqqqq);
          };
      };
       
      var r = function(k, v) { return {} };
       
      db.tmp.save({});
      db.tmp.mapReduce(
          m("Clem"), r, 
          { "out": "tmp" }
      );

      Attachments

        Activity

          People

            Unassigned Unassigned
            mjs Michael Stillwell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: