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.
It was a mistake to use it in other contexts. This made interop
difficult between pacakges that depended on pgtype such as pgx and
packages that did not like pgconn and pgproto3. In particular this was
awkward for prepared statements.
Because pgx depends on pgtype and the tests for pgtype depend on pgx
this change will require a couple back and forth commits to get the
go.mod dependecies correct.
commit 251e6b7730c7b31b600e6fe06162e541f3032604
Author: Nicholas Wilson <nicholas.wilson@realvnc.com>
Date: Wed Jul 24 12:32:43 2019 +0100
Tidying: make underlyingTimeType consistent with other underlyingFooType
The first return value is ignored when returning false - so there's no
point returning an empty time.Time when it can be nil.
commit fc020c24ac9590f6547f8ad1d291fc75b4873a84
Author: Nicholas Wilson <nicholas.wilson@realvnc.com>
Date: Wed Jul 24 12:32:18 2019 +0100
Add support for pgtype.UUID to write into any [16]byte type
Also remove PrepareEx. It's primary usage was for context. Supplying
parameter OIDs is unnecessary when you can type cast in the query SQL.
If it does become necessary or desirable to add options back it can be
added in a backwards compatible way by adding a varargs as last
argument.
Instead of needing to instrospect the database on connection preload the
standard OID / type map. Types from extensions (like hstore) and custom
types can be registered by the application developer. Otherwise, they
will be treated as strings.
It is impossible to guarantee that the a query executed with the simple
protocol will behave the same as with the extended protocol. This is
because the normal pgx path relies on knowing the OID of query
parameters. Without this encoding a value can only be determined by the
value instead of the combination of value and PostgreSQL type. For
example, how should a []int32 be encoded? It might be encoded into a
PostgreSQL int4[] or json.
Removal also simplifies the core query path.
The primary reason for the simple protocol is for servers like PgBouncer
that may not be able to support normal prepared statements. After
further research it appears that issuing a "flush" instead "sync" after
preparing the unnamed statement would allow PgBouncer to work.
The one round trip mode can be better handled with prepared statements.
As a last resort, all original server functionality can still be accessed by
dropping down to PgConn.
AssignTo can only assign NULL to a **string. Previous code tried to
assign nil to a *string, which did nothing. Correct behavior is to
detect this as an error.
JSON(B) automatically marshals any value. Avoid marshalling values of
pgtype.JSON and pgtype.JSONB. The caller certainly meant to call on a
pointer.
See https://github.com/jackc/pgx/issues/350 for discussion.
refs #350