[SERVER-32201] Core Object has no hasOwnProperty Function Created: 07/Dec/17  Updated: 15/Sep/18  Resolved: 23/Aug/18

Status: Closed
Project: Core Server
Component/s: JavaScript
Affects Version/s: 3.4.10, 3.6.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Thomas Scheibe [X] Assignee: Mira Carey
Resolution: Won't Fix Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows, Linux, MacOs


Issue Links:
Backports
Operating System: ALL
Backport Requested:
v3.6, v3.4
Steps To Reproduce:

Start mongoshell
>typeof db.hasOwnProperty
object
>typeof db.<SOMECOLLECTION>.hasOwnProperty
object

Participants:

 Description   

In Mongo (server and mongo shell) , the DB/Collection Object (maybe more?) has no function "hasOwnProperty" anymore. There is a Object now.



 Comments   
Comment by Mira Carey [ 23/Aug/18 ]

While it's definitely unfortunate that this behavior changed, the existence of a workaround (Object.prototype.hasOwnProperty.call(object, 'fieldName')), as well as the long duration of the regression in the wild has led me to decline to fix this at this time.

Comment by Mark Benvenuto [ 08/Dec/17 ]

After the switch to use resolve instead of GetProperty, SpiderMonkey asks resolve for all functions, and properties including those that are part of the Object.prototype. The fix is to simply change resolve to return true all of Object's prototype properties and methods. This is consistent with the fix made for _proto_ in SERVER-30769.

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype

Comment by Kelsey Schubert [ 07/Dec/17 ]

Hi LitixThomas,

Thank you for the report. I've reproduced the issue, and we will continue to update this ticket as we investigate.

Kind regards,
Kelsey

Generated at Thu Feb 08 04:29:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.