pgtype
pgtype copied to clipboard
Set a ValueTranscoder from the same type errors
I'm trying to generate code to handle a composite type that contains a pgtype.Interval: https://github.com/jschaf/pggen/issues/49. The main issue seems to be that pgtype doesn't support Set with the same type. This test case shows the error:
func TestPgtype_Interval(t *testing.T) {
v1 := pgtype.Interval{Days: 2, Status: pgtype.Present}
v2 := pgtype.Interval{Days: 2, Status: pgtype.Present}
err := v1.Set(v2)
require.NoError(t, err) // Received unexpected error: cannot convert {0 2 0 2} to Interval
}
Two questions:
- Is it reasonable to support
Setfrom the same type?Getreturns the same type so it'd have a nice symmetry. - Would you take a PR for this feature?
Seems reasonable.