Scanning nil for null.Time creates value with Valid = false rather than erroring

This commit is contained in:
Jed Borovik 2015-09-10 12:49:41 -04:00
parent 8112aae462
commit 5bebd577e0

View file

@ -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)
}