corresponds timestamp precision for mysql

This commit is contained in:
miyauchi 2017-10-20 10:24:09 +09:00 committed by Jinzhu
parent 89a726ce5d
commit ae696d051f
1 changed files with 2 additions and 2 deletions

View File

@ -96,9 +96,9 @@ func (s *mysql) DataTypeOf(field *StructField) string {
case reflect.Struct: case reflect.Struct:
if _, ok := dataValue.Interface().(time.Time); ok { if _, ok := dataValue.Interface().(time.Time); ok {
if _, ok := field.TagSettings["NOT NULL"]; ok { if _, ok := field.TagSettings["NOT NULL"]; ok {
sqlType = "timestamp" sqlType = fmt.Sprintf("timestamp(%d)", size)
} else { } else {
sqlType = "timestamp NULL" sqlType = fmt.Sprintf("timestamp(%d) NULL", size)
} }
} }
default: default: