Attach all eagerly loaded models in to-one
- The problem here is that due to the nature of the relationship and the way the loop was set up it was possible to miss some relationships: A _ C \_ D B _ E \_ F Since we looped over A and B and did a break when we found something to attach it to (in this example A would find C) it would break. What we should be looping through is CDEF and finding a home for each one. Did the same change in to_one though it doesn't matter since it's one-to-one. to-many is untouched because it's already looping over CDEF and finding a home for it because the relationship is reversed. - Fix #98
This commit is contained in:
parent
0221da2491
commit
59c238539d
2 changed files with 14 additions and 6 deletions
|
@ -65,13 +65,17 @@ func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singula
|
|||
}
|
||||
{{- end}}
|
||||
|
||||
if singular && len(resultSlice) != 0 {
|
||||
if len(resultSlice) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if singular {
|
||||
object.R.{{$txt.Function.Name}} = resultSlice[0]
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, foreign := range resultSlice {
|
||||
for _, local := range slice {
|
||||
for _, local := range slice {
|
||||
for _, foreign := range resultSlice {
|
||||
{{if $txt.Function.UsesBytes -}}
|
||||
if 0 == bytes.Compare(local.{{$txt.Function.LocalAssignment}}, foreign.{{$txt.Function.ForeignAssignment}}) {
|
||||
{{else -}}
|
||||
|
|
|
@ -65,13 +65,17 @@ func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singula
|
|||
}
|
||||
{{- end}}
|
||||
|
||||
if singular && len(resultSlice) != 0 {
|
||||
if len(resultSlice) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if singular {
|
||||
object.R.{{$txt.Function.Name}} = resultSlice[0]
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, foreign := range resultSlice {
|
||||
for _, local := range slice {
|
||||
for _, local := range slice {
|
||||
for _, foreign := range resultSlice {
|
||||
{{if $txt.Function.UsesBytes -}}
|
||||
if 0 == bytes.Compare(local.{{$txt.Function.LocalAssignment}}, foreign.{{$txt.Function.ForeignAssignment}}) {
|
||||
{{else -}}
|
||||
|
|
Loading…
Reference in a new issue