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

ES5: enumerable properties on document are not saved

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.3.2
    • Component/s: JavaScript, Shell
    • Labels:
      None
    • ALL
    • 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 `

      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).

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

              Created:
              Updated:
              Resolved: