The shopspring/decimal package provides a NullDecimal struct intended
for use with nullable SQL NUMERICs and numbers. It has Scanner and
Valuer implementations already, but adding it to this package allows
it to be used with the binary encoding as well.
The implementation is very straightforward, but the tests have been made
slightly more complicated. The previous version wasn't testing the
decimal.Decimal cases, and this change adds those as well as new
NullDecimal cases. I've added some logic to the test harness to catch
these as you need to use the Equals method to properly compare Decimals.
Methods defined on T are also available on *T. Thought this technically
changes the interface, because *T will be automatically dereferenced as
needed it shouldn't be a breaking change.
See a8802b16cc for similar change.
Methods defined on T are also available on *T. This change makes Value
consistent with database/sql Value implementations. It also makes Value,
EncodeBinary, and EncodeText more convenient to use because you can
pass T or *T as an argument to a query.
The MarshalJSON change is even more significant because without it
json.Marshal would generate the "%v" format instead of the implemented
MarshalJSON.
Thought this technically changes the interface, because *T will be
automatically dereferenced as needed it shouldn't be a breaking change.
See: https://github.com/jackc/pgx/issues/538 for initial discussion.
This adds PostgreSQL numeric mapping to and from
github.com/shopspring/decimal.
Makes pgtype.NullAssignTo public as external types need this functionality.
Begin extraction of pgtype testing functionality so it can easily be used by
external types.