forked from mirror/gorm
optimize Parse func for fieldValue.Interface
This commit is contained in:
parent
41ac73b6a1
commit
7a49629fd1
|
@ -244,19 +244,20 @@ func Parse(dest interface{}, cacheStore *sync.Map, namer Namer) (*Schema, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldValue := reflect.New(field.IndirectFieldType)
|
fieldValue := reflect.New(field.IndirectFieldType)
|
||||||
if fc, ok := fieldValue.Interface().(CreateClausesInterface); ok {
|
fieldInterface := fieldValue.Interface()
|
||||||
|
if fc, ok := fieldInterface.(CreateClausesInterface); ok {
|
||||||
field.Schema.CreateClauses = append(field.Schema.CreateClauses, fc.CreateClauses(field)...)
|
field.Schema.CreateClauses = append(field.Schema.CreateClauses, fc.CreateClauses(field)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if fc, ok := fieldValue.Interface().(QueryClausesInterface); ok {
|
if fc, ok := fieldInterface.(QueryClausesInterface); ok {
|
||||||
field.Schema.QueryClauses = append(field.Schema.QueryClauses, fc.QueryClauses(field)...)
|
field.Schema.QueryClauses = append(field.Schema.QueryClauses, fc.QueryClauses(field)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if fc, ok := fieldValue.Interface().(UpdateClausesInterface); ok {
|
if fc, ok := fieldInterface.(UpdateClausesInterface); ok {
|
||||||
field.Schema.UpdateClauses = append(field.Schema.UpdateClauses, fc.UpdateClauses(field)...)
|
field.Schema.UpdateClauses = append(field.Schema.UpdateClauses, fc.UpdateClauses(field)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if fc, ok := fieldValue.Interface().(DeleteClausesInterface); ok {
|
if fc, ok := fieldInterface.(DeleteClausesInterface); ok {
|
||||||
field.Schema.DeleteClauses = append(field.Schema.DeleteClauses, fc.DeleteClauses(field)...)
|
field.Schema.DeleteClauses = append(field.Schema.DeleteClauses, fc.DeleteClauses(field)...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue