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

js add property do not work at emit()

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.1.0
    • 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)
    • ALL

      /**
       * 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();
      
      

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

              Created:
              Updated:
              Resolved: