diff --git a/templates/07_relationship_to_one_eager.tpl b/templates/07_relationship_to_one_eager.tpl index 43392f0..4af84ca 100644 --- a/templates/07_relationship_to_one_eager.tpl +++ b/templates/07_relationship_to_one_eager.tpl @@ -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 -}} diff --git a/templates/08_relationship_one_to_one_eager.tpl b/templates/08_relationship_one_to_one_eager.tpl index 6603d55..7363b69 100644 --- a/templates/08_relationship_one_to_one_eager.tpl +++ b/templates/08_relationship_one_to_one_eager.tpl @@ -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 -}}