Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-6764

useBigInt64 deserializes negative numbers incorrectly

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Critical - P2 Critical - P2
    • bson-6.10.3
    • Affects Version/s: 6.13.0
    • Component/s: BSON
    • 3
    • 3
    • Needed
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Parsing negative numbers using `useBigInt64` appears to parse the number as an unsigned int64, instead of a signed int64.

       

      > bson = require('mongodb').BSON // OR: bson = require('bson')
      > bson.deserialize(bson.serialize({a: -1n}), { useBigInt64: false })
      { a: -1 }
      > bson.deserialize(bson.serialize({a: -1}), { useBigInt64: true })
      { a: -1 }
      > bson.deserialize(bson.serialize({a: -1n}), { useBigInt64: true })
      { a: 18446744073709551615n }
      
      

      Tested with mongodb 6.13.0 / bson 6.10.2.

       

            Assignee:
            warren.james@mongodb.com Warren James
            Reporter:
            ralf@journeyapps.com Ralf Kistner
            Bailey Pearson, Durran Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: