Use the cached relationship information

This commit is contained in:
Aaron L 2016-07-16 13:02:09 -07:00
parent 488e203c0b
commit fc5bbc3e2e
3 changed files with 3 additions and 4 deletions

View file

@ -152,6 +152,5 @@ var templateFunctions = template.FuncMap{
"columnNames": bdb.ColumnNames,
"columnTypes": bdb.ColumnTypes,
"columnDBTypes": bdb.ColumnDBTypes,
"toManyRelationships": bdb.ToManyRelationships,
"defaultValues": bdb.DefaultValues,
}

View file

@ -2,7 +2,7 @@
{{- else -}}
{{- $dot := . }}
{{- $table := .Table }}
{{- range toManyRelationships .Table.Name .Tables -}}
{{- range .Table.ToManyRelationships -}}
{{- $rel := textsFromRelationship $dot.Tables $table . -}}
// {{$rel.Function.Name}} retrieves all the {{$rel.LocalTable.NameSingular}}'s {{$rel.ForeignTable.NameHumanReadable}}
{{- if not (eq $rel.Function.Name $rel.ForeignTable.NamePluralGo)}} via {{.ForeignColumn}} column{{- end}}.

View file

@ -2,7 +2,7 @@
{{- else -}}
{{- $dot := . }}
{{- $table := .Table }}
{{- range toManyRelationships .Table.Name .Tables -}}
{{- range .Table.ToManyRelationships -}}
{{- $rel := textsFromRelationship $dot.Tables $table . -}}
func Test{{$rel.LocalTable.NameGo}}ToMany{{$rel.Function.Name}}(t *testing.T) {
var err error
@ -75,5 +75,5 @@ func Test{{$rel.LocalTable.NameGo}}ToMany{{$rel.Function.Name}}(t *testing.T) {
}
}
{{ end -}}{{- /* range */ -}}
{{end -}}{{- /* range */ -}}
{{- end -}}{{- /* outer if join table */ -}}