diff --git a/templates/01_types.tpl b/templates/01_types.tpl index 1994e53..19325ed 100644 --- a/templates/01_types.tpl +++ b/templates/01_types.tpl @@ -11,7 +11,7 @@ var ( ) type ( - {{$varNameSingular}}Slice []*{{$tableNameSingular}} + {{$tableNameSingular}}Slice []*{{$tableNameSingular}} {{$tableNameSingular}}Hook func(*{{$tableNameSingular}}) error {{$varNameSingular}}Query struct { diff --git a/templates/03_finishers.tpl b/templates/03_finishers.tpl index 8ce2728..26ad19c 100644 --- a/templates/03_finishers.tpl +++ b/templates/03_finishers.tpl @@ -26,8 +26,8 @@ func (q {{$varNameSingular}}Query) OneP() (*{{$tableNameSingular}}) { } // All returns all {{$tableNameSingular}} records from the query. -func (q {{$varNameSingular}}Query) All() ({{$varNameSingular}}Slice, error) { - var o {{$varNameSingular}}Slice +func (q {{$varNameSingular}}Query) All() ({{$tableNameSingular}}Slice, error) { + var o {{$tableNameSingular}}Slice res, err := boil.ExecQueryAll(q.Query) if err != nil { @@ -44,7 +44,7 @@ func (q {{$varNameSingular}}Query) All() ({{$varNameSingular}}Slice, error) { } // AllP returns all {{$tableNameSingular}} records from the query, and panics on error. -func (q {{$varNameSingular}}Query) AllP() {{$varNameSingular}}Slice { +func (q {{$varNameSingular}}Query) AllP() {{$tableNameSingular}}Slice { o, err := q.All() if err != nil { panic(boil.WrapErr(err)) diff --git a/templates/10_delete.tpl b/templates/10_delete.tpl index 2075181..e959827 100644 --- a/templates/10_delete.tpl +++ b/templates/10_delete.tpl @@ -77,7 +77,7 @@ func (o {{$varNameSingular}}Query) DeleteAllP() { } // DeleteAll deletes all rows in the slice. -func (o {{$varNameSingular}}Slice) DeleteAll() error { +func (o {{$tableNameSingular}}Slice) DeleteAll() error { if o == nil { return errors.New("{{.PkgName}}: no {{$tableNameSingular}} slice provided for delete all") } @@ -85,14 +85,14 @@ func (o {{$varNameSingular}}Slice) DeleteAll() error { } // DeleteAll deletes all rows in the slice. -func (o {{$varNameSingular}}Slice) DeleteAllP() { +func (o {{$tableNameSingular}}Slice) DeleteAllP() { if err := o.DeleteAll(); err != nil { panic(boil.WrapErr(err)) } } // DeleteAllX deletes all rows in the slice with an executor. -func (o {{$varNameSingular}}Slice) DeleteAllX(exec boil.Executor) error { +func (o {{$tableNameSingular}}Slice) DeleteAllX(exec boil.Executor) error { if o == nil { return errors.New("{{.PkgName}}: no {{$tableNameSingular}} slice provided for delete all") } @@ -122,7 +122,7 @@ func (o {{$varNameSingular}}Slice) DeleteAllX(exec boil.Executor) error { } // DeleteAllXP deletes all rows in the slice with an executor, and panics on error. -func (o {{$varNameSingular}}Slice) DeleteAllXP(exec boil.Executor) { +func (o {{$tableNameSingular}}Slice) DeleteAllXP(exec boil.Executor) { if err := o.DeleteAllX(exec); err != nil { panic(boil.WrapErr(err)) } diff --git a/templates/11_helpers.tpl b/templates/11_helpers.tpl index 92c6f75..a9dd023 100644 --- a/templates/11_helpers.tpl +++ b/templates/11_helpers.tpl @@ -10,7 +10,7 @@ func (o {{$tableNameSingular}}) inPrimaryKeyArgs() []interface{} { return args } -func (o {{$varNameSingular}}Slice) inPrimaryKeyArgs() []interface{} { +func (o {{$tableNameSingular}}Slice) inPrimaryKeyArgs() []interface{} { var args []interface{} for i := 0; i < len(o); i++ { diff --git a/templates_test/all.tpl b/templates_test/all.tpl index 9de1d26..7385135 100644 --- a/templates_test/all.tpl +++ b/templates_test/all.tpl @@ -6,7 +6,7 @@ func Test{{$tableNamePlural}}(t *testing.T) { var err error - o := make({{$varNameSingular}}Slice, 2) + o := make({{$tableNameSingular}}Slice, 2) if err = boil.RandomizeSlice(&o, {{$varNameSingular}}DBTypes, true); err != nil { t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err) } @@ -33,7 +33,7 @@ func Test{{$tableNamePlural}}(t *testing.T) { t.Errorf("Expected {{.Table.Name}} table to be empty, but got %d rows", c) } - o = make({{$varNameSingular}}Slice, 3) + o = make({{$tableNameSingular}}Slice, 3) if err = boil.RandomizeSlice(&o, {{$varNameSingular}}DBTypes, true); err != nil { t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err) } diff --git a/templates_test/delete.tpl b/templates_test/delete.tpl index 90f9b74..9a0247a 100644 --- a/templates_test/delete.tpl +++ b/templates_test/delete.tpl @@ -25,7 +25,7 @@ func Test{{$tableNamePlural}}QueryDeleteAll(t *testing.T) { t.Errorf("Expected 0 rows after ObjDeleteAllRows() call, but got %d rows", c) } - o := make({{$varNameSingular}}Slice, 3) + o := make({{$tableNameSingular}}Slice, 3) if err = boil.RandomizeSlice(&o, {{$varNameSingular}}DBTypes, true); err != nil { t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err) } @@ -57,7 +57,7 @@ func Test{{$tableNamePlural}}SliceDeleteAll(t *testing.T) { var c int64 // insert random columns to test DeleteAll - o := make({{$varNameSingular}}Slice, 3) + o := make({{$tableNameSingular}}Slice, 3) if err = boil.RandomizeSlice(&o, {{$varNameSingular}}DBTypes, true); err != nil { t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err) } @@ -87,7 +87,7 @@ func Test{{$tableNamePlural}}Delete(t *testing.T) { var c int64 // insert random columns to test Delete - o := make({{$varNameSingular}}Slice, 3) + o := make({{$tableNameSingular}}Slice, 3) if err = boil.RandomizeSlice(&o, {{$varNameSingular}}DBTypes, true); err != nil { t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err) } diff --git a/templates_test/find.tpl b/templates_test/find.tpl index 12dfc77..5bea308 100644 --- a/templates_test/find.tpl +++ b/templates_test/find.tpl @@ -6,7 +6,7 @@ func Test{{$tableNamePlural}}Find(t *testing.T) { var err error - o := make({{$varNameSingular}}Slice, 3) + o := make({{$tableNameSingular}}Slice, 3) if err = boil.RandomizeSlice(&o, {{$varNameSingular}}DBTypes, true); err != nil { t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err) } @@ -17,7 +17,7 @@ func Test{{$tableNamePlural}}Find(t *testing.T) { } } - j := make({{$varNameSingular}}Slice, 3) + j := make({{$tableNameSingular}}Slice, 3) // Perform all Find queries and assign result objects to slice for comparison for i := 0; i < len(j); i++ { j[i], err = {{$tableNameSingular}}Find({{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o[i]." | join ", "}}) diff --git a/templates_test/finishers.tpl b/templates_test/finishers.tpl index d193fd9..3bd6172 100644 --- a/templates_test/finishers.tpl +++ b/templates_test/finishers.tpl @@ -27,7 +27,7 @@ func Test{{$tableNamePlural}}Bind(t *testing.T) { // insert 3 rows, attempt to bind into slice {{$varNamePlural}}DeleteAllRows(t) - y := make({{$varNameSingular}}Slice, 3) + y := make({{$tableNameSingular}}Slice, 3) if err = boil.RandomizeSlice(&y, {{$varNameSingular}}DBTypes, true); err != nil { t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err) } @@ -40,7 +40,7 @@ func Test{{$tableNamePlural}}Bind(t *testing.T) { } } - k := {{$varNameSingular}}Slice{} + k := {{$tableNameSingular}}Slice{} err = {{$tableNamePlural}}().Bind(&k) if err != nil { t.Errorf("Unable to call Bind on {{$tableNameSingular}} slice of objects: %s", err) @@ -82,7 +82,7 @@ func Test{{$tableNamePlural}}One(t *testing.T) { func Test{{$tableNamePlural}}All(t *testing.T) { var err error - o := make({{$varNameSingular}}Slice, 3) + o := make({{$tableNameSingular}}Slice, 3) if err = boil.RandomizeSlice(&o, {{$varNameSingular}}DBTypes, true); err != nil { t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err) } @@ -114,7 +114,7 @@ func Test{{$tableNamePlural}}All(t *testing.T) { func Test{{$tableNamePlural}}Count(t *testing.T) { var err error - o := make({{$varNameSingular}}Slice, 3) + o := make({{$tableNameSingular}}Slice, 3) if err = boil.RandomizeSlice(&o, {{$varNameSingular}}DBTypes, true); err != nil { t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err) } diff --git a/templates_test/helpers.tpl b/templates_test/helpers.tpl index b4e0992..ab28cf3 100644 --- a/templates_test/helpers.tpl +++ b/templates_test/helpers.tpl @@ -51,7 +51,7 @@ func Test{{$tableNamePlural}}InPrimaryKeyArgs(t *testing.T) { func Test{{$tableNamePlural}}SliceInPrimaryKeyArgs(t *testing.T) { var err error - o := make({{$varNameSingular}}Slice, 3) + o := make({{$tableNameSingular}}Slice, 3) if err = boil.RandomizeSlice(&o, {{$varNameSingular}}DBTypes, true); err != nil { t.Errorf("Could not randomize slice: %s", err) diff --git a/templates_test/insert.tpl b/templates_test/insert.tpl index ad99e7a..2276f7a 100644 --- a/templates_test/insert.tpl +++ b/templates_test/insert.tpl @@ -16,7 +16,7 @@ func Test{{$tableNamePlural}}Insert(t *testing.T) { nullTime := null.NewTime(time.Time{}, true) _ = nullTime - o := make({{$varNameSingular}}Slice, 3) + o := make({{$tableNameSingular}}Slice, 3) if err = boil.RandomizeSlice(&o, {{$varNameSingular}}DBTypes, true); err != nil { t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err) } @@ -27,7 +27,7 @@ func Test{{$tableNamePlural}}Insert(t *testing.T) { } } - j := make({{$varNameSingular}}Slice, 3) + j := make({{$tableNameSingular}}Slice, 3) // Perform all Find queries and assign result objects to slice for comparison for i := 0; i < len(j); i++ { j[i], err = {{$tableNameSingular}}Find({{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o[i]." | join ", "}}) diff --git a/text_helpers.go b/text_helpers.go index ef065e6..58174a8 100644 --- a/text_helpers.go +++ b/text_helpers.go @@ -93,7 +93,7 @@ func textsFromRelationship(tables []bdb.Table, table bdb.Table, rel bdb.ToManyRe r.ForeignTable.NameSingular = strmangle.Singular(rel.ForeignTable) r.ForeignTable.NamePluralGo = strmangle.TitleCase(strmangle.Plural(rel.ForeignTable)) r.ForeignTable.NameGo = strmangle.TitleCase(r.ForeignTable.NameSingular) - r.ForeignTable.Slice = fmt.Sprintf("%sSlice", strmangle.CamelCase(r.ForeignTable.NameSingular)) + r.ForeignTable.Slice = fmt.Sprintf("%sSlice", strmangle.TitleCase(r.ForeignTable.NameSingular)) r.ForeignTable.NameHumanReadable = strings.Replace(rel.ForeignTable, "_", " ", -1) r.Function.Receiver = strings.ToLower(table.Name[:1])