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

Error on non-object inputs when encoding BSON

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • bson-5.0.0
    • Affects Version/s: None
    • Component/s: BSON
    • None
    • 3
    • Not Needed
    • Not Needed

      DrPizza points out that we are presently unable to roundtrip single values through our javascript BSON library:

      • BSON.deserialize(BSON.serialize([])) yields "{}"
      • BSON.deserialize(BSON.serialize([1, 2, 3])) yields " {0: 1, 1: 2, 2: 3}

        "

      • BSON.deserialize(BSON.serialize(1)) yields "{}"
      • and so on..

      We should consider two approaches, and perhaps a marriage of the two:

      • Explicitly disallow non-object inputs
      • Provide a mechanism to roundtrip single values (perhaps wrapping the value in some reserved key like $$single$$, we do something similar in Swift)

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            matt.broadstone@mongodb.com Matt Broadstone
            Durran Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: