-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Unknown
-
Affects Version/s: None
-
Component/s: BSON
-
None
-
Not Needed
-
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.
- is related to
-
GODRIVER-2407 BSON Unmarshal to struct uses incorrect type alias for interface{}
-
- Closed
-