Deal with null values.
This commit is contained in:
parent
95ef4ce74b
commit
08feff45d7
1 changed files with 7 additions and 1 deletions
|
@ -12,6 +12,12 @@ func Test{{$rel.LocalTable.NameGo}}ToOne{{$rel.ForeignTable.NameGo}}_{{$rel.Loca
|
|||
|
||||
var foreign {{$rel.ForeignTable.NameGo}}
|
||||
var local {{$rel.LocalTable.NameGo}}
|
||||
{{if .Nullable -}}
|
||||
local.{{.Column | titleCase}}.Valid = true
|
||||
{{end}}
|
||||
{{- if .ForeignColumnNullable -}}
|
||||
foreign.{{.ForeignColumn | titleCase}}.Valid = true
|
||||
{{end}}
|
||||
|
||||
if err := foreign.InsertX(tx); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
Loading…
Add table
Reference in a new issue