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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.3.2
    • Fix Version/s: None
    • Component/s: JavaScript, Shell
    • Labels:
      None
    • Operating System:
      ALL
    • Steps To Reproduce:
      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

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: