Skip to content

Commit

Permalink
Don't set NULL if timestamp column is Primary Key (go-gorm#2332)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaneli authored and jinzhu committed Apr 14, 2019
1 parent e3987fd commit 7bc3561
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dialect_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (s *mysql) DataTypeOf(field *StructField) string {
precision = fmt.Sprintf("(%s)", p)
}

if _, ok := field.TagSettingsGet("NOT NULL"); ok {
if _, ok := field.TagSettingsGet("NOT NULL"); ok || field.IsPrimaryKey {
sqlType = fmt.Sprintf("timestamp%v", precision)
} else {
sqlType = fmt.Sprintf("timestamp%v NULL", precision)
Expand Down

0 comments on commit 7bc3561

Please sign in to comment.