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 0f54846 commit 50eeb50
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions sqlserver.go
Expand Up @@ -191,10 +191,17 @@ func (dialector Dialector) DataTypeOf(field *schema.Field) string {
}
return "nvarchar(MAX)"
case schema.Time:
var timeType string
// Distinguish between schema.Time and tag time
if val, ok := field.TagSettings["TYPE"]; ok {
timeType = val
} else {
timeType = "datetimeoffset"
}
if field.Precision > 0 {
return fmt.Sprintf("datetimeoffset(%d)", field.Precision)
return fmt.Sprintf("%s(%d)", timeType, field.Precision)
}
return "datetimeoffset"
return timeType
case schema.Bytes:
return "varbinary(MAX)"
}
Expand Down

0 comments on commit 50eeb50

Please sign in to comment.