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

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

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: BSON
    • Fully Compatible

      This is in reference to the comment here.

      The struct decoder should have the ability to report non-existent field. Go's json decoder has support for this documented here. I've played around this a bit, and the quickest way to implement this would be potentially exposing a similar function in the RegistryBuilder`. All decoders have a reference to the registry through DocodeContext.

      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:
            steelphase Eric Bajumpaa
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: