Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GODRIVER-2866 Update method signatures of bson.ValueMarshaler/bson.ValueUnmarshaler to only use basic types. #1671

Merged
merged 3 commits into from
Jun 27, 2024

Conversation

qingyang-hu
Copy link
Collaborator

GODRIVER-2866

Summary

Update method signatures of bson.ValueMarshaler/bson.ValueUnmarshaler to only use basic types.

….ValueUnmarshaler` to only use basic types.
@mongodb-drivers-pr-bot mongodb-drivers-pr-bot bot added the priority-3-low Low Priority PR for Review label Jun 10, 2024
Copy link
Contributor

API Change Report

./bson

incompatible changes

(*D).UnmarshalJSON: removed
D.MarshalJSON: removed
ValueMarshaler.MarshalBSONValue: changed from func() (Type, []byte, error) to func() (byte, []byte, error)
ValueUnmarshaler.UnmarshalBSONValue: changed from func(Type, []byte) error to func(byte, []byte) error

@qingyang-hu qingyang-hu marked this pull request as ready for review June 11, 2024 14:50
bson/marshal.go Outdated
@@ -34,7 +34,7 @@ type Marshaler interface {
// create custom BSON marshaling behavior for an entire BSON document, implement
// the Marshaler interface instead.
type ValueMarshaler interface {
MarshalBSONValue() (Type, []byte, error)
MarshalBSONValue() (byte, []byte, error)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: Consider adding named returns to the interface to describe what the values are, since we're removing some type information. We may also want to update the documentation.

Suggested change
MarshalBSONValue() (byte, []byte, error)
MarshalBSONValue() (typ byte, data []byte, err error)

@@ -31,7 +31,7 @@ type Unmarshaler interface {
// document. To create custom BSON unmarshaling behavior for an entire BSON
// document, implement the Unmarshaler interface instead.
type ValueUnmarshaler interface {
UnmarshalBSONValue(Type, []byte) error
UnmarshalBSONValue(byte, []byte) error
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: Consider adding named parameters to the interface to describe what the values are, since we're removing some type information. We may also want to update the documentation.

Suggested change
UnmarshalBSONValue(byte, []byte) error
UnmarshalBSONValue(typ byte, data []byte) error

Copy link
Collaborator

@matthewdale matthewdale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 👍

@qingyang-hu qingyang-hu merged commit cef198c into mongodb:master Jun 27, 2024
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-3-low Low Priority PR for Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants