Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-11791

bsonspec.org should clarify MinKey type code

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • None
    • bsonspec, drivers

    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

      Attachments

        Activity

          People

            rea.rustagi@mongodb.com Rea Rustagi
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              6 days ago