mirror of https://github.com/go-gorm/gorm.git
Handle data type cases
This commit is contained in:
parent
e3292b3b41
commit
d4d339f3b5
|
@ -224,8 +224,13 @@ 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 v, ok := field.TagSettings["AUTOCREATETIME"]; ok || (field.Name == "CreatedAt" && (field.DataType == Time || field.DataType == Int || field.DataType == Uint)) {
|
||||
if strings.ToUpper(v) == "NANO" {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue