Make templates generate again

This commit is contained in:
Aaron L 2016-09-18 16:02:08 -07:00
parent 1eb1ed10cf
commit 34b30ce6c3
12 changed files with 44 additions and 66 deletions

View file

@ -26,15 +26,15 @@ type {{$modelNameCamel}}R struct {
{{$txt.Function.Name}} *{{$txt.ForeignTable.NameGo}} {{$txt.Function.Name}} *{{$txt.ForeignTable.NameGo}}
{{end -}} {{end -}}
{{- range .Table.ToOneRelationships -}} {{range .Table.ToOneRelationships -}}
{{- $txt := txtsFromOneToOne $dot.Tables $dot.Table . -}} {{- $txt := txtsFromOneToOne $dot.Tables $dot.Table . -}}
{{$txt.Function.Name}} *{{$txt.ForeignTable.NameGo}} {{$txt.Function.Name}} *{{$txt.ForeignTable.NameGo}}
{{end -}} {{end -}}
{{- range .Table.ToManyRelationships -}} {{range .Table.ToManyRelationships -}}
{{- $txt := txtsFromToMany $dot.Tables $dot.Table . -}} {{- $txt := txtsFromToMany $dot.Tables $dot.Table . -}}
{{$txt.Function.Name}} {{$txt.ForeignTable.Slice}} {{$txt.Function.Name}} {{$txt.ForeignTable.Slice}}
{{- end -}}{{/* range tomany */}} {{end -}}{{/* range tomany */}}
} }
// {{$modelNameCamel}}L is where Load methods for each relationship are stored. // {{$modelNameCamel}}L is where Load methods for each relationship are stored.

View file

@ -2,8 +2,8 @@
{{- else -}} {{- else -}}
{{- $dot := . -}} {{- $dot := . -}}
{{- range .Table.FKeys -}} {{- range .Table.FKeys -}}
{{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}} {{- $txt := txtsFromFKey $dot.Tables $dot.Table . -}}
{{- $varNameSingular := .ForeignKey.ForeignTable | singular | camelCase -}} {{- $varNameSingular := .ForeignTable | singular | camelCase -}}
// {{$txt.Function.Name}}G pointed to by the foreign key. // {{$txt.Function.Name}}G pointed to by the foreign key.
func ({{$txt.Function.Receiver}} *{{$txt.LocalTable.NameGo}}) {{$txt.Function.Name}}G(mods ...qm.QueryMod) {{$varNameSingular}}Query { func ({{$txt.Function.Receiver}} *{{$txt.LocalTable.NameGo}}) {{$txt.Function.Name}}G(mods ...qm.QueryMod) {{$varNameSingular}}Query {
return {{$txt.Function.Receiver}}.{{$txt.Function.Name}}(boil.GetDB(), mods...) return {{$txt.Function.Receiver}}.{{$txt.Function.Name}}(boil.GetDB(), mods...)

View file

@ -2,7 +2,7 @@
{{- else -}} {{- else -}}
{{- $dot := . -}} {{- $dot := . -}}
{{- range .Table.FKeys -}} {{- range .Table.FKeys -}}
{{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}} {{- $txt := txtsFromFKey $dot.Tables $dot.Table . -}}
{{- $varNameSingular := $dot.Table.Name | singular | camelCase -}} {{- $varNameSingular := $dot.Table.Name | singular | camelCase -}}
{{- $arg := printf "maybe%s" $txt.LocalTable.NameGo -}} {{- $arg := printf "maybe%s" $txt.LocalTable.NameGo -}}
{{- $slice := printf "%sSlice" $txt.LocalTable.NameGo}} {{- $slice := printf "%sSlice" $txt.LocalTable.NameGo}}
@ -30,7 +30,7 @@ func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singula
} }
query := fmt.Sprintf( query := fmt.Sprintf(
"select * from {{.ForeignKey.ForeignTable | $dot.SchemaTable}} where {{.ForeignKey.ForeignColumn | $dot.Quotes}} in (%s)", "select * from {{.ForeignTable | $dot.SchemaTable}} where {{.ForeignColumn | $dot.Quotes}} in (%s)",
strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1), strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
) )
@ -69,7 +69,7 @@ func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singula
for _, foreign := range resultSlice { for _, foreign := range resultSlice {
for _, local := range slice { for _, local := range slice {
{{if .Function.UsesBytes -}} {{if $txt.Function.UsesBytes -}}
if 0 == bytes.Compare(local.{{$txt.Function.LocalAssignment}}, foreign.{{$txt.Function.ForeignAssignment}}) { if 0 == bytes.Compare(local.{{$txt.Function.LocalAssignment}}, foreign.{{$txt.Function.ForeignAssignment}}) {
{{else -}} {{else -}}
if local.{{$txt.Function.LocalAssignment}} == foreign.{{$txt.Function.ForeignAssignment}} { if local.{{$txt.Function.LocalAssignment}} == foreign.{{$txt.Function.ForeignAssignment}} {

View file

@ -3,10 +3,10 @@
{{- else -}} {{- else -}}
{{- $dot := . -}} {{- $dot := . -}}
{{- range .Table.FKeys -}} {{- range .Table.FKeys -}}
{{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}} {{- $txt := txtsFromFKey $dot.Tables $dot.Table . -}}
{{- $varNameSingular := .ForeignKey.ForeignTable | singular | camelCase -}} {{- $varNameSingular := .ForeignTable | singular | camelCase -}}
{{- $localNameSingular := .ForeignKey.Table | singular | camelCase}} {{- $localNameSingular := .Table | singular | camelCase}}
// Set{{$txt.Function.Name}} of the {{.ForeignKey.Table | singular}} to the related item. // Set{{$txt.Function.Name}} of the {{.Table | singular}} to the related item.
// Sets {{$txt.Function.Receiver}}.R.{{$txt.Function.Name}} to related. // Sets {{$txt.Function.Receiver}}.R.{{$txt.Function.Name}} to related.
// Adds {{$txt.Function.Receiver}} to related.R.{{$txt.Function.ForeignName}}. // Adds {{$txt.Function.Receiver}} to related.R.{{$txt.Function.ForeignName}}.
func ({{$txt.Function.Receiver}} *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}(exec boil.Executor, insert bool, related *{{$txt.ForeignTable.NameGo}}) error { func ({{$txt.Function.Receiver}} *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}(exec boil.Executor, insert bool, related *{{$txt.ForeignTable.NameGo}}) error {
@ -20,7 +20,7 @@ func ({{$txt.Function.Receiver}} *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function
oldVal := {{$txt.Function.Receiver}}.{{$txt.Function.LocalAssignment}} oldVal := {{$txt.Function.Receiver}}.{{$txt.Function.LocalAssignment}}
related.{{$txt.Function.ForeignAssignment}} = {{$txt.Function.Receiver}}.{{$txt.Function.LocalAssignment}} related.{{$txt.Function.ForeignAssignment}} = {{$txt.Function.Receiver}}.{{$txt.Function.LocalAssignment}}
{{$txt.Function.Receiver}}.{{$txt.Function.LocalAssignment}} = related.{{$txt.Function.ForeignAssignment}} {{$txt.Function.Receiver}}.{{$txt.Function.LocalAssignment}} = related.{{$txt.Function.ForeignAssignment}}
if err = {{$txt.Function.Receiver}}.Update(exec, "{{.ForeignKey.Column}}"); err != nil { if err = {{$txt.Function.Receiver}}.Update(exec, "{{.Column}}"); err != nil {
{{$txt.Function.Receiver}}.{{$txt.Function.LocalAssignment}} = oldVal {{$txt.Function.Receiver}}.{{$txt.Function.LocalAssignment}} = oldVal
return errors.Wrap(err, "failed to update local table") return errors.Wrap(err, "failed to update local table")
} }
@ -33,7 +33,7 @@ func ({{$txt.Function.Receiver}} *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function
{{$txt.Function.Receiver}}.R.{{$txt.Function.Name}} = related {{$txt.Function.Receiver}}.R.{{$txt.Function.Name}} = related
} }
{{if .ForeignKey.Unique -}} {{if .Unique -}}
if related.R == nil { if related.R == nil {
related.R = &{{$varNameSingular}}R{ related.R = &{{$varNameSingular}}R{
{{$txt.Function.ForeignName}}: {{$txt.Function.Receiver}}, {{$txt.Function.ForeignName}}: {{$txt.Function.Receiver}},
@ -51,13 +51,13 @@ func ({{$txt.Function.Receiver}} *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function
} }
{{end -}} {{end -}}
{{if .ForeignKey.Nullable}} {{if .Nullable}}
{{$txt.Function.Receiver}}.{{$txt.LocalTable.ColumnNameGo}}.Valid = true {{$txt.Function.Receiver}}.{{$txt.LocalTable.ColumnNameGo}}.Valid = true
{{end -}} {{end -}}
return nil return nil
} }
{{- if .ForeignKey.Nullable}} {{- if .Nullable}}
// Remove{{$txt.Function.Name}} relationship. // Remove{{$txt.Function.Name}} relationship.
// Sets {{$txt.Function.Receiver}}.R.{{$txt.Function.Name}} to nil. // Sets {{$txt.Function.Receiver}}.R.{{$txt.Function.Name}} to nil.
// Removes {{$txt.Function.Receiver}} from all passed in related items' relationships struct (Optional). // Removes {{$txt.Function.Receiver}} from all passed in related items' relationships struct (Optional).
@ -65,7 +65,7 @@ func ({{$txt.Function.Receiver}} *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Funct
var err error var err error
{{$txt.Function.Receiver}}.{{$txt.LocalTable.ColumnNameGo}}.Valid = false {{$txt.Function.Receiver}}.{{$txt.LocalTable.ColumnNameGo}}.Valid = false
if err = {{$txt.Function.Receiver}}.Update(exec, "{{.ForeignKey.Column}}"); err != nil { if err = {{$txt.Function.Receiver}}.Update(exec, "{{.Column}}"); err != nil {
{{$txt.Function.Receiver}}.{{$txt.LocalTable.ColumnNameGo}}.Valid = true {{$txt.Function.Receiver}}.{{$txt.LocalTable.ColumnNameGo}}.Valid = true
return errors.Wrap(err, "failed to update local table") return errors.Wrap(err, "failed to update local table")
} }
@ -75,7 +75,7 @@ func ({{$txt.Function.Receiver}} *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Funct
return nil return nil
} }
{{if .ForeignKey.Unique -}} {{if .Unique -}}
related.R.{{$txt.Function.ForeignName}} = nil related.R.{{$txt.Function.ForeignName}} = nil
{{else -}} {{else -}}
for i, ri := range related.R.{{$txt.Function.ForeignName}} { for i, ri := range related.R.{{$txt.Function.ForeignName}} {

View file

@ -28,7 +28,7 @@ func ({{.Function.Receiver}} *{{.LocalTable.NameGo}}) {{.Function.Name}}(exec bo
{{- else -}} {{- else -}}
{{- $dot := . -}} {{- $dot := . -}}
{{- range .Table.FKeys -}} {{- range .Table.FKeys -}}
{{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}} {{- $txt := txtsFromFKey $dot.Tables $dot.Table . -}}
{{- template "relationship_to_one_helper" (preserveDot $dot $txt) -}} {{- template "relationship_to_one_helper" (preserveDot $dot $txt) -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -91,7 +91,7 @@ func ({{$varNameSingular}}L) Load{{.Function.Name}}(e boil.Executor, singular bo
{{- else -}} {{- else -}}
{{- $dot := . -}} {{- $dot := . -}}
{{- range .Table.FKeys -}} {{- range .Table.FKeys -}}
{{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}} {{- $txt := txtsFromFKey $dot.Tables $dot.Table . -}}
{{- template "relationship_to_one_eager_helper" (preserveDot $dot $txt) -}} {{- template "relationship_to_one_eager_helper" (preserveDot $dot $txt) -}}
{{- end -}} {{- end -}}
{{end}} {{end}}

View file

@ -124,7 +124,7 @@ func ({{.Function.Receiver}} *{{.LocalTable.NameGo}}) Remove{{.Function.Name}}(e
{{- else -}} {{- else -}}
{{- $dot := . -}} {{- $dot := . -}}
{{- range .Table.FKeys -}} {{- range .Table.FKeys -}}
{{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}} {{- $txt := txtsFromFKey $dot.Tables $dot.Table . -}}
{{- template "relationship_to_one_setops_helper" (preserveDot $dot $txt) -}} {{- template "relationship_to_one_setops_helper" (preserveDot $dot $txt) -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -70,7 +70,7 @@ func test{{.LocalTable.NameGo}}ToOne{{.ForeignTable.NameGo}}_{{.Function.Name}}(
{{- else -}} {{- else -}}
{{- $dot := . -}} {{- $dot := . -}}
{{- range .Table.FKeys -}} {{- range .Table.FKeys -}}
{{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}} {{- $txt := txtsFromFKey $dot.Tables $dot.Table . -}}
{{- template "relationship_to_one_test_helper" (preserveDot $dot $txt) -}} {{- template "relationship_to_one_test_helper" (preserveDot $dot $txt) -}}
{{end -}} {{end -}}
{{- end -}} {{- end -}}

View file

@ -159,7 +159,7 @@ func test{{.LocalTable.NameGo}}ToOneRemoveOp{{.ForeignTable.NameGo}}_{{.Function
{{- else -}} {{- else -}}
{{- $dot := . -}} {{- $dot := . -}}
{{- range .Table.FKeys -}} {{- range .Table.FKeys -}}
{{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table .}} {{- $txt := txtsFromFKey $dot.Tables $dot.Table .}}
{{template "relationship_to_one_setops_test_helper" (preserveDot $dot $txt) -}} {{template "relationship_to_one_setops_test_helper" (preserveDot $dot $txt) -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -2,30 +2,20 @@
{{- else -}} {{- else -}}
{{- $dot := . -}} {{- $dot := . -}}
{{- range .Table.FKeys -}} {{- range .Table.FKeys -}}
{{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}} {{- $txt := txtsFromFKey $dot.Tables $dot.Table . -}}
func test{{$txt.LocalTable.NameGo}}ToOne{{$txt.ForeignTable.NameGo}}_{{$txt.Function.Name}}(t *testing.T) { func test{{$txt.LocalTable.NameGo}}ToOne{{$txt.ForeignTable.NameGo}}_{{$txt.Function.Name}}(t *testing.T) {
tx := MustTx(boil.Begin()) tx := MustTx(boil.Begin())
defer tx.Rollback() defer tx.Rollback()
var foreign {{$txt.ForeignTable.NameGo}} var foreign {{$txt.ForeignTable.NameGo}}
var local {{$txt.LocalTable.NameGo}} var local {{$txt.LocalTable.NameGo}}
{{if .ForeignKey.Nullable -}} {{if .Nullable -}}
local.{{.ForeignKey.Column | titleCase}}.Valid = true local.{{.Column | titleCase}}.Valid = true
{{end}} {{end}}
{{- if .ForeignKey.ForeignColumnNullable -}} {{- if .ForeignColumnNullable -}}
foreign.{{.ForeignKey.ForeignColumn | titleCase}}.Valid = true foreign.{{.ForeignColumn | titleCase}}.Valid = true
{{end}} {{end}}
{{if not $txt.Function.OneToOne -}}
if err := foreign.Insert(tx); err != nil {
t.Fatal(err)
}
local.{{$txt.Function.LocalAssignment}} = foreign.{{$txt.Function.ForeignAssignment}}
if err := local.Insert(tx); err != nil {
t.Fatal(err)
}
{{else -}}
if err := local.Insert(tx); err != nil { if err := local.Insert(tx); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -34,7 +24,6 @@ func test{{$txt.LocalTable.NameGo}}ToOne{{$txt.ForeignTable.NameGo}}_{{$txt.Func
if err := foreign.Insert(tx); err != nil { if err := foreign.Insert(tx); err != nil {
t.Fatal(err) t.Fatal(err)
} }
{{end -}}
check, err := local.{{$txt.Function.Name}}(tx).One() check, err := local.{{$txt.Function.Name}}(tx).One()
if err != nil { if err != nil {

View file

@ -2,9 +2,9 @@
{{- else -}} {{- else -}}
{{- $dot := . -}} {{- $dot := . -}}
{{- range .Table.FKeys -}} {{- range .Table.FKeys -}}
{{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table .}} {{- $txt := txtsFromFKey $dot.Tables $dot.Table .}}
{{- $varNameSingular := .ForeignKey.Table | singular | camelCase -}} {{- $varNameSingular := .Table | singular | camelCase -}}
{{- $foreignVarNameSingular := .ForeignKey.ForeignTable | singular | camelCase}} {{- $foreignVarNameSingular := .ForeignTable | singular | camelCase}}
func test{{$txt.LocalTable.NameGo}}ToOneSetOp{{$txt.ForeignTable.NameGo}}_{{$txt.Function.Name}}(t *testing.T) { func test{{$txt.LocalTable.NameGo}}ToOneSetOp{{$txt.ForeignTable.NameGo}}_{{$txt.Function.Name}}(t *testing.T) {
var err error var err error
@ -49,23 +49,12 @@ func test{{$txt.LocalTable.NameGo}}ToOneSetOp{{$txt.ForeignTable.NameGo}}_{{$txt
t.Error("relationship struct not set to correct value") t.Error("relationship struct not set to correct value")
} }
{{if $txt.Function.OneToOne -}}
zero := reflect.Zero(reflect.TypeOf(x.{{$txt.Function.ForeignAssignment}}))
reflect.Indirect(reflect.ValueOf(&x.{{$txt.Function.ForeignAssignment}})).Set(zero)
xrel := x.R
if err = x.Reload(tx); err != nil {
t.Fatal("failed to reload", err)
}
x.R = xrel
{{else -}}
zero := reflect.Zero(reflect.TypeOf(a.{{$txt.Function.LocalAssignment}})) zero := reflect.Zero(reflect.TypeOf(a.{{$txt.Function.LocalAssignment}}))
reflect.Indirect(reflect.ValueOf(&a.{{$txt.Function.LocalAssignment}})).Set(zero) reflect.Indirect(reflect.ValueOf(&a.{{$txt.Function.LocalAssignment}})).Set(zero)
if err = a.Reload(tx); err != nil { if err = a.Reload(tx); err != nil {
t.Fatal("failed to reload", err) t.Fatal("failed to reload", err)
} }
{{- end}}
{{if $txt.Function.UsesBytes -}} {{if $txt.Function.UsesBytes -}}
if 0 != bytes.Compare(a.{{$txt.Function.LocalAssignment}}, x.{{$txt.Function.ForeignAssignment}}) { if 0 != bytes.Compare(a.{{$txt.Function.LocalAssignment}}, x.{{$txt.Function.ForeignAssignment}}) {
@ -75,7 +64,7 @@ func test{{$txt.LocalTable.NameGo}}ToOneSetOp{{$txt.ForeignTable.NameGo}}_{{$txt
t.Error("foreign key was wrong value", a.{{$txt.Function.LocalAssignment}}, x.{{$txt.Function.ForeignAssignment}}) t.Error("foreign key was wrong value", a.{{$txt.Function.LocalAssignment}}, x.{{$txt.Function.ForeignAssignment}})
} }
{{if .ForeignKey.Unique -}} {{if .Unique -}}
if x.R.{{$txt.Function.ForeignName}} != &a { if x.R.{{$txt.Function.ForeignName}} != &a {
t.Error("failed to append to foreign relationship struct") t.Error("failed to append to foreign relationship struct")
} }
@ -86,7 +75,7 @@ func test{{$txt.LocalTable.NameGo}}ToOneSetOp{{$txt.ForeignTable.NameGo}}_{{$txt
{{end -}} {{end -}}
} }
} }
{{- if or (.ForeignKey.Nullable) (and $txt.Function.OneToOne .ForeignKey.ForeignColumnNullable)}} {{- if .Nullable}}
func test{{$txt.LocalTable.NameGo}}ToOneRemoveOp{{$txt.ForeignTable.NameGo}}_{{$txt.Function.Name}}(t *testing.T) { func test{{$txt.LocalTable.NameGo}}ToOneRemoveOp{{$txt.ForeignTable.NameGo}}_{{$txt.Function.Name}}(t *testing.T) {
var err error var err error
@ -133,7 +122,7 @@ func test{{$txt.LocalTable.NameGo}}ToOneRemoveOp{{$txt.ForeignTable.NameGo}}_{{$
t.Error("R struct entry should be nil") t.Error("R struct entry should be nil")
} }
{{if .ForeignKey.Unique -}} {{if .Unique -}}
if b.R.{{$txt.Function.ForeignName}} != nil { if b.R.{{$txt.Function.ForeignName}} != nil {
t.Error("failed to remove a from b's relationships") t.Error("failed to remove a from b's relationships")
} }

View file

@ -152,8 +152,8 @@ func TestOneToOne(t *testing.T) {
{{- else -}} {{- else -}}
{{- range $table.ToOneRelationships -}} {{- range $table.ToOneRelationships -}}
{{- $txt := txtsFromOneToOne $dot.Tables $table . -}} {{- $txt := txtsFromOneToOne $dot.Tables $table . -}}
t.Run("{{$txt.LocalTable.NameGo}}ToMany{{$txt.Function.Name}}", test{{$txt.LocalTable.NameGo}}ToMany{{$txt.Function.Name}}) t.Run("{{$txt.LocalTable.NameGo}}To{{$txt.Function.Name}}", test{{$txt.LocalTable.NameGo}}ToMany{{$txt.Function.Name}})
{{- end -}}{{- /* range */ -}} {{end -}}{{- /* range */ -}}
{{- end -}}{{- /* outer if join table */ -}} {{- end -}}{{- /* outer if join table */ -}}
{{- end -}}{{- /* outer tables range */ -}} {{- end -}}{{- /* outer tables range */ -}}
} }
@ -168,8 +168,8 @@ func TestToMany(t *testing.T) {
{{- else -}} {{- else -}}
{{- range $table.ToManyRelationships -}} {{- range $table.ToManyRelationships -}}
{{- $txt := txtsFromToMany $dot.Tables $table . -}} {{- $txt := txtsFromToMany $dot.Tables $table . -}}
t.Run("{{$txt.LocalTable.NameGo}}ToMany{{$txt.Function.Name}}", test{{$txt.LocalTable.NameGo}}ToMany{{$txt.Function.Name}}) t.Run("{{$txt.LocalTable.NameGo}}To{{$txt.Function.Name}}", test{{$txt.LocalTable.NameGo}}ToMany{{$txt.Function.Name}})
{{- end -}}{{- /* range */ -}} {{end -}}{{- /* range */ -}}
{{- end -}}{{- /* outer if join table */ -}} {{- end -}}{{- /* outer if join table */ -}}
{{- end -}}{{- /* outer tables range */ -}} {{- end -}}{{- /* outer tables range */ -}}
} }
@ -219,7 +219,7 @@ func TestOneToOneSet(t *testing.T) {
{{- else -}} {{- else -}}
{{- $txt := txtsFromOneToOne $dot.Tables $table . -}} {{- $txt := txtsFromOneToOne $dot.Tables $table . -}}
t.Run("{{$txt.LocalTable.NameGo}}To{{$txt.Function.Name}}", test{{$txt.LocalTable.NameGo}}OneToOneSetOp{{$txt.Function.Name}}) t.Run("{{$txt.LocalTable.NameGo}}To{{$txt.Function.Name}}", test{{$txt.LocalTable.NameGo}}OneToOneSetOp{{$txt.Function.Name}})
{{- end -}}{{- /* if foreign column nullable */ -}} {{end -}}{{- /* if foreign column nullable */ -}}
{{- end -}}{{- /* range */ -}} {{- end -}}{{- /* range */ -}}
{{- end -}}{{- /* outer if join table */ -}} {{- end -}}{{- /* outer if join table */ -}}
{{- end -}}{{- /* outer tables range */ -}} {{- end -}}{{- /* outer tables range */ -}}
@ -233,12 +233,12 @@ func TestOneToOneRemove(t *testing.T) {
{{- $tableName := $table.Name | plural | titleCase -}} {{- $tableName := $table.Name | plural | titleCase -}}
{{- if $table.IsJoinTable -}} {{- if $table.IsJoinTable -}}
{{- else -}} {{- else -}}
{{- range $table.OneToOneRelationships -}} {{- range $table.ToOneRelationships -}}
{{- if not .ForeignColumnNullable -}} {{- if not .ForeignColumnNullable -}}
{{- else -}} {{- else -}}
{{- $txt := txtsFromOneToOne $dot.Tables $table . -}} {{- $txt := txtsFromOneToOne $dot.Tables $table . -}}
t.Run("{{$txt.LocalTable.NameGo}}To{{$txt.Function.Name}}", test{{$txt.LocalTable.NameGo}}OneToOneRemoveOp{{$txt.Function.Name}}) t.Run("{{$txt.LocalTable.NameGo}}To{{$txt.Function.Name}}", test{{$txt.LocalTable.NameGo}}OneToOneRemoveOp{{$txt.Function.Name}})
{{- end -}}{{- /* if foreign column nullable */ -}} {{end -}}{{- /* if foreign column nullable */ -}}
{{- end -}}{{- /* range */ -}} {{- end -}}{{- /* range */ -}}
{{- end -}}{{- /* outer if join table */ -}} {{- end -}}{{- /* outer if join table */ -}}
{{- end -}}{{- /* outer tables range */ -}} {{- end -}}{{- /* outer tables range */ -}}
@ -255,7 +255,7 @@ func TestToManyAdd(t *testing.T) {
{{- range $table.ToManyRelationships -}} {{- range $table.ToManyRelationships -}}
{{- $txt := txtsFromToMany $dot.Tables $table . -}} {{- $txt := txtsFromToMany $dot.Tables $table . -}}
t.Run("{{$txt.LocalTable.NameGo}}To{{$txt.Function.Name}}", test{{$txt.LocalTable.NameGo}}ToManyAddOp{{$txt.Function.Name}}) t.Run("{{$txt.LocalTable.NameGo}}To{{$txt.Function.Name}}", test{{$txt.LocalTable.NameGo}}ToManyAddOp{{$txt.Function.Name}})
{{- end -}}{{- /* range */ -}} {{end -}}{{- /* range */ -}}
{{- end -}}{{- /* outer if join table */ -}} {{- end -}}{{- /* outer if join table */ -}}
{{- end -}}{{- /* outer tables range */ -}} {{- end -}}{{- /* outer tables range */ -}}
} }
@ -273,7 +273,7 @@ func TestToManySet(t *testing.T) {
{{- else -}} {{- else -}}
{{- $txt := txtsFromToMany $dot.Tables $table . -}} {{- $txt := txtsFromToMany $dot.Tables $table . -}}
t.Run("{{$txt.LocalTable.NameGo}}To{{$txt.Function.Name}}", test{{$txt.LocalTable.NameGo}}ToManySetOp{{$txt.Function.Name}}) t.Run("{{$txt.LocalTable.NameGo}}To{{$txt.Function.Name}}", test{{$txt.LocalTable.NameGo}}ToManySetOp{{$txt.Function.Name}})
{{- end -}}{{- /* if foreign column nullable */ -}} {{end -}}{{- /* if foreign column nullable */ -}}
{{- end -}}{{- /* range */ -}} {{- end -}}{{- /* range */ -}}
{{- end -}}{{- /* outer if join table */ -}} {{- end -}}{{- /* outer if join table */ -}}
{{- end -}}{{- /* outer tables range */ -}} {{- end -}}{{- /* outer tables range */ -}}
@ -292,7 +292,7 @@ func TestToManyRemove(t *testing.T) {
{{- else -}} {{- else -}}
{{- $txt := txtsFromToMany $dot.Tables $table . -}} {{- $txt := txtsFromToMany $dot.Tables $table . -}}
t.Run("{{$txt.LocalTable.NameGo}}To{{$txt.Function.Name}}", test{{$txt.LocalTable.NameGo}}ToManyRemoveOp{{$txt.Function.Name}}) t.Run("{{$txt.LocalTable.NameGo}}To{{$txt.Function.Name}}", test{{$txt.LocalTable.NameGo}}ToManyRemoveOp{{$txt.Function.Name}})
{{- end -}}{{- /* if foreign column nullable */ -}} {{end -}}{{- /* if foreign column nullable */ -}}
{{- end -}}{{- /* range */ -}} {{- end -}}{{- /* range */ -}}
{{- end -}}{{- /* outer if join table */ -}} {{- end -}}{{- /* outer if join table */ -}}
{{- end -}}{{- /* outer tables range */ -}} {{- end -}}{{- /* outer tables range */ -}}