[SERVER-8246] Min/MaxKey on V8 are not comparable Created: 18/Jan/13  Updated: 27/Oct/15  Resolved: 22/Oct/15

Status: Closed
Project: Core Server
Component/s: JavaScript
Affects Version/s: None
Fix Version/s: 3.2.0-rc1

Type: Bug Priority: Minor - P4
Reporter: Scott Hernandez (Inactive) Assignee: Jonathan Reams
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-2667 Cannot compare different instances of... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Platform A (10/09/15), Build B (10/30/15)
Participants:

 Description   

Cannot be singled out, or tested:

//can't use typeof
>typeof MinKey
object
 
//not === comparable (should make singleton?)
> db.max.findOne()._id
{ "$maxKey" : 1 }
> db.max.findOne()._id === MaxKey
// no instanceof support...
> "a" instanceof MinKey
Fri Jan 18 18:07:21.863 javascript execution failed (shell):1 TypeError: Expecting a function in instanceof check, but got a
"a" instanceof MinKey



 Comments   
Comment by Githook User [ 21/Oct/15 ]

Author:

{u'username': u'jbreams', u'name': u'Jonathan Reams', u'email': u'jbreams@mongodb.com'}

Message: SERVER-8246 Exclude type6.js from parallel tests
Branch: master
https://github.com/mongodb/mongo/commit/e31b1742ae1bc37b05401a5214e0e1f55e87c9aa

Comment by Githook User [ 20/Oct/15 ]

Author:

{u'username': u'jbreams', u'name': u'Jonathan Reams', u'email': u'jbreams@mongodb.com'}

Message: SERVER-8246 Add instanceof support for MinKey/MaxKey
Branch: master
https://github.com/mongodb/mongo/commit/acad0bb412888fbaadabe602a0f2602df430539b

Comment by Scott Hernandez (Inactive) [ 08/Oct/15 ]

Still has issues, but workable now:

// Singleton support works for round-tripping
> db.max.save({_id: MaxKey})
> db.max.findOne()._id === MaxKey
true
> db.max.findOne()._id === MinKey
false
 
// But these still don't work
> typeof MaxKey
function
 
> "a" instanceof MinKey
2015-10-08T15:30:49.663-0400 E QUERY    [thread1] TypeError: invalid 'instanceof' operand MinKey :
@(shell):1:1
 
> "a" instanceof String
false

Comment by Andrew Morrow (Inactive) [ 08/Oct/15 ]

scotthernandez - Is this still an issue with the new SpiderMonkey integration?

Comment by Ben Becker [ 07/Mar/13 ]

Just to note, the behavior is the same in SM. ECMAScript 5 defines object equality in section 11.9.3.

If MaxKey and MinKey were string types, we could check for equality, but then we lose track of the fact that this is an instance of a BSON type. Plus MaxKey would be less than or equal to MinKey.

See discussion in SERVER-2667 for more details.

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