-
Notifications
You must be signed in to change notification settings - Fork 905
GODRIVER-3071 Correct uint Encoding BSON Documentation #1500
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
Conversation
API Change ReportNo changes found! |
bson/doc.go
Outdated
// 6. When encoding with EncodeContext.MinSize set to true, uint, uint32, and uint64 will marshal to a BSON int32 if | ||
// the value falls within the inclusive range of math.MinInt32 to math.MaxInt32. Otherwise, they will marshal to a | ||
// BSON int64. See Encoder examples for usage of EncodeContext.MinSize. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EncodeContext.MinSize
is deprecated, so we shouldn't recommend that people use it. They should use Encoder.IntMinSize
instead.
Co-authored-by: Matt Dale <[email protected]>
Co-authored-by: Matt Dale <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 👍
Co-authored-by: Matt Dale <[email protected]> (cherry picked from commit 6740ce0)
Co-authored-by: Matt Dale <[email protected]>
GODRIVER-3071
Summary
Update documentation for when the Go Driver will marshal Go integer values (int, int8, int16, int32, int64, uint, uint8, uint16, uint32, or uint64) as the minimum BSON int size (either 32 or 64 bits) that can represent the integer value.
Background & Motivation
A user submitted this community issue describing how the Go Driver does not work as described in the following documentation:
The logic for this, added in GODRIVER-1358, is contradictory. The default case for the "min int" condition in the UintCodec is false / nil, which means that an type >= 32-bits will be considered int64. This can also be effected by EncodeContext.MinSize.