[SERVER-8214] ES5: enumerable properties on document are not saved Created: 17/Jan/13  Updated: 28/Apr/17  Resolved: 28/Apr/17

Status: Closed
Project: Core Server
Component/s: JavaScript, Shell
Affects Version/s: 2.3.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Aaron Heckmann Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to DOCS-1135 Document limitation described in SERV... Closed
Operating System: ALL
Steps To Reproduce:

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`

Participants:

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



 Comments   
Comment by Andrew Morrow (Inactive) [ 28/Apr/17 ]

This was fixed either during the move from MozJS to V8, or in the subsequent move from V8 back to MozJS. In either event, the currently behavior in the shell does not reproduce the issue.

Comment by Aaron Heckmann [ 17/Jan/13 ]

Same thing when using Object.defineProperties(obj, properties) instead of Object.definePropery.

Generated at Thu Feb 08 03:16:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.