mirror of https://github.com/go-gorm/gorm.git
Don't set NULL if timestamp column is Primary Key (#2332)
This commit is contained in:
parent
e3987fd4b8
commit
7bc3561503
|
@ -100,7 +100,7 @@ func (s *mysql) DataTypeOf(field *StructField) string {
|
||||||
precision = fmt.Sprintf("(%s)", p)
|
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)
|
sqlType = fmt.Sprintf("timestamp%v", precision)
|
||||||
} else {
|
} else {
|
||||||
sqlType = fmt.Sprintf("timestamp%v NULL", precision)
|
sqlType = fmt.Sprintf("timestamp%v NULL", precision)
|
||||||
|
|
Loading…
Reference in New Issue