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

0 comments on commit b0cf955

Please sign in to comment.