6 Commits

Author SHA1 Message Date
Maxim Ivanov
5f0d5f4255 Remove pgtype.Row(), introduce Composite.Scan()
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.
2020-04-27 00:48:02 +01:00
Maxim Ivanov
a6747b513f Split composite examples 2020-04-13 17:44:02 +01:00
Maxim Ivanov
3ce29f9e05 Add Composite type for inplace row() values handling
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.
2020-04-13 17:41:44 +01:00
Maxim Ivanov
8ae83b19f7 Add EncodeRow helpers
Also extend example to show how EncodeRow can be used
to create binary encoders for composite type
2020-04-13 00:09:03 +01:00
Maxim Ivanov
368295d3ee Create ROW helper for adhoc decoding of records 2020-04-12 18:40:52 +01:00
Maxim Ivanov
71ed747f3a Add example of CompositeType handling with ScanRowValue helper 2020-04-12 17:36:39 +01:00