[SERVER-33901] Strange behavior with MinKey comparisons in the shell Created: 15/Mar/18  Updated: 27/Oct/23  Resolved: 15/Mar/18

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

Type: Bug Priority: Major - P3
Reporter: Ian Boros Assignee: Backlog - Query Team (Inactive)
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query
Operating System: ALL
Participants:

 Description   

charlie.swanson discovered the following weird (and seemingly incorrect) behavior with MinKey in the shell:

> db.foo.insert({x: MinKey})
WriteResult({ "nInserted" : 1 })
> db.foo.find()
{ "_id" : ObjectId("5aa9764861da7407ff9101f4"), "x" : { "$minKey" : 1 } }
> db.foo.findOne()
{ "_id" : ObjectId("5aa9764861da7407ff9101f4"), "x" : { "$minKey" : 1 } }
> db.foo.findOne().x
{ "$minKey" : 1 }
> db.foo.findOne().x == MinKey
true
> db.foo.findOne({}, {_id: 0}).x == MinKey
true
> db.foo.findOne({}, {_id: 0})
{ "x" : { "$minKey" : 1 } }
> db.foo.findOne({}, {_id: 0}) == {x: MinKey}
false
> db.foo.findOne({}, {_id: 0}) == { "x" : { "$minKey" : 1 } }
false

It seems like there's been weird behavior with this before, in SERVER-8246, but that was such a long time ago it seemed reasonable to open a new ticket.


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