Skip to content

Commit b0cf955

Browse files
committed
distinguish between schema.Time and tag time
fix go-gorm/gorm#6033
1 parent a7f2d26 commit b0cf955

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

postgres.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,17 @@ func (dialector Dialector) DataTypeOf(field *schema.Field) string {
189189
}
190190
return "text"
191191
case schema.Time:
192+
var timeType string
193+
// Distinguish between schema.Time and tag time
194+
if val, ok := field.TagSettings["TYPE"]; ok {
195+
timeType = val
196+
} else {
197+
timeType = "timestamptz"
198+
}
192199
if field.Precision > 0 {
193-
return fmt.Sprintf("timestamptz(%d)", field.Precision)
200+
return fmt.Sprintf("%s(%d)", timeType, field.Precision)
194201
}
195-
return "timestamptz"
202+
return timeType
196203
case schema.Bytes:
197204
return "bytea"
198205
default:

0 commit comments

Comments
 (0)