DateCodec.DecodeDatabaseSQLValue returns time.Time when possible

Previously it returned a string. However, this was an unintended
behavior change from pgx v4.

89f69aaea9 (commitcomment-89173737)
pull/1379/head
Jack Christensen 2022-11-12 06:21:48 -06:00
parent daf570c752
commit 29109487ec
1 changed files with 15 additions and 1 deletions

View File

@ -308,7 +308,21 @@ func (scanPlanTextAnyToDateScanner) Scan(src []byte, dst any) error {
}
func (c DateCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error) {
return codecDecodeToTextFormat(c, m, oid, format, src)
if src == nil {
return nil, nil
}
var date Date
err := codecScan(c, m, oid, format, src, &date)
if err != nil {
return nil, err
}
if date.InfinityModifier != Finite {
return date.InfinityModifier.String(), nil
}
return date.Time, nil
}
func (c DateCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {