[GODRIVER-2367] Un-export all result type BSON unmarshaling functions and BSON struct tags Created: 05/Apr/22  Updated: 09/Nov/23  Resolved: 09/Nov/23

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

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

Issue Links:
Depends
depends on GODRIVER-2606 Deprecate unused functionality in pre... Closed
Epic Link: Go Driver 2.0: Driver
Documentation Changes: Not Needed
Documentation Changes Summary:

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?


 Description   

Currently the mongo.UpdateResult and mongo.DeleteResult types support unmarshaling from BSON (either via an UnmarshalBSON function or struct tags). However, the BSON unmarshaling logic is sometimes inconsistent with the logic used to form those result types in the operation layer. The ability to unmarshal directly from BSON appears to be vestigial from an earlier version of the driver before the CRUD spec tests, is (mostly?) unused, and potentially confusing.

Remove the mongo.UpdateResult.UnmarshalBSON function and remove the BSON struct tags from mongo.DeleteResult in the v2.0 Go driver.

Additionally, other result types support unmarshaling from BSON via an exported UnmarshalBSON function:

  • mongo.CollectionSpecification
  • mongo.IndexSpecification
  • gridfs.File

Those UnmarshalBSON functions are actually used to unmarshal the results right now, but don't need to be on an exported type. Remove the UnmarshalBSON function from those exported result types, move them to the existing unmarshal[result type] types, and move the unmarshal type to result type conversion into the relevant functions instead of in the UnmarshalBSON function.



 Comments   
Comment by Githook User [ 09/Nov/23 ]

Author:

{'name': 'Preston Vasquez', 'email': 'prestonvasquez@icloud.com', 'username': 'prestonvasquez'}

Message: GODRIVER-2367 Un-export all result type BSON encoding logic (#1442)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/3a339ac9f657f71c4793f9dfcbdc562eb99f49cb

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