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

js add property do not work at emit()

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 2.1.0
    • JavaScript, MapReduce
    • None
    • Affected versions r2.1.0-1580-g0c1a6bd (v8), v8 engine: Version 3.9.23
      Not affected versions 2.0.3-1 (spider monkey)
    • 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

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: