Skip to content

Commit

Permalink
optimize Parse func for fieldValue.Interface
Browse files Browse the repository at this point in the history
  • Loading branch information
daheige authored and huacnlee committed Jul 28, 2021
1 parent 41ac73b commit 7a49629
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,19 +244,20 @@ func Parse(dest interface{}, cacheStore *sync.Map, namer Namer) (*Schema, error)
}

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)...)
}

if fc, ok := fieldValue.Interface().(QueryClausesInterface); ok {
if fc, ok := fieldInterface.(QueryClausesInterface); ok {
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)...)
}

if fc, ok := fieldValue.Interface().(DeleteClausesInterface); ok {
if fc, ok := fieldInterface.(DeleteClausesInterface); ok {
field.Schema.DeleteClauses = append(field.Schema.DeleteClauses, fc.DeleteClauses(field)...)
}
}
Expand Down

0 comments on commit 7a49629

Please sign in to comment.