Scanning nil for null.Time creates value with Valid = false rather than erroring
This commit is contained in:
parent
8112aae462
commit
5bebd577e0
1 changed files with 3 additions and 0 deletions
3
time.go
3
time.go
|
@ -21,6 +21,9 @@ func (t *Time) Scan(value interface{}) error {
|
|||
switch x := value.(type) {
|
||||
case time.Time:
|
||||
t.Time = x
|
||||
case nil:
|
||||
t.Valid = false
|
||||
return nil
|
||||
default:
|
||||
err = fmt.Errorf("null: cannot scan type %T into null.Time: %v", value, value)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue