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

js add property do not work at emit()

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 2.1.0
    • Fix Version/s: None
    • Component/s: JavaScript, MapReduce
    • Labels:
      None
    • Environment:
      Affected versions r2.1.0-1580-g0c1a6bd (v8), v8 engine: Version 3.9.23
      Not affected versions 2.0.3-1 (spider monkey)
    • Operating System:
      ALL

      Description

      /**
       * js add property do not work at emit()
       *
       * @link https://jira.mongodb.org/browse/
       *
       * Affected versions:		r2.1.0-1580-g0c1a6bd (v8)
       * 					v8 engine: Version 3.9.23
       *
       * Not affected versions:	2.0.3-1 (spider monkey)
       */
       
      var testCollName = 'such-collection-can-t-exist';
      var testColl = db.getCollection(testCollName);
      testColl.insert({key: 1, foo: {bar: 1}});
      testColl.insert({key: 1, foo: {bar: 1}});
      testColl.insert({key: 1, foo: {bar: 1}});
       
      res = db.runCommand({
      	mapreduce: testCollName,
      	map: function() {
      		this.foo.additional = 1;
      		assert(this.foo.additional, "additional not exist");
      		emit(this.key, {foo: this.foo});
      	},
      	reduce: function(k, vals) {
      		return 0;
      	},
      	out: {inline: 1}, // the same with "replace" and others
      });
      printjson(res);
       
      testColl.drop();
       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              antoine Antoine Girbal
              Reporter:
              azat Azat Khuzhin
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: