[GODRIVER-2725] Allow setting "bson.Encoder" and "bson.Decoder" configurations via "ClientOptions" Created: 24/Dec/22  Updated: 28/Oct/23  Resolved: 21/Jun/23

Status: Closed
Project: Go Driver
Component/s: Options & Configuration
Affects Version/s: None
Fix Version/s: 1.12.0

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

Issue Links:
Depends
depends on GODRIVER-2716 Deprecate all "bsoncodec.*Codec" types Closed
is depended on by GODRIVER-2743 Expose an API to create a cursor from... Closed
Epic Link: Go Driver 2.0 Prep
Quarter: FY24Q1
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   

GODRIVER-2716 adds a new API for configuring bson.Encoder and bson.Decoder that significantly simplifies applying many configurations compared to overriding the default Registry. However, users need a way to apply those configurations in mongo.Connect via ClientOptions.

An example options struct:

type BSONOptions struct {
	Registry                        *bsoncodec.Registry
	AllowUnexported                 bool
	UseJSONStructTags               bool
	EncodeIntMinSize                bool
	EncodeMapKeysWithStringer       bool
	EncodeNilByteSliceAsEmpty       bool
	EncodeNilMapAsEmpty             bool
	EncodeNilSliceAsEmpty           bool
	EncodeOmitDefaultStruct         bool
	EncodeOverwriteInlineDuplicates bool
	DecodeDefaultDocumentM          bool
	DecodeBinaryAsSlice             bool
	DecodeObjectIDAsHexString       bool
	DecodeZerosMap                  bool
	DecodeZerosStruct               bool
}

Definition of done:

  • Users have a way to set all bson.Encoder and bson.Decoder configuration options in a ClientOptions passed to mongo.Connect (including setting a Registry).
  • Deprecate ClientOptions.Registry and ClientOptions.SetRegistry.


 Comments   
Comment by Githook User [ 21/Jun/23 ]

Author:

{'name': 'Matt Dale', 'email': '9760375+matthewdale@users.noreply.github.com', 'username': 'matthewdale'}

Message: GODRIVER-2725 Allow setting Encoder and Decoder options on a Client. (#1282)

Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/41ebbc3ff73d64383d566cb9be77048c52c156f5

Comment by Matt Dale [ 13/Jun/23 ]

PR: https://github.com/mongodb/mongo-go-driver/pull/1282

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