fix: if it's an empty time, do not return a driver value

This commit is contained in:
c9s 2022-03-06 18:25:16 +08:00
parent 917684aa27
commit f3577a4182

View File

@ -176,6 +176,9 @@ func NewTimeFromUnix(sec int64, nsec int64) Time {
// Value implements the driver.Valuer interface
// see http://jmoiron.net/blog/built-in-interfaces/
func (t Time) Value() (driver.Value, error) {
if time.Time(t) == (time.Time{}) {
return nil, nil
}
return time.Time(t), nil
}