Skip to content

Commit 44ae235

Browse files
committed
Alias NullTime to sql.NullTime
And mark as deprecated. Fixes #902
1 parent 1dcfa6f commit 44ae235

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

encode.go

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package pq
22

33
import (
44
"bytes"
5-
"database/sql/driver"
5+
"database/sql"
66
"encoding/binary"
77
"encoding/hex"
88
"errors"
@@ -609,24 +609,9 @@ func encodeBytea(serverVersion int, v []byte) (result []byte) {
609609
return result
610610
}
611611

612-
// NullTime represents a time.Time that may be null. NullTime implements the
613-
// sql.Scanner interface so it can be used as a scan destination, similar to
614-
// sql.NullString.
615-
type NullTime struct {
616-
Time time.Time
617-
Valid bool // Valid is true if Time is not NULL
618-
}
619-
620-
// Scan implements the Scanner interface.
621-
func (nt *NullTime) Scan(value any) error {
622-
nt.Time, nt.Valid = value.(time.Time)
623-
return nil
624-
}
625-
626-
// Value implements the driver Valuer interface.
627-
func (nt NullTime) Value() (driver.Value, error) {
628-
if !nt.Valid {
629-
return nil, nil
630-
}
631-
return nt.Time, nil
632-
}
612+
// NullTime represents a [time.Time] that may be null.
613+
// NullTime implements the [sql.Scanner] interface so
614+
// it can be used as a scan destination, similar to [sql.NullString].
615+
//
616+
// Deprecated: this is an alias for [sql.NullTime].
617+
type NullTime = sql.NullTime

0 commit comments

Comments
 (0)