pgx v5 introduced nil normalization for typed nils. This means that
[]byte(nil) is normalized to nil at the edge of the encoding system.
This simplified encoding logic as nil could be encoded as NULL and type
specific handling was unneeded.
However, database/sql compatibility requires Value to be called on a
nil pointer that implements driver.Valuer. This was broken by
normalizing to nil.
This commit changes the normalization logic to not normalize pointers
that directly implement driver.Valuer to nil. It still normalizes
pointers that implement driver.Valuer through implicit derefence.
e.g.
type T struct{}
func (t *T) Value() (driver.Value, error) {
return nil, nil
}
type S struct{}
func (s S) Value() (driver.Value, error) {
return nil, nil
}
(*T)(nil) will not be normalized to nil but (*S)(nil) will be.
https://github.com/jackc/pgx/issues/1566