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

Error when unmarshaling a BSON document if the document has unknown fields

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: BSON
    • Labels:
      None
    • 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?

      Context

      Some users want the ability to configure a BSON decoder to return an error if the BSON document has fields that don't match fields in the decode destination struct. The Go "encoding/json" library supports a similar configuration called Decoder.DisallowUnknownFields . We should support something similar for the BSON decoder.

      Definition of done

      • Add a configuration that causes decoding to return an error if there are fields in the decoded BSON document that don't match fields in the decode destination struct. Note that this only makes sense when the destination is a struct.
      • Add the ability to configure that unmarshal behavior on a MongoDB Client using BSONOptions.

      Pitfalls

      • Adds additional configuration to the bson.Decoder type, which already has a lot of configurable behaviors.

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

              Created:
              Updated:
              Resolved: