Skip to content

Commit

Permalink
1. suport date time '2070-03-30 00:00:00',timestamp can't support lar…
Browse files Browse the repository at this point in the history
…ge date time. (go-gorm#1823)
  • Loading branch information
lotus-wu authored and jinzhu committed Oct 17, 2019
1 parent 120d39b commit b99f2d8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dialect_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b99f2d8

Please sign in to comment.