diff --git a/pkg/types/unix_milli.go b/pkg/types/unix_milli.go index d68c12df..e0b780ab 100644 --- a/pkg/types/unix_milli.go +++ b/pkg/types/unix_milli.go @@ -5,6 +5,7 @@ import ( "database/sql/driver" "encoding" "encoding/json" + "github.com/pkg/errors" "strconv" "time" ) @@ -63,13 +64,23 @@ func (t *UnixMilli) Scan(src interface{}) error { return nil } - i, err := strToInt(string(src.([]byte))) - if err != nil { - return err + switch v := src.(type) { + case []byte: + i, err := strToInt(string(src.([]byte))) + if err != nil { + return err + } + + *t = UnixMilli(time.UnixMilli(i)) + // https://github.com/go-sql-driver/mysql/pull/1452 + case uint64: + *t = UnixMilli(time.UnixMilli(int64(v))) + case int64: + *t = UnixMilli(time.UnixMilli(v)) + default: + return errors.Errorf("bad (u)int64/[]byte type assertion from %[1]v (%[1]T)", src) } - *t = UnixMilli(FromUnixMilli(i)) - return nil }