DateCodec.DecodeDatabaseSQLValue returns time.Time when possible
Previously it returned a string. However, this was an unintended behavior change from pgx v4. https://github.com/jackc/pgx/commit/89f69aaea9748ae0ea121af4f1886d24966cef56#commitcomment-89173737
This commit is contained in:
+15
-1
@@ -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) {
|
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) {
|
func (c DateCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user