diff --git a/schema/field.go b/schema/field.go index a8328367..f02968fa 100644 --- a/schema/field.go +++ b/schema/field.go @@ -223,15 +223,6 @@ func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field { field.DataType = DataType(dataTyper.GormDataType()) } - if val, ok := field.TagSettings["TYPE"]; ok { - switch DataType(strings.ToLower(val)) { - case Bool, Int, Uint, Float, String, Time, Bytes: - field.DataType = DataType(strings.ToLower(val)) - default: - field.DataType = DataType(val) - } - } - if v, ok := field.TagSettings["AUTOCREATETIME"]; ok || (field.Name == "CreatedAt" && (field.DataType == Time || field.DataType == Int || field.DataType == Uint)) { if strings.ToUpper(v) == "NANO" { field.AutoCreateTime = UnixNanosecond @@ -248,6 +239,15 @@ func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field { } } + if val, ok := field.TagSettings["TYPE"]; ok { + switch DataType(strings.ToLower(val)) { + case Bool, Int, Uint, Float, String, Time, Bytes: + field.DataType = DataType(strings.ToLower(val)) + default: + field.DataType = DataType(val) + } + } + if field.Size == 0 { switch reflect.Indirect(fieldValue).Kind() { case reflect.Int, reflect.Int64, reflect.Uint, reflect.Uint64, reflect.Float64: