Ensure that relationship structs aren't clobbered

- There was no thought put in if a relationship struct already existed
  when it went to be used a second time so it was being clobbered.
- Fix #39
This commit is contained in:
Aaron L 2016-11-08 18:25:15 -08:00
parent 42681453a9
commit 3046214fb6
3 changed files with 18 additions and 6 deletions

View file

@ -22,11 +22,15 @@ func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singula
args := make([]interface{}, count)
if singular {
object.R = &{{$varNameSingular}}R{}
if object.R == nil {
object.R = &{{$varNameSingular}}R{}
}
args[0] = object.{{$txt.LocalTable.ColumnNameGo}}
} else {
for i, obj := range slice {
obj.R = &{{$varNameSingular}}R{}
if obj.R == nil {
obj.R = &{{$varNameSingular}}R{}
}
args[i] = obj.{{$txt.LocalTable.ColumnNameGo}}
}
}

View file

@ -22,11 +22,15 @@ func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singula
args := make([]interface{}, count)
if singular {
object.R = &{{$varNameSingular}}R{}
if object.R == nil {
object.R = &{{$varNameSingular}}R{}
}
args[0] = object.{{$txt.LocalTable.ColumnNameGo}}
} else {
for i, obj := range slice {
obj.R = &{{$varNameSingular}}R{}
if obj.R == nil {
obj.R = &{{$varNameSingular}}R{}
}
args[i] = obj.{{$txt.LocalTable.ColumnNameGo}}
}
}

View file

@ -23,11 +23,15 @@ func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singula
args := make([]interface{}, count)
if singular {
object.R = &{{$varNameSingular}}R{}
if object.R == nil {
object.R = &{{$varNameSingular}}R{}
}
args[0] = object.{{.Column | titleCase}}
} else {
for i, obj := range slice {
obj.R = &{{$varNameSingular}}R{}
if obj.R == nil {
obj.R = &{{$varNameSingular}}R{}
}
args[i] = obj.{{.Column | titleCase}}
}
}