Fix Find name

This commit is contained in:
Patrick O'brien 2016-09-01 11:16:21 +10:00
parent e33da59f0b
commit 87b1f90c43
3 changed files with 9 additions and 9 deletions
templates
templates_test

View file

@ -5,13 +5,13 @@
{{- $pkNames := $colDefs.Names | stringMap .StringFuncs.camelCase -}} {{- $pkNames := $colDefs.Names | stringMap .StringFuncs.camelCase -}}
{{- $pkArgs := joinSlices " " $pkNames $colDefs.Types | join ", " -}} {{- $pkArgs := joinSlices " " $pkNames $colDefs.Types | join ", " -}}
// {{$tableNameSingular}}FindG retrieves a single record by ID. // {{$tableNameSingular}}FindG retrieves a single record by ID.
func {{$tableNameSingular}}FindG({{$pkArgs}}, selectCols ...string) (*{{$tableNameSingular}}, error) { func Find{{$tableNameSingular}}G({{$pkArgs}}, selectCols ...string) (*{{$tableNameSingular}}, error) {
return {{$tableNameSingular}}Find(boil.GetDB(), {{$pkNames | join ", "}}, selectCols...) return Find{{$tableNameSingular}}(boil.GetDB(), {{$pkNames | join ", "}}, selectCols...)
} }
// {{$tableNameSingular}}FindGP retrieves a single record by ID, and panics on error. // {{$tableNameSingular}}FindGP retrieves a single record by ID, and panics on error.
func {{$tableNameSingular}}FindGP({{$pkArgs}}, selectCols ...string) *{{$tableNameSingular}} { func Find{{$tableNameSingular}}GP({{$pkArgs}}, selectCols ...string) *{{$tableNameSingular}} {
retobj, err := {{$tableNameSingular}}Find(boil.GetDB(), {{$pkNames | join ", "}}, selectCols...) retobj, err := Find{{$tableNameSingular}}(boil.GetDB(), {{$pkNames | join ", "}}, selectCols...)
if err != nil { if err != nil {
panic(boil.WrapErr(err)) panic(boil.WrapErr(err))
} }
@ -21,7 +21,7 @@ func {{$tableNameSingular}}FindGP({{$pkArgs}}, selectCols ...string) *{{$tableNa
// {{$tableNameSingular}}Find retrieves a single record by ID with an executor. // {{$tableNameSingular}}Find retrieves a single record by ID with an executor.
// If selectCols is empty Find will return all columns. // If selectCols is empty Find will return all columns.
func {{$tableNameSingular}}Find(exec boil.Executor, {{$pkArgs}}, selectCols ...string) (*{{$tableNameSingular}}, error) { func Find{{$tableNameSingular}}(exec boil.Executor, {{$pkArgs}}, selectCols ...string) (*{{$tableNameSingular}}, error) {
{{$varNameSingular}}Obj := &{{$tableNameSingular}}{} {{$varNameSingular}}Obj := &{{$tableNameSingular}}{}
sel := "*" sel := "*"
@ -46,8 +46,8 @@ func {{$tableNameSingular}}Find(exec boil.Executor, {{$pkArgs}}, selectCols ...s
} }
// {{$tableNameSingular}}FindP retrieves a single record by ID with an executor, and panics on error. // {{$tableNameSingular}}FindP retrieves a single record by ID with an executor, and panics on error.
func {{$tableNameSingular}}FindP(exec boil.Executor, {{$pkArgs}}, selectCols ...string) *{{$tableNameSingular}} { func Find{{$tableNameSingular}}P(exec boil.Executor, {{$pkArgs}}, selectCols ...string) *{{$tableNameSingular}} {
retobj, err := {{$tableNameSingular}}Find(exec, {{$pkNames | join ", "}}, selectCols...) retobj, err := Find{{$tableNameSingular}}(exec, {{$pkNames | join ", "}}, selectCols...)
if err != nil { if err != nil {
panic(boil.WrapErr(err)) panic(boil.WrapErr(err))
} }

View file

@ -27,7 +27,7 @@ func (o *{{$tableNameSingular}}) ReloadG() error {
// Reload refetches the object from the database // Reload refetches the object from the database
// using the primary keys with an executor. // using the primary keys with an executor.
func (o *{{$tableNameSingular}}) Reload(exec boil.Executor) error { func (o *{{$tableNameSingular}}) Reload(exec boil.Executor) error {
ret, err := {{$tableNameSingular}}Find(exec, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o." | join ", "}}) ret, err := Find{{$tableNameSingular}}(exec, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o." | join ", "}})
if err != nil { if err != nil {
return err return err
} }

View file

@ -18,7 +18,7 @@ func test{{$tableNamePlural}}Find(t *testing.T) {
t.Error(err) t.Error(err)
} }
{{$varNameSingular}}Found, err := {{$tableNameSingular}}Find(tx, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice (printf "%s." $varNameSingular) | join ", "}}) {{$varNameSingular}}Found, err := Find{{$tableNameSingular}}(tx, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice (printf "%s." $varNameSingular) | join ", "}})
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }