Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2819

Make BSON decode to bson.D if there is no type information

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.0.0
    • Affects Version/s: None
    • Component/s: BSON
    • None
    • 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?

      Currently, when decoding a BSON nested document into a Go field with no type information (e.g. empty interface), the Go Driver BSON library will try to determine the correct type to decode into based on other types defined in the decode target (i.e. the "ancestor" type). However, that behavior has resulted in many users complaining about unexpected decode results or unexpected decode errors. Instead, if there is no type information, we should always decode into a bson.D, and provide a configuration to always decode into bson.M instead.

      Definition of done:

      • Update the BSON decoding logic to always decode into a bson.D if there is no type information, including a top-level value (e.g. you pass in an empty interface value to Decode).
      • Update the documentation
      • Remove all BSON decoding "ancestor" logic.
      • Test that setting DefaultDocumentM always decodes into a bson.M if there is no type information, including a top-level value (e.g. you pass in an empty interface value to Decode).
      • Remove Decoder.DefaultDocumentD because that is now the default behavior.

            Assignee:
            qingyang.hu@mongodb.com Qingyang Hu
            Reporter:
            matt.dale@mongodb.com Matt Dale
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: