[DOCS-11791] bsonspec.org should clarify MinKey type code Created: 11/Jun/18  Updated: 01/Feb/24

Status: External Review
Project: Documentation
Component/s: bsonspec, drivers
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: David Storch Assignee: Rea Rustagi
Resolution: Unresolved Votes: 0
Labels: backlog, request
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-8196 $type value should be signed extended Closed
Participants:
Days since reply: 6 days ago

 Description   

The type code associated with a BSON element is a one-byte number which the MongoDB server's implementation interprets as a C++ signed char.

Whether or not the type code is a signed or unsigned char is usually not relevant, since all type codes except for MaxKey fall in the interval [0, 127]. However, the type code for MinKey is -1 (documented here). http://bsonspec.org/spec.html confusingly lists the MinKey type code as \xFF (the bit pattern 1111 1111) which would be 255 if interpreted as an unsigned char and -1 if interpreted as a twos complement signed char. This could lead a user to erroneously believe that {$type: 255} is a valid query, when in fact 255 is an invalid BSON type code.

http://bsonspec.org/spec.html should clarify that the type byte associated with a BSON element is a twos complement 8-bit signed number, and that the type code for MinKey is -1, not "\0xFF".

 

A/C

As a user, I understand that the type byte associated with a BSON element is a twos complement 8-bit signed char

As a user, i understand that the type code for minKey is -1



 Comments   
Comment by Rea Rustagi [ 01/Feb/24 ]

https://github.com/mongodb/bsonspec.org/pull/80

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