[SERVER-23626] Function.prototype isn't treated as BSON type Code Created: 09/Apr/16  Updated: 13/Aug/16  Resolved: 20/Jul/16

Status: Closed
Project: Core Server
Component/s: JavaScript
Affects Version/s: 3.2.0-rc0
Fix Version/s: 3.3.11

Type: Bug Priority: Minor - P4
Reporter: Max Hirschhorn Assignee: Waley Chen
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

db.mycoll.drop();
assert.writeOK(db.mycoll.insert({_id: 0, a: Function.prototype}));
assert.eq(1, db.mycoll.find({a: {$type: 'javascript'}}).itcount());

Sprint: Platforms 13 (04/22/16), Platforms 14 (05/13/16), Platforms 15 (06/03/16), Platforms 16 (06/24/16), Platforms 17 (07/15/16), Platforms 18 (08/05/16)
Participants:

 Description   
mongo shell version 3.0.11 (v8)

> db.mycoll.find()
{ "_id" : 0, "a" : function Empty() {} }

mongo shell version 3.1.9 (SpiderMonkey)

> db.mycoll.find()
{ "_id" : 0, "a" : function () { } }

mongo shell version 3.2.0-rc0 (SpiderMonkey)

> db.mycoll.find()
{ "_id" : 0, "a" : {  } }
> db.mycoll.find({a: {$type: 'object'}})
{ "_id" : 0, "a" : {  } }



 Comments   
Comment by Githook User [ 20/Jul/16 ]

Author:

{u'username': u'WaleyChen', u'name': u'Waley Chen', u'email': u'waleycz@gmail.com'}

Message: SERVER-23626 Function.prototype isn't treated as BSON type Code
Branch: master
https://github.com/mongodb/mongo/commit/48abdc3093889286a947f9aba16342cfbb82efaa

Comment by Mira Carey [ 11/Apr/16 ]

The broader problem (that I introduced between 3.1.9 and 3.2.0) is that we aren't properly handling prototypes of any of the interesting built in types. So, we've got the same bug for Function, Date and RegExp.

Fix is that we need to check the prototype key with JS::IdentifyStandardInstanceOrPrototype, instead of just JS::IdentifyStandardInstance.

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