Commit Graph

14 Commits (e44f0f24c4bb7e7fcfaa6057497e0a61d27d5eac)

Author SHA1 Message Date
Damir Vandic fa045b7a4b Add the type of the value in all decode error messages 2018-06-04 21:02:20 +02:00
Jack Christensen 8f4178b3d3 Use github.com/pkg/errors 2017-06-04 21:30:03 -05:00
Jack Christensen 6e64a0c867 Refactor pgio and types to append buffers 2017-05-02 20:38:26 -05:00
Jack Christensen 932caef600 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 a8c350c77d Use pointer methods for all struct pgtypes
Now no need to no whether certain interfaces are implemented by struct or
pointer to struct.
2017-04-14 13:08:05 -05:00
Jack Christensen e4451b47b2 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 bec9bd261b Add database/sql support to pgtype 2017-03-18 21:11:43 -05:00
Jack Christensen 4d9c44fc01 Factor out duplication in AssignTo 2017-03-18 16:54:08 -05:00
Jack Christensen 19c6689752 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 aac8fd66f2 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 57494a6a0f Expand pgtype.Value interface
- Include and rename ConvertFrom to Set
- Add Get
- Include AssignTo
2017-03-11 19:53:45 -06:00
Jack Christensen 1f3e484ca1 pgtype.Encode(Binary|Text) do not write length
To aid in composability, these methods no longer write their own length. This
is especially useful for text formatted arrays and may be useful for future
database/sql compatibility. It also makes the code a little simpler as the
types no longer have to compute their own size.

Along with this, these methods cannot encode NULL. They now return a boolean
if they are NULL. This also benefits text array encoding as numeric arrays
require NULL to be exactly `NULL` while string arrays require NULL to be
`"NULL"`.
2017-03-11 12:45:30 -06:00
Jack Christensen 8162634259 Decode(Text|Binary) now accepts []byte instead of io.Reader 2017-03-10 16:08:47 -06:00
Jack Christensen 3179e2debc Add timestamp to pgtype 2017-03-04 12:36:24 -06:00