Skip to content

Commit 7e86795

Browse files
committed
bugfix: decimal uses a test variable
The patch replaces usage of a test variable DecimalPrecision by a package-level variable decimalPrecision in the decimal package code.
1 parent 7d4b3cc commit 7e86795

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
1414

1515
### Fixed
1616

17+
- Decimal package uses a test variable DecimalPrecision instead of a
18+
package-level variable decimalPrecision (#233)
19+
1720
## [1.9.0] - 2022-11-02
1821

1922
The release adds support for the latest version of the
@@ -40,7 +43,7 @@ switching.
4043
- A connection is still opened after ConnectionPool.Close() (#208)
4144
- Future.GetTyped() after Future.Get() does not decode response
4245
correctly (#213)
43-
- Decimal package use a test function GetNumberLength instead of a
46+
- Decimal package uses a test function GetNumberLength instead of a
4447
package-level function getNumberLength (#219)
4548
- Datetime location after encode + decode is unequal (#217)
4649
- Wrong interval arithmetic with timezones (#221)

decimal/decimal.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ func NewDecimalFromString(src string) (result *Decimal, err error) {
5858
// MarshalMsgpack serializes the Decimal into a MessagePack representation.
5959
func (decNum *Decimal) MarshalMsgpack() ([]byte, error) {
6060
one := decimal.NewFromInt(1)
61-
maxSupportedDecimal := decimal.New(1, DecimalPrecision).Sub(one) // 10^DecimalPrecision - 1
62-
minSupportedDecimal := maxSupportedDecimal.Neg().Sub(one) // -10^DecimalPrecision - 1
61+
maxSupportedDecimal := decimal.New(1, decimalPrecision).Sub(one) // 10^decimalPrecision - 1
62+
minSupportedDecimal := maxSupportedDecimal.Neg().Sub(one) // -10^decimalPrecision - 1
6363
if decNum.GreaterThan(maxSupportedDecimal) {
64-
return nil, fmt.Errorf("msgpack: decimal number is bigger than maximum supported number (10^%d - 1)", DecimalPrecision)
64+
return nil, fmt.Errorf("msgpack: decimal number is bigger than maximum supported number (10^%d - 1)", decimalPrecision)
6565
}
6666
if decNum.LessThan(minSupportedDecimal) {
67-
return nil, fmt.Errorf("msgpack: decimal number is lesser than minimum supported number (-10^%d - 1)", DecimalPrecision)
67+
return nil, fmt.Errorf("msgpack: decimal number is lesser than minimum supported number (-10^%d - 1)", decimalPrecision)
6868
}
6969

7070
strBuf := decNum.String()

0 commit comments

Comments
 (0)