Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

distinguish between schema.Time and tag time #109

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions mysql.go
Original file line number Diff line number Diff line change
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