diff --git a/pgtype/builtin_wrappers.go b/pgtype/builtin_wrappers.go index d93f8d59..e34dd578 100644 --- a/pgtype/builtin_wrappers.go +++ b/pgtype/builtin_wrappers.go @@ -238,7 +238,7 @@ func (w *uint64Wrapper) ScanNumeric(v Numeric) error { return fmt.Errorf("cannot scan %v into *uint64", bi.String()) } - *w = uint64Wrapper(v.Int.Uint64()) + *w = uint64Wrapper(bi.Uint64()) return nil } @@ -291,7 +291,7 @@ func (w *uintWrapper) ScanNumeric(v Numeric) error { return fmt.Errorf("cannot scan %v into *uint", bi.String()) } - ui := v.Int.Uint64() + ui := bi.Uint64() if math.MaxUint < ui { return fmt.Errorf("cannot scan %v into *uint", ui) diff --git a/pgtype/numeric_test.go b/pgtype/numeric_test.go index 46faa5ce..4852f442 100644 --- a/pgtype/numeric_test.go +++ b/pgtype/numeric_test.go @@ -110,8 +110,10 @@ func TestNumericCodec(t *testing.T) { {int64(math.MinInt64 + 1), new(pgtype.Numeric), isExpectedEqNumeric(mustParseNumeric(t, strconv.FormatInt(math.MinInt64+1, 10)))}, {int64(math.MaxInt64), new(pgtype.Numeric), isExpectedEqNumeric(mustParseNumeric(t, strconv.FormatInt(math.MaxInt64, 10)))}, {int64(math.MaxInt64 - 1), new(pgtype.Numeric), isExpectedEqNumeric(mustParseNumeric(t, strconv.FormatInt(math.MaxInt64-1, 10)))}, + {uint64(100), new(uint64), isExpectedEq(uint64(100))}, {uint64(math.MaxUint64), new(uint64), isExpectedEq(uint64(math.MaxUint64))}, {uint(math.MaxUint), new(uint), isExpectedEq(uint(math.MaxUint))}, + {uint(100), new(uint), isExpectedEq(uint(100))}, {"1.23", new(string), isExpectedEq("1.23")}, {pgtype.Numeric{}, new(pgtype.Numeric), isExpectedEq(pgtype.Numeric{})}, {nil, new(pgtype.Numeric), isExpectedEq(pgtype.Numeric{})},