Merge 0ff3187ca582d7b919260761cb627cbaf2c2ff4f into 57c72125b3087e1ed02c16f23a1f381cde3aaf2c
This commit is contained in:
commit
a90a6ebd39
@ -288,7 +288,7 @@ func (scope *Scope) handleManyToManyPreload(field *Field, conditions []interface
|
||||
// assign find results
|
||||
var (
|
||||
indirectScopeValue = scope.IndirectValue()
|
||||
fieldsSourceMap = map[string]reflect.Value{}
|
||||
fieldsSourceMap = map[string][]reflect.Value{}
|
||||
foreignFieldNames = []string{}
|
||||
)
|
||||
|
||||
@ -301,13 +301,16 @@ func (scope *Scope) handleManyToManyPreload(field *Field, conditions []interface
|
||||
if indirectScopeValue.Kind() == reflect.Slice {
|
||||
for j := 0; j < indirectScopeValue.Len(); j++ {
|
||||
object := indirect(indirectScopeValue.Index(j))
|
||||
fieldsSourceMap[toString(getValueFromFields(object, foreignFieldNames))] = object.FieldByName(field.Name)
|
||||
fieldsSourceMap[toString(getValueFromFields(object, foreignFieldNames))] = append(fieldsSourceMap[toString(getValueFromFields(object, foreignFieldNames))], object.FieldByName(field.Name))
|
||||
}
|
||||
} else if indirectScopeValue.IsValid() {
|
||||
fieldsSourceMap[toString(getValueFromFields(indirectScopeValue, foreignFieldNames))] = indirectScopeValue.FieldByName(field.Name)
|
||||
fieldsSourceMap[toString(getValueFromFields(indirectScopeValue, foreignFieldNames))] = append(fieldsSourceMap[toString(getValueFromFields(indirectScopeValue, foreignFieldNames))], indirectScopeValue.FieldByName(field.Name))
|
||||
}
|
||||
|
||||
for source, link := range linkHash {
|
||||
fieldsSourceMap[source].Set(reflect.Append(fieldsSourceMap[source], link...))
|
||||
for i, field := range fieldsSourceMap[source] {
|
||||
field.Set(reflect.Append(fieldsSourceMap[source][i], link...))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user