1
0
mirror of https://github.com/jackc/pgx.git synced 2025-04-05 00:10:54 +00:00

23 Commits

Author SHA1 Message Date
Jack Christensen
55a56add23 Set will call Get on src if possible 2020-02-19 11:58:49 -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 a8802b16cc593842f5c69b0f7cfb0de11d5cd3a8 for similar change.
2020-02-19 10:48:09 -06:00
Jack Christensen
be36a7e14b Fix test and avoid change to array signatures
typed_array.go.erb was not updated back in
a8802b16cc593842f5c69b0f7cfb0de11d5cd3a8 when Value, EncodeBinary,
EncodeText, and MarshalJSON were changed to be defined on T instead of
*T. This has been corrected.
2019-11-14 20:40:41 -06:00
Alex Gaynor
0079108e29 Fixes -- support initializing Array types from a slice of the value 2019-11-08 14:59:19 -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
f25878662d Use golang.org/x/xerrors 2019-04-20 17:43:44 -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
0ac82007fb Use extracted packages with Go modules 2019-04-05 10:59:47 -05:00
Damir Vandic
79ba0275de Add the type of the value in all decode error messages 2018-06-04 21:02:20 +02:00
Jack Christensen
703ce85513 Generate UUIDArray from template
- Fix error in Set
- Specifically handle untyped nil
2017-08-29 14:33:25 -05:00
Jack Christensen
a5f166bd21 Use github.com/pkg/errors 2017-06-04 21:30:03 -05:00
Jack Christensen
2140814606 Use Go casing convention for OID 2017-06-03 11:53:49 -05:00
Jack Christensen
6b906ca870 Refactor pgio and types to append buffers 2017-05-02 20:38:26 -05:00
Jack Christensen
ab21bc4ec7 pgtype DecodeText and DecodeBinary do not copy
They now take ownership of the src argument.

Needed to change Scan to make a copy of []byte arguments as lib/pq apparently
gives Scan a shared memory buffer.
2017-04-29 12:23:51 -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
Jack Christensen
6f9ef694d0 Add database/sql support to pgtype 2017-03-18 21:11:43 -05:00
Jack Christensen
85f7df1e81 Factor out duplication in AssignTo 2017-03-18 16:54:08 -05:00
Jack Christensen
df8f8e17cf Add pgtype.HstoreArray
This required restructuring array types to lookup oid of element instead of
hard-coding it due to hstore having a variable oid.
2017-03-18 12:40:54 -05:00
Jack Christensen
6e21cb00fe Add pgtype.Record and prerequisite restructuring
Because reading a record type requires the decoder to be able to look up oid
to type mapping and types such as hstore have types that are not fixed between
different PostgreSQL servers it was necessary to restructure the pgtype system
so all encoders and decodes take a *ConnInfo that includes oid/name/type
information.
2017-03-18 12:01:16 -05:00
Jack Christensen
a79b498533 Remove Set self support from pgtype
Set having the capability to assign an object of the same type was
inconsistently implemented. Some places it was not implemented at all, some
places it was a shallow copy, some places a deep copy. Given that it doesn't
seem likely to ever be used, and if it is needed it is easy enough to do
outside of the library this code has been removed.
2017-03-11 20:18:56 -06:00
Jack Christensen
9b9361848d Expand pgtype.Value interface
- Include and rename ConvertFrom to Set
- Add Get
- Include AssignTo
2017-03-11 19:53:45 -06:00
Jack Christensen
666af9ead5 Name PG types as words
Though this doesn't follow Go naming conventions exactly it makes names more
consistent with PostgreSQL and it is easier to read. For example, TIDOID becomes
TidOid. In addition this is one less breaking change in the move to V3.
2017-03-11 17:03:23 -06:00
Jack Christensen
44e206ab5b Rename array files 2017-03-11 16:53:07 -06:00