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

ES5: enumerable properties on document are not saved

    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

      u = {}
      u._id = ObjectId()
      db.u.drop()
      db.u.insert(u)
      doc = db.u.findOne({ _id: u._id }) // { "_id" : ObjectId("50f847b777c54f68d526c7a0") }
      Object.defineProperty(doc, 'works', { value: true, enumerable: true }) // { "_id" : ObjectId("50f847b777c54f68d526c7a0"), "works" : true }
      db.u.remove()
      db.u.insert(doc)
      db.u.findOne({ _id: doc._id }) // { "_id" : ObjectId("50f847b777c54f68d526c7a0") }
      print(doc.works) // undefined <== expected `true`

      Note that enumerable properties added to an object not returned from a query ARE saved (correct behavior).

      db.u.drop()
      u = {}
      u._id = ObjectId()
      Object.defineProperty(u, 'works', { value: true, enumerable: true })
      db.u.insert(u)
      doc = db.u.findOne({ _id: u._id })
      print(doc.works) // `true`

      Show
      u = {} u._id = ObjectId() db.u.drop() db.u.insert(u) doc = db.u.findOne({ _id: u._id }) // { "_id" : ObjectId("50f847b777c54f68d526c7a0") } Object.defineProperty(doc, 'works', { value: true, enumerable: true }) // { "_id" : ObjectId("50f847b777c54f68d526c7a0"), "works" : true } db.u.remove() db.u.insert(doc) db.u.findOne({ _id: doc._id }) // { "_id" : ObjectId("50f847b777c54f68d526c7a0") } print(doc.works) // undefined <== expected `true` Note that enumerable properties added to an object not returned from a query ARE saved (correct behavior). db.u.drop() u = {} u._id = ObjectId() Object.defineProperty(u, 'works', { value: true, enumerable: true }) db.u.insert(u) doc = db.u.findOne({ _id: u._id }) print(doc.works) // `true`

      Description

      Enumerable properties added to a document returned from a query are not saved.

      Note that enumerable properties added to an object not returned from a query ARE saved (correct behavior).

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: