pgtype.Row() was optimized for a single line use
without much ceremony at a cost of OID registration,
which is cumbersome. In practice it so much incovnenience
to create new Composite just before making a query.
So now there is just a Composite type and 2 helper methods:
- SetFields sets composite fields to values passed. This assignment
fails if types passed are not assignable to Values pgtype is
made of.
- Scan acts exactly like query.Scan, but for a composite value. Passed
values are set to values from SQL composite.
Composite() function returns a private type, which should
be registered with ConnInfo.RegisterDataType for the composite
type's OID.
All subsequent interaction with Composite types is to be done
via Row(...) function. Function return value can be either
passed as a query argument to build SQL composite value out of
individual fields or passed to Scan to read SQL composite value
back.
When passed to Scan, Row() should have first argument of type
*bool to flag NULL values returned from query.
ScanRowValue is useful when reading ROW() values with
known field types as well as composite types. It accepts
pgtype.Value arguments, where ROW() fields are written to
on successfull scan.
PostgreSQL has microsecond precision. If more than this precision is
supplied in the text format it is rounded. This was inconsistent with
the binary format.
See https://github.com/jackc/pgx/issues/699 for original issue.
Previously Set would always return an error when called on a range type.
Now it will accept an instance of itself, a pointer to an instance of
itself, a string, or nil. Strings are parsed with the same logic as
DecodeText.
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.
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.