[GODRIVER-2819] Make BSON decode to bson.D if there is no type information Created: 21/Apr/23  Updated: 08/Jan/24

Status: Backlog
Project: Go Driver
Component/s: BSON
Affects Version/s: None
Fix Version/s: 2.0.0

Type: Improvement Priority: Unknown
Reporter: Matt Dale Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Go Driver 2.0 BSON
Quarter: FY24Q3

 Description   

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.

Generated at Thu Feb 08 08:39:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.