diff --git a/schema/field.go b/schema/field.go index f8ecef60..737f56c4 100644 --- a/schema/field.go +++ b/schema/field.go @@ -224,7 +224,12 @@ func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field { } if val, ok := field.TagSettings["TYPE"]; ok { - field.DataType = DataType(val) + 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)) { diff --git a/tests/embedded_struct_test.go b/tests/embedded_struct_test.go index 5f06f63c..8536b605 100644 --- a/tests/embedded_struct_test.go +++ b/tests/embedded_struct_test.go @@ -107,7 +107,7 @@ func TestEmbeddedPointerTypeStruct(t *testing.T) { } type Content struct { - Content interface{} `gorm:"type:string"` + Content interface{} `gorm:"type:String"` } func (c Content) Value() (driver.Value, error) {