From f00230c414995f9fcb160cd430fcc54c29a077b6 Mon Sep 17 00:00:00 2001 From: Aaron L Date: Sun, 18 Sep 2016 11:18:43 -0700 Subject: [PATCH] Fix names of txt helper functions in templates --- templates/04_relationship_to_one.tpl | 2 +- templates/05_relationship_to_many.tpl | 2 +- templates/06_relationship_to_one_eager.tpl | 2 +- templates/07_relationship_to_many_eager.tpl | 2 +- templates/08_relationship_to_one_setops.tpl | 2 +- templates/09_relationship_to_many_setops.tpl | 2 +- templates/relationship_one_to_one.tpl.bak | 2 +- templates/relationship_one_to_one_eager.tpl.bak | 2 +- templates/relationship_one_to_one_setops.tpl.bak | 2 +- templates_test/relationship_one_to_one.tpl.bak | 2 +- templates_test/relationship_one_to_one_setops.tpl.bak | 2 +- templates_test/relationship_to_many.tpl | 2 +- templates_test/relationship_to_many_setops.tpl | 2 +- templates_test/relationship_to_one.tpl | 2 +- templates_test/relationship_to_one_setops.tpl | 2 +- text_helpers.go | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/templates/04_relationship_to_one.tpl b/templates/04_relationship_to_one.tpl index 6b7cf24..e9b9078 100644 --- a/templates/04_relationship_to_one.tpl +++ b/templates/04_relationship_to_one.tpl @@ -2,7 +2,7 @@ {{- else -}} {{- $dot := . -}} {{- range .Table.FKeys -}} - {{- $txt := textsFromForeignKey $dot.PkgName $dot.Tables $dot.Table . -}} + {{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}} {{- $varNameSingular := .ForeignKey.ForeignTable | singular | camelCase -}} // {{$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 { diff --git a/templates/05_relationship_to_many.tpl b/templates/05_relationship_to_many.tpl index 68a5e58..b4f2a86 100644 --- a/templates/05_relationship_to_many.tpl +++ b/templates/05_relationship_to_many.tpl @@ -4,7 +4,7 @@ {{- $table := .Table -}} {{- range .Table.ToManyRelationships -}} {{- $varNameSingular := .ForeignTable | singular | camelCase -}} - {{- $rel := textsFromRelationship $dot.Tables $table . -}} + {{- $rel := txtsFromToMany $dot.Tables $table . -}} {{- $schemaForeignTable := .ForeignTable | $dot.SchemaTable -}} // {{$rel.Function.Name}}G retrieves all the {{$rel.LocalTable.NameSingular}}'s {{$rel.ForeignTable.NameHumanReadable}} {{- if not (eq $rel.Function.Name $rel.ForeignTable.NamePluralGo)}} via {{.ForeignColumn}} column{{- end}}. diff --git a/templates/06_relationship_to_one_eager.tpl b/templates/06_relationship_to_one_eager.tpl index 55d0f47..a3e3f4e 100644 --- a/templates/06_relationship_to_one_eager.tpl +++ b/templates/06_relationship_to_one_eager.tpl @@ -2,7 +2,7 @@ {{- else -}} {{- $dot := . -}} {{- range .Table.FKeys -}} - {{- $txt := textsFromForeignKey $dot.PkgName $dot.Tables $dot.Table . -}} + {{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}} {{- $varNameSingular := $dot.Table.Name | singular | camelCase -}} {{- $arg := printf "maybe%s" $txt.LocalTable.NameGo -}} {{- $slice := printf "%sSlice" $txt.LocalTable.NameGo}} diff --git a/templates/07_relationship_to_many_eager.tpl b/templates/07_relationship_to_many_eager.tpl index 2e7263a..ad931ac 100644 --- a/templates/07_relationship_to_many_eager.tpl +++ b/templates/07_relationship_to_many_eager.tpl @@ -4,7 +4,7 @@ {{- $dot := . -}} {{- range .Table.ToManyRelationships -}} {{- $varNameSingular := $dot.Table.Name | singular | camelCase -}} - {{- $txt := textsFromRelationship $dot.Tables $dot.Table . -}} + {{- $txt := txtsFromToMany $dot.Tables $dot.Table . -}} {{- $arg := printf "maybe%s" $txt.LocalTable.NameGo -}} {{- $slice := printf "%sSlice" $txt.LocalTable.NameGo -}} {{- $schemaForeignTable := .ForeignTable | $dot.SchemaTable}} diff --git a/templates/08_relationship_to_one_setops.tpl b/templates/08_relationship_to_one_setops.tpl index b2c47f9..6dea482 100644 --- a/templates/08_relationship_to_one_setops.tpl +++ b/templates/08_relationship_to_one_setops.tpl @@ -3,7 +3,7 @@ {{- else -}} {{- $dot := . -}} {{- range .Table.FKeys -}} - {{- $txt := textsFromForeignKey $dot.PkgName $dot.Tables $dot.Table . -}} + {{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}} {{- $varNameSingular := .ForeignKey.ForeignTable | singular | camelCase -}} {{- $localNameSingular := .ForeignKey.Table | singular | camelCase}} // Set{{$txt.Function.Name}} of the {{.ForeignKey.Table | singular}} to the related item. diff --git a/templates/09_relationship_to_many_setops.tpl b/templates/09_relationship_to_many_setops.tpl index 2090805..1404d2f 100644 --- a/templates/09_relationship_to_many_setops.tpl +++ b/templates/09_relationship_to_many_setops.tpl @@ -5,7 +5,7 @@ {{- $table := .Table -}} {{- range .Table.ToManyRelationships -}} {{- $varNameSingular := .ForeignTable | singular | camelCase -}} - {{- $rel := textsFromRelationship $dot.Tables $table . -}} + {{- $rel := txtsFromToMany $dot.Tables $table . -}} {{- $localNameSingular := .Table | singular | camelCase -}} {{- $foreignNameSingular := .ForeignTable | singular | camelCase}} // Add{{$rel.Function.Name}} adds the given related objects to the existing relationships diff --git a/templates/relationship_one_to_one.tpl.bak b/templates/relationship_one_to_one.tpl.bak index b956626..171ebd4 100644 --- a/templates/relationship_one_to_one.tpl.bak +++ b/templates/relationship_one_to_one.tpl.bak @@ -28,7 +28,7 @@ func ({{.Function.Receiver}} *{{.LocalTable.NameGo}}) {{.Function.Name}}(exec bo {{- else -}} {{- $dot := . -}} {{- range .Table.FKeys -}} - {{- $txt := textsFromForeignKey $dot.PkgName $dot.Tables $dot.Table . -}} + {{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}} {{- template "relationship_to_one_helper" (preserveDot $dot $txt) -}} {{- end -}} {{- end -}} diff --git a/templates/relationship_one_to_one_eager.tpl.bak b/templates/relationship_one_to_one_eager.tpl.bak index 99fb0cd..ecd94a9 100644 --- a/templates/relationship_one_to_one_eager.tpl.bak +++ b/templates/relationship_one_to_one_eager.tpl.bak @@ -91,7 +91,7 @@ func ({{$varNameSingular}}L) Load{{.Function.Name}}(e boil.Executor, singular bo {{- else -}} {{- $dot := . -}} {{- range .Table.FKeys -}} - {{- $txt := textsFromForeignKey $dot.PkgName $dot.Tables $dot.Table . -}} + {{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}} {{- template "relationship_to_one_eager_helper" (preserveDot $dot $txt) -}} {{- end -}} {{end}} diff --git a/templates/relationship_one_to_one_setops.tpl.bak b/templates/relationship_one_to_one_setops.tpl.bak index e03803d..d75d75b 100644 --- a/templates/relationship_one_to_one_setops.tpl.bak +++ b/templates/relationship_one_to_one_setops.tpl.bak @@ -124,7 +124,7 @@ func ({{.Function.Receiver}} *{{.LocalTable.NameGo}}) Remove{{.Function.Name}}(e {{- else -}} {{- $dot := . -}} {{- range .Table.FKeys -}} - {{- $txt := textsFromForeignKey $dot.PkgName $dot.Tables $dot.Table . -}} + {{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}} {{- template "relationship_to_one_setops_helper" (preserveDot $dot $txt) -}} {{- end -}} {{- end -}} diff --git a/templates_test/relationship_one_to_one.tpl.bak b/templates_test/relationship_one_to_one.tpl.bak index fbced51..508eac8 100644 --- a/templates_test/relationship_one_to_one.tpl.bak +++ b/templates_test/relationship_one_to_one.tpl.bak @@ -70,7 +70,7 @@ func test{{.LocalTable.NameGo}}ToOne{{.ForeignTable.NameGo}}_{{.Function.Name}}( {{- else -}} {{- $dot := . -}} {{- range .Table.FKeys -}} - {{- $txt := textsFromForeignKey $dot.PkgName $dot.Tables $dot.Table . -}} + {{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}} {{- template "relationship_to_one_test_helper" (preserveDot $dot $txt) -}} {{end -}} {{- end -}} diff --git a/templates_test/relationship_one_to_one_setops.tpl.bak b/templates_test/relationship_one_to_one_setops.tpl.bak index f78c261..be4d503 100644 --- a/templates_test/relationship_one_to_one_setops.tpl.bak +++ b/templates_test/relationship_one_to_one_setops.tpl.bak @@ -159,7 +159,7 @@ func test{{.LocalTable.NameGo}}ToOneRemoveOp{{.ForeignTable.NameGo}}_{{.Function {{- else -}} {{- $dot := . -}} {{- range .Table.FKeys -}} - {{- $txt := textsFromForeignKey $dot.PkgName $dot.Tables $dot.Table .}} + {{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table .}} {{template "relationship_to_one_setops_test_helper" (preserveDot $dot $txt) -}} {{- end -}} {{- end -}} diff --git a/templates_test/relationship_to_many.tpl b/templates_test/relationship_to_many.tpl index eaa3516..a238666 100644 --- a/templates_test/relationship_to_many.tpl +++ b/templates_test/relationship_to_many.tpl @@ -3,7 +3,7 @@ {{- $dot := . }} {{- $table := .Table }} {{- range .Table.ToManyRelationships -}} - {{- $rel := textsFromRelationship $dot.Tables $table .}} + {{- $rel := txtsFromToMany $dot.Tables $table .}} func test{{$rel.LocalTable.NameGo}}ToMany{{$rel.Function.Name}}(t *testing.T) { var err error tx := MustTx(boil.Begin()) diff --git a/templates_test/relationship_to_many_setops.tpl b/templates_test/relationship_to_many_setops.tpl index 9262140..a248cc6 100644 --- a/templates_test/relationship_to_many_setops.tpl +++ b/templates_test/relationship_to_many_setops.tpl @@ -5,7 +5,7 @@ {{- range .Table.ToManyRelationships -}} {{- $varNameSingular := .Table | singular | camelCase -}} {{- $foreignVarNameSingular := .ForeignTable | singular | camelCase -}} - {{- $rel := textsFromRelationship $dot.Tables $table .}} + {{- $rel := txtsFromToMany $dot.Tables $table .}} func test{{$rel.LocalTable.NameGo}}ToManyAddOp{{$rel.Function.Name}}(t *testing.T) { var err error diff --git a/templates_test/relationship_to_one.tpl b/templates_test/relationship_to_one.tpl index be91d50..21a0b34 100644 --- a/templates_test/relationship_to_one.tpl +++ b/templates_test/relationship_to_one.tpl @@ -2,7 +2,7 @@ {{- else -}} {{- $dot := . -}} {{- range .Table.FKeys -}} - {{- $txt := textsFromForeignKey $dot.PkgName $dot.Tables $dot.Table . -}} + {{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table . -}} func test{{$txt.LocalTable.NameGo}}ToOne{{$txt.ForeignTable.NameGo}}_{{$txt.Function.Name}}(t *testing.T) { tx := MustTx(boil.Begin()) defer tx.Rollback() diff --git a/templates_test/relationship_to_one_setops.tpl b/templates_test/relationship_to_one_setops.tpl index 0105052..4fde062 100644 --- a/templates_test/relationship_to_one_setops.tpl +++ b/templates_test/relationship_to_one_setops.tpl @@ -2,7 +2,7 @@ {{- else -}} {{- $dot := . -}} {{- range .Table.FKeys -}} - {{- $txt := textsFromForeignKey $dot.PkgName $dot.Tables $dot.Table .}} + {{- $txt := txtsFromFKey $dot.PkgName $dot.Tables $dot.Table .}} {{- $varNameSingular := .ForeignKey.Table | singular | camelCase -}} {{- $foreignVarNameSingular := .ForeignKey.ForeignTable | singular | camelCase}} func test{{$txt.LocalTable.NameGo}}ToOneSetOp{{$txt.ForeignTable.NameGo}}_{{$txt.Function.Name}}(t *testing.T) { diff --git a/text_helpers.go b/text_helpers.go index faff7ad..f71bec3 100644 --- a/text_helpers.go +++ b/text_helpers.go @@ -141,7 +141,7 @@ type TxtToMany struct { } } -// textsFromRelationship creates a struct that does a lot of the text +// txtsFromToMany creates a struct that does a lot of the text // transformation in advance for a given relationship. func txtsFromToMany(tables []bdb.Table, table bdb.Table, rel bdb.ToManyRelationship) TxtToMany { r := TxtToMany{}