From 08feff45d7fbfb81283f60c24571aaa2e314da96 Mon Sep 17 00:00:00 2001 From: Aaron L Date: Thu, 14 Jul 2016 22:45:24 -0700 Subject: [PATCH] Deal with null values. --- templates_test/relationship_to_one.tpl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/templates_test/relationship_to_one.tpl b/templates_test/relationship_to_one.tpl index 26a26ec..10a6c28 100644 --- a/templates_test/relationship_to_one.tpl +++ b/templates_test/relationship_to_one.tpl @@ -12,12 +12,18 @@ 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) } - local.{{$rel.Function.LocalAssignment}} = foreign.{{$rel.Function.ForeignAssignment}} + local.{{$rel.Function.LocalAssignment}} = foreign.{{$rel.Function.ForeignAssignment}} if err := local.InsertX(tx); err != nil { t.Fatal(err) }