Change objectSlice to be exported (ObjectSlice)

This commit is contained in:
Patrick O'brien 2016-07-17 00:15:14 +10:00
parent 4278d21b37
commit 488e203c0b
11 changed files with 24 additions and 24 deletions

View file

@ -11,7 +11,7 @@ var (
)
type (
{{$varNameSingular}}Slice []*{{$tableNameSingular}}
{{$tableNameSingular}}Slice []*{{$tableNameSingular}}
{{$tableNameSingular}}Hook func(*{{$tableNameSingular}}) error
{{$varNameSingular}}Query struct {

View file

@ -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))

View file

@ -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))
}

View file

@ -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++ {

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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 ", "}})

View file

@ -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)
}

View file

@ -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)

View file

@ -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 ", "}})

View file

@ -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])