[SERVER-8057] Cannot override prototype members of DB type in javascript shell. Created: 02/Jan/13  Updated: 05/May/17  Resolved: 05/May/17

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

Type: Bug Priority: Major - P3
Reporter: Andy Schwerin Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Done Votes: 0
Labels: triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

In the shell, when connected to a databse, the following actual behavior occurs:

> DB.prototype.x = 1
1
> db.x
1
> db.x = 2
2
> db.x
1

The expected behavior differs in that the last db.x examination should return 2, though DB.prototype.x should continue to return 1. Instances of DB aren't properly respecting prototype overriding behavior.

For comparison,

> function Y() {}
> Y.prototype.y = 1
1
> y = new Y();
{ "y" : 1 }
> y.y
1
> y.y = 2
2
> y.y
2
> Y.prototype.y
1
> 

Note that assigning to y.y hides the prototypical value Y.prototype.y, but does not replace it.



 Comments   
Comment by Justin Cohler [ 05/May/17 ]

Could not reproduce on MongoDB 3.4.1. Closing as Gone Away.

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