[SERVER-8060] MinKey/MaxKey print incorrect V8 Created: 02/Jan/13  Updated: 11/Jul/16  Resolved: 22/Jan/13

Status: Closed
Project: Core Server
Component/s: JavaScript
Affects Version/s: None
Fix Version/s: 2.4.0-rc0

Type: Bug Priority: Minor - P4
Reporter: Scott Hernandez (Inactive) Assignee: Scott Hernandez (Inactive)
Resolution: Done Votes: 0
Labels: JSON, MaxKey, MinKey
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-19171 Shell does not always use extended JS... Closed
is related to SERVER-8052 json parser should support all types ... Closed
Operating System: ALL
Participants:

 Description   

The extended json spec is here: http://www.mongodb.org/display/DOCS/Mongo+Extended+JSON

Also, this comes up with json parsing and export with mongoimport/export.

The shell will not correctly parse the document/json representation either, but does allow $MaxKey/$MinKey (along with $ref,$id,$db) through on validation incorrectly.

//V8 v2.3.2--pre
> MaxKey
{ "$MaxKey" : true } // wrong
> db.max.find()
{ "_id" : { "$MinKey" : true } }
{ "_id" : { "$MaxKey" : true } }
> db.max.find({_id:{$type:-1}})
{ "_id" : { "$MinKey" : true } }
> db.max.find({_id:{$type:0x7f}})
{ "_id" : { "$MaxKey" : true } }
> tojson(MaxKey)
{ "$maxKey" : 1 }
> db.max.insert({_id:{$MaxKey:true}})
> db.max.count()
3
 
//SM 2.2.2
> MaxKey
{ "$maxKey" : 1 }
> db.max.find()
{ "_id" : { $minKey : 1 } }
{ "_id" : { $maxKey : 1 } }
> db.max.find({_id:{$type:-1}})
{ "_id" : { $minKey : 1 } }
> db.max.find({_id:{$type:0x7f}})
{ "_id" : { $maxKey : 1 } }
> tojson(MaxKey)
{ "$maxKey" : 1 }
> db.max.insert({_id:{$MaxKey:true}})
> db.max.count()
3



 Comments   
Comment by auto [ 22/Jan/13 ]

Author:

{u'date': u'2013-01-22T20:32:34Z', u'email': u'scotthernandez@gmail.com', u'name': u'Scott Hernandez'}

Message: SERVER-8060: MinKey/MaxKey fixes for V8
Branch: master
https://github.com/mongodb/mongo/commit/8b23788e366470fff665947bb7acb93653e6a967

Comment by Ben Becker [ 18/Jan/13 ]

Just to note, Min/MaxKey are mutable in SM.

leaf:~/projects/mongo (v8_mr_security_8104) $ ../mongo-v2.0/mongo --nodb
MongoDB shell version: 2.0.7
> MaxKey
{ $maxKey : 1 }
> MaxKey = 1
1
> MaxKey
1

Comment by auto [ 17/Jan/13 ]

Author:

{u'date': u'2013-01-17T20:14:40Z', u'email': u'scotthernandez@gmail.com', u'name': u'Scott Hernandez'}

Message: Revert "SERVER-8060: make min/max key consistent with spidermonkey"

We need to fix validation via save and make the Min/MaxKey immutable like SM

This reverts commit bbf3b7dffa0c27db45eb4398c4e88eb63435fe51.
Branch: master
https://github.com/mongodb/mongo/commit/f744b0e7c560dc8ce984dfc3b8589132af7f3868

Comment by Ben Becker [ 16/Jan/13 ]

Updated the print output to be consistent with spidermonkey:

leaf:~/projects/mongo (master) $ ./mongo --nodb
MongoDB shell version: 2.3.3-pre-
> MinKey
{ "$minKey" : 1 }
> MaxKey
{ "$maxKey" : 1 }
> 

Comment by auto [ 16/Jan/13 ]

Author:

{u'date': u'2013-01-16T22:01:01Z', u'email': u'ben.becker@10gen.com', u'name': u'Ben Becker'}

Message: SERVER-8060: make min/max key consistent with spidermonkey
Branch: master
https://github.com/mongodb/mongo/commit/bbf3b7dffa0c27db45eb4398c4e88eb63435fe51

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