Skip to content

Commit

Permalink
distinguish between schema.Time and tag time
Browse files Browse the repository at this point in the history
  • Loading branch information
black-06 committed Feb 20, 2023
1 parent 7ba6a0e commit 53d3fa1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions mysql.go
Expand Up @@ -399,6 +399,14 @@ func (dialector Dialector) getSchemaStringType(field *schema.Field) string {
}

func (dialector Dialector) getSchemaTimeType(field *schema.Field) string {
var timeType string
// Distinguish between schema.Time and tag time
if val, ok := field.TagSettings["TYPE"]; ok {
timeType = val
} else {
timeType = "datetime"
}

if !dialector.DisableDatetimePrecision && field.Precision == 0 {
field.Precision = *dialector.DefaultDatetimePrecision
}
Expand All @@ -409,9 +417,9 @@ func (dialector Dialector) getSchemaTimeType(field *schema.Field) string {
}

if field.NotNull || field.PrimaryKey {
return "datetime" + precision
return timeType + precision
}
return "datetime" + precision + " NULL"
return timeType + precision + " NULL"
}

func (dialector Dialector) getSchemaBytesType(field *schema.Field) string {
Expand Down

0 comments on commit 53d3fa1

Please sign in to comment.