forked from mirror/gorm
Don't use value's first field to guess data type for struct implements GormDataTypeInterface
This commit is contained in:
parent
362779575c
commit
6dc583869b
|
@ -105,6 +105,7 @@ func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field {
|
||||||
// if field is valuer, used its value or first fields as data type
|
// if field is valuer, used its value or first fields as data type
|
||||||
valuer, isValuer := fieldValue.Interface().(driver.Valuer)
|
valuer, isValuer := fieldValue.Interface().(driver.Valuer)
|
||||||
if isValuer {
|
if isValuer {
|
||||||
|
if _, ok := fieldValue.Interface().(GormDataTypeInterface); !ok {
|
||||||
var overrideFieldValue bool
|
var overrideFieldValue bool
|
||||||
if v, err := valuer.Value(); v != nil && err == nil {
|
if v, err := valuer.Value(); v != nil && err == nil {
|
||||||
overrideFieldValue = true
|
overrideFieldValue = true
|
||||||
|
@ -132,6 +133,7 @@ func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if dbName, ok := field.TagSettings["COLUMN"]; ok {
|
if dbName, ok := field.TagSettings["COLUMN"]; ok {
|
||||||
field.DBName = dbName
|
field.DBName = dbName
|
||||||
|
|
Loading…
Reference in New Issue