Skip to content

Commit

Permalink
compatible slice struct pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
fifsky committed Dec 27, 2018
1 parent 370d4ec commit 55b14c5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion relation.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func RelationAll(data interface{} , chains map[string] BuilderChainFunc) error {
}

// get the struct field in slice
t := refVal.Index(0).Elem().Type()
t := reflect.Indirect(refVal.Index(0)).Type()

return eachField(t, func(field reflect.StructField, val string, name string, relations []string) error {
relVals := make([]interface{}, 0)
Expand Down
1 change: 1 addition & 0 deletions wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ func (w *Wrapper) Select(dest interface{}, query string, args ...interface{}) (e
if err != nil {
return err
}

// relation data fill
return RelationAll(dest , w.RelationMap)
}
Expand Down

0 comments on commit 55b14c5

Please # to comment.