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

ES5: Object.preventExtensions() broken when run on documents

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.3.2
    • Component/s: JavaScript, Shell
    • None
    • ALL
    • Hide

      db.u.drop()
      db.u.insert(

      {a: 1}

      )
      doc = db.u.findOne() //

      { "_id" : ObjectId("50f859962db7a1d82e1ec250"), "a" : 1 }

      Object.preventExtensions(doc);
      doc.o = 9
      Object.keys(doc) // [ "_id", "a", "o" ] ("o" should not exist)
      assert(null != doc.o) // fails

      Show
      db.u.drop() db.u.insert( {a: 1} ) doc = db.u.findOne() // { "_id" : ObjectId("50f859962db7a1d82e1ec250"), "a" : 1 } Object.preventExtensions(doc); doc.o = 9 Object.keys(doc) // [ "_id", "a", "o" ] ("o" should not exist) assert(null != doc.o) // fails

      Passing a document to Object.preventExtensions() does not work properly, the property in question is set on the document with the value discarded and `null` assigned.

      Expected the property in question to be discarded entirely, not set on the document at all.

      Note that passing plain (non-document) objects works correctly.

            Assignee:
            backlog-server-platform DO NOT USE - Backlog - Platform Team
            Reporter:
            aheckmann Aaron Heckmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: