1. suport date time '2070-03-30 00:00:00',timestamp can't support large date time. (#1823)

This commit is contained in:
lotus.wu 2019-10-17 23:36:06 +08:00 committed by Jinzhu
parent 120d39b4d6
commit b99f2d8270
1 changed files with 3 additions and 3 deletions

View File

@ -103,10 +103,10 @@ func (s *mysql) DataTypeOf(field *StructField) string {
precision = fmt.Sprintf("(%s)", p)
}
if _, ok := field.TagSettingsGet("NOT NULL"); ok || field.IsPrimaryKey {
sqlType = fmt.Sprintf("timestamp%v", precision)
if _, ok := field.TagSettings["NOT NULL"]; ok || field.IsPrimaryKey {
sqlType = fmt.Sprintf("DATETIME%v", precision)
} else {
sqlType = fmt.Sprintf("timestamp%v NULL", precision)
sqlType = fmt.Sprintf("DATETIME%v NULL", precision)
}
}
default: