Commit Graph

25 Commits (5db1de5fc18703ddf645024dff9ff73c98bc9107)

Author SHA1 Message Date
Eli Treuherz db84905b7f Add NullDecimal to shopspring-numeric
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.
2021-08-07 08:23:02 -05:00
Jack Christensen c16a4f7d6a Revert "Temporarily delete tests and pgxtype to break recursive dependency with pgx"
This reverts commit 32e20a6031.
2021-07-24 10:40:30 -05:00
Jack Christensen 32e20a6031 Temporarily delete tests and pgxtype to break recursive dependency with pgx 2021-07-24 10:16:00 -05:00
Jack Christensen dd160540c4 Use Go 1.13 errors instead of xerrors 2021-03-25 09:08:27 -04:00
Jack Christensen 0e2bc3467a Fix ext/gofrs-uuid AssignTo *uuid.UUID 2020-05-12 21:01:06 -05:00
Jack Christensen e6c6de9494 Improved ext/shopspring-numeric binary decoding performance
Before:
BenchmarkDecode/Zero-Binary-16       	 3944304	       292 ns/op	     128 B/op	       7 allocs/op
BenchmarkDecode/Small-Binary-16      	 2034132	       585 ns/op	     184 B/op	      13 allocs/op
BenchmarkDecode/Medium-Binary-16     	 1747191	       690 ns/op	     192 B/op	      12 allocs/op
BenchmarkDecode/Large-Binary-16      	 1334006	       899 ns/op	     304 B/op	      14 allocs/op
BenchmarkDecode/Huge-Binary-16       	  702382	      1590 ns/op	     584 B/op	      18 allocs/op

After:
BenchmarkDecode/Zero-Binary-16       	14592645	        80.1 ns/op	      64 B/op	       2 allocs/op
BenchmarkDecode/Small-Binary-16      	 5729318	       212 ns/op	     104 B/op	       7 allocs/op
BenchmarkDecode/Medium-Binary-16     	 4930009	       241 ns/op	      88 B/op	       5 allocs/op
BenchmarkDecode/Large-Binary-16      	 3369573	       344 ns/op	     144 B/op	       7 allocs/op
BenchmarkDecode/Huge-Binary-16       	 2587156	       453 ns/op	     216 B/op	       9 allocs/op
2020-05-02 11:34:14 -05:00
Jack Christensen 9016875cae Add JSON support to ext/gofrs-uuid 2020-04-02 14:01:16 -05:00
Jack Christensen 55a56add23 Set will call Get on src if possible 2020-02-19 11:58:49 -06:00
Jack Christensen 666bd514e2 Add standard nil test to gofrs-uuid.UUID.Set 2020-02-19 10:50:58 -06:00
Jack Christensen f3816bd1c0 Get implemented on T instead of *T
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.
2020-02-19 10:48:09 -06:00
Jack Christensen cf87e34792 Add JSON to shopspring-numeric extension 2020-01-24 17:07:41 -06:00
Jack Christensen cf8fe4a477 uuid extension switched to gofrs from satori
Do not encourage library use that has serious outstanding bug:
https://github.com/satori/go.uuid/issues/73
2019-09-14 19:58:54 -05:00
Jack Christensen a8802b16cc Value, EncodeBinary, EncodeText, and MarshalJSON on T instead of *T
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.
2019-08-27 20:46:16 -05:00
Jack Christensen 4ed0de4755 Splitting pgtype into own repo 2019-04-20 19:14:08 -05:00
Jack Christensen f25878662d Use golang.org/x/xerrors 2019-04-20 17:43:44 -05:00
Jack Christensen 8502a12ac7 Fix go modules
Wow. This is fun. Sure is easy to get modules wrong when upgrading a v2+
project.
2019-04-20 17:41:08 -05:00
Jack Christensen 4e79a104f7 Test domains when registered and unregistered
Fix bug assigning to unknown type.
2019-04-13 17:09:51 -05:00
Jack Christensen 7ed0a8732c Update shopspring decimal integration test
New version of shopspring/decimal improves precision. This broke a test.
2018-03-08 07:40:25 -05:00
Jack Christensen a5f166bd21 Use github.com/pkg/errors 2017-06-04 21:30:03 -05:00
Jack Christensen 496c5a4dff Use Go casing convention for UUID 2017-06-03 11:54:57 -05:00
Jack Christensen 071de0b674 Fix shopsprint-numeric test 2017-05-20 09:46:06 -05:00
Jack Christensen 1f1677ba5e Ensure shopspring-numeric tests run 2017-05-20 09:44:15 -05:00
Jack Christensen 6b906ca870 Refactor pgio and types to append buffers 2017-05-02 20:38:26 -05:00
Jack Christensen f0e9337d8f Add satori-uuid type
Make pgtype.EncodeValueText public
2017-04-14 16:46:39 -05:00
Jack Christensen b49035fdc1 Add shopspring.Numeric
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.
2017-04-14 12:24:44 -05:00