switch to our errors package
This commit is contained in:
parent
0b0a1f21c2
commit
e4a52e21b6
27 changed files with 190 additions and 236 deletions
|
@ -1,23 +0,0 @@
|
|||
package boil
|
||||
|
||||
type boilErr struct {
|
||||
error
|
||||
}
|
||||
|
||||
// WrapErr wraps err in a boilErr
|
||||
func WrapErr(err error) error {
|
||||
return boilErr{
|
||||
error: err,
|
||||
}
|
||||
}
|
||||
|
||||
// Error returns the underlying error string
|
||||
func (e boilErr) Error() string {
|
||||
return e.error.Error()
|
||||
}
|
||||
|
||||
// IsBoilErr checks if err is a boilErr
|
||||
func IsBoilErr(err error) bool {
|
||||
_, ok := err.(boilErr)
|
||||
return ok
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package boil
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestErrors(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
err := errors.New("test error")
|
||||
if IsBoilErr(err) == true {
|
||||
t.Errorf("Expected false")
|
||||
}
|
||||
|
||||
err = WrapErr(errors.New("test error"))
|
||||
if err.Error() != "test error" {
|
||||
t.Errorf(`Expected "test error", got %v`, err.Error())
|
||||
}
|
||||
|
||||
if IsBoilErr(err) != true {
|
||||
t.Errorf("Expected true")
|
||||
}
|
||||
}
|
|
@ -170,12 +170,12 @@ func newImporter() importer {
|
|||
`"time"`,
|
||||
},
|
||||
thirdParty: importList{
|
||||
`"github.com/lbryio/errors.go"`,
|
||||
`"github.com/lbryio/null.go"`,
|
||||
`"github.com/lbryio/sqlboiler/boil"`,
|
||||
`"github.com/lbryio/sqlboiler/queries"`,
|
||||
`"github.com/lbryio/sqlboiler/queries/qm"`,
|
||||
`"github.com/lbryio/sqlboiler/strmangle"`,
|
||||
`"github.com/pkg/errors"`,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -185,16 +185,16 @@ func newImporter() importer {
|
|||
`"fmt"`,
|
||||
},
|
||||
thirdParty: importList{
|
||||
`"github.com/lbryio/errors.go"`,
|
||||
`"github.com/lbryio/sqlboiler/boil"`,
|
||||
`"github.com/lbryio/sqlboiler/queries"`,
|
||||
`"github.com/lbryio/sqlboiler/queries/qm"`,
|
||||
`"github.com/lbryio/sqlboiler/strmangle"`,
|
||||
`"github.com/pkg/errors"`,
|
||||
},
|
||||
},
|
||||
"boil_types": {
|
||||
thirdParty: importList{
|
||||
`"github.com/pkg/errors"`,
|
||||
`"github.com/lbryio/errors.go"`,
|
||||
`"github.com/lbryio/sqlboiler/strmangle"`,
|
||||
},
|
||||
},
|
||||
|
@ -227,9 +227,9 @@ func newImporter() importer {
|
|||
},
|
||||
thirdParty: importList{
|
||||
`"github.com/kat-co/vala"`,
|
||||
`"github.com/pkg/errors"`,
|
||||
`"github.com/spf13/viper"`,
|
||||
`"github.com/lbryio/errors.go"`,
|
||||
`"github.com/lbryio/sqlboiler/boil"`,
|
||||
`"github.com/spf13/viper"`,
|
||||
},
|
||||
},
|
||||
"boil_queries_test": {
|
||||
|
@ -265,11 +265,11 @@ func newImporter() importer {
|
|||
`"strings"`,
|
||||
},
|
||||
thirdParty: importList{
|
||||
`"github.com/pkg/errors"`,
|
||||
`"github.com/spf13/viper"`,
|
||||
`"github.com/lbryio/errors.go"`,
|
||||
`"github.com/lbryio/sqlboiler/bdb/drivers"`,
|
||||
`"github.com/lbryio/sqlboiler/randomize"`,
|
||||
`_ "github.com/lib/pq"`,
|
||||
`"github.com/spf13/viper"`,
|
||||
},
|
||||
},
|
||||
"mysql": {
|
||||
|
@ -284,11 +284,11 @@ func newImporter() importer {
|
|||
`"strings"`,
|
||||
},
|
||||
thirdParty: importList{
|
||||
`"github.com/pkg/errors"`,
|
||||
`"github.com/spf13/viper"`,
|
||||
`_ "github.com/go-sql-driver/mysql"`,
|
||||
`"github.com/lbryio/errors.go"`,
|
||||
`"github.com/lbryio/sqlboiler/bdb/drivers"`,
|
||||
`"github.com/lbryio/sqlboiler/randomize"`,
|
||||
`_ "github.com/go-sql-driver/mysql"`,
|
||||
`"github.com/spf13/viper"`,
|
||||
},
|
||||
},
|
||||
"mssql": {
|
||||
|
@ -301,11 +301,11 @@ func newImporter() importer {
|
|||
`"strings"`,
|
||||
},
|
||||
thirdParty: importList{
|
||||
`"github.com/pkg/errors"`,
|
||||
`"github.com/spf13/viper"`,
|
||||
`_ "github.com/denisenkom/go-mssqldb"`,
|
||||
`"github.com/lbryio/errors.go"`,
|
||||
`"github.com/lbryio/sqlboiler/bdb/drivers"`,
|
||||
`"github.com/lbryio/sqlboiler/randomize"`,
|
||||
`_ "github.com/denisenkom/go-mssqldb"`,
|
||||
`"github.com/spf13/viper"`,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/lbryio/errors.go"
|
||||
"github.com/lbryio/sqlboiler/boil"
|
||||
)
|
||||
|
||||
|
@ -136,7 +137,7 @@ func (q *Query) Query() (*sql.Rows, error) {
|
|||
func (q *Query) ExecP() sql.Result {
|
||||
res, err := q.Exec()
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
|
||||
return res
|
||||
|
@ -147,7 +148,7 @@ func (q *Query) ExecP() sql.Result {
|
|||
func (q *Query) QueryP() *sql.Rows {
|
||||
rows, err := q.Query()
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
|
||||
return rows
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/lbryio/sqlboiler/boil"
|
||||
"github.com/lbryio/sqlboiler/strmangle"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -41,7 +41,7 @@ const (
|
|||
// It panics on error. See boil.Bind() documentation.
|
||||
func (q *Query) BindP(obj interface{}) {
|
||||
if err := q.Bind(obj); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.WithStack(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ var {{$varNameSingular}}AfterUpsertHooks []{{$tableNameSingular}}Hook
|
|||
func (o *{{$tableNameSingular}}) doBeforeInsertHooks(exec boil.Executor) (err error) {
|
||||
for _, hook := range {{$varNameSingular}}BeforeInsertHooks {
|
||||
if err := hook(exec, o); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ func (o *{{$tableNameSingular}}) doBeforeInsertHooks(exec boil.Executor) (err er
|
|||
func (o *{{$tableNameSingular}}) doBeforeUpdateHooks(exec boil.Executor) (err error) {
|
||||
for _, hook := range {{$varNameSingular}}BeforeUpdateHooks {
|
||||
if err := hook(exec, o); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ func (o *{{$tableNameSingular}}) doBeforeUpdateHooks(exec boil.Executor) (err er
|
|||
func (o *{{$tableNameSingular}}) doBeforeDeleteHooks(exec boil.Executor) (err error) {
|
||||
for _, hook := range {{$varNameSingular}}BeforeDeleteHooks {
|
||||
if err := hook(exec, o); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ func (o *{{$tableNameSingular}}) doBeforeDeleteHooks(exec boil.Executor) (err er
|
|||
func (o *{{$tableNameSingular}}) doBeforeUpsertHooks(exec boil.Executor) (err error) {
|
||||
for _, hook := range {{$varNameSingular}}BeforeUpsertHooks {
|
||||
if err := hook(exec, o); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ func (o *{{$tableNameSingular}}) doBeforeUpsertHooks(exec boil.Executor) (err er
|
|||
func (o *{{$tableNameSingular}}) doAfterInsertHooks(exec boil.Executor) (err error) {
|
||||
for _, hook := range {{$varNameSingular}}AfterInsertHooks {
|
||||
if err := hook(exec, o); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ func (o *{{$tableNameSingular}}) doAfterInsertHooks(exec boil.Executor) (err err
|
|||
func (o *{{$tableNameSingular}}) doAfterSelectHooks(exec boil.Executor) (err error) {
|
||||
for _, hook := range {{$varNameSingular}}AfterSelectHooks {
|
||||
if err := hook(exec, o); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ func (o *{{$tableNameSingular}}) doAfterSelectHooks(exec boil.Executor) (err err
|
|||
func (o *{{$tableNameSingular}}) doAfterUpdateHooks(exec boil.Executor) (err error) {
|
||||
for _, hook := range {{$varNameSingular}}AfterUpdateHooks {
|
||||
if err := hook(exec, o); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ func (o *{{$tableNameSingular}}) doAfterUpdateHooks(exec boil.Executor) (err err
|
|||
func (o *{{$tableNameSingular}}) doAfterDeleteHooks(exec boil.Executor) (err error) {
|
||||
for _, hook := range {{$varNameSingular}}AfterDeleteHooks {
|
||||
if err := hook(exec, o); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ func (o *{{$tableNameSingular}}) doAfterDeleteHooks(exec boil.Executor) (err err
|
|||
func (o *{{$tableNameSingular}}) doAfterUpsertHooks(exec boil.Executor) (err error) {
|
||||
for _, hook := range {{$varNameSingular}}AfterUpsertHooks {
|
||||
if err := hook(exec, o); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
func (q {{$tableNameSingular}}Query) OneP() (*{{$tableNameSingular}}) {
|
||||
o, err := q.One()
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
|
||||
return o
|
||||
|
@ -18,10 +18,10 @@ func (q {{$tableNameSingular}}Query) One() (*{{$tableNameSingular}}, error) {
|
|||
|
||||
err := q.Bind(o)
|
||||
if err != nil {
|
||||
if errors.Cause(err) == sql.ErrNoRows {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, errors.Wrap(err, "{{.PkgName}}: failed to execute a one query for {{.Table.Name}}")
|
||||
return nil, errors.Prefix("{{.PkgName}}: failed to execute a one query for {{.Table.Name}}", err)
|
||||
}
|
||||
|
||||
{{if not .NoHooks -}}
|
||||
|
@ -37,7 +37,7 @@ func (q {{$tableNameSingular}}Query) One() (*{{$tableNameSingular}}, error) {
|
|||
func (q {{$tableNameSingular}}Query) AllP() {{$tableNameSingular}}Slice {
|
||||
o, err := q.All()
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
|
||||
return o
|
||||
|
@ -49,7 +49,7 @@ func (q {{$tableNameSingular}}Query) All() ({{$tableNameSingular}}Slice, error)
|
|||
|
||||
err := q.Bind(&o)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "{{.PkgName}}: failed to assign all query results to {{$tableNameSingular}} slice")
|
||||
return nil, errors.Prefix("{{.PkgName}}: failed to assign all query results to {{$tableNameSingular}} slice", err)
|
||||
}
|
||||
|
||||
{{if not .NoHooks -}}
|
||||
|
@ -69,7 +69,7 @@ func (q {{$tableNameSingular}}Query) All() ({{$tableNameSingular}}Slice, error)
|
|||
func (q {{$tableNameSingular}}Query) CountP() int64 {
|
||||
c, err := q.Count()
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
|
||||
return c
|
||||
|
@ -84,7 +84,7 @@ func (q {{$tableNameSingular}}Query) Count() (int64, error) {
|
|||
|
||||
err := q.Query.QueryRow().Scan(&count)
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "{{.PkgName}}: failed to count {{.Table.Name}} rows")
|
||||
return 0, errors.Prefix("{{.PkgName}}: failed to count {{.Table.Name}} rows", err)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
|
@ -94,7 +94,7 @@ func (q {{$tableNameSingular}}Query) Count() (int64, error) {
|
|||
func (q {{$tableNameSingular}}Query) ExistsP() bool {
|
||||
e, err := q.Exists()
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
|
||||
return e
|
||||
|
@ -110,7 +110,7 @@ func (q {{$tableNameSingular}}Query) Exists() (bool, error) {
|
|||
|
||||
err := q.Query.QueryRow().Scan(&count)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "{{.PkgName}}: failed to check if {{.Table.Name}} exists")
|
||||
return false, errors.Prefix("{{.PkgName}}: failed to check if {{.Table.Name}} exists", err)
|
||||
}
|
||||
|
||||
return count > 0, nil
|
||||
|
|
|
@ -45,20 +45,20 @@ func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singula
|
|||
|
||||
results, err := e.Query(query, args...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to eager load {{$txt.ForeignTable.NameGo}}")
|
||||
return errors.Prefix("failed to eager load {{$txt.ForeignTable.NameGo}}", err)
|
||||
}
|
||||
defer results.Close()
|
||||
|
||||
var resultSlice []*{{$txt.ForeignTable.NameGo}}
|
||||
if err = queries.Bind(results, &resultSlice); err != nil {
|
||||
return errors.Wrap(err, "failed to bind eager loaded slice {{$txt.ForeignTable.NameGo}}")
|
||||
return errors.Prefix("failed to bind eager loaded slice {{$txt.ForeignTable.NameGo}}", err)
|
||||
}
|
||||
|
||||
{{if not $dot.NoHooks -}}
|
||||
if len({{$varNameSingular}}AfterSelectHooks) != 0 {
|
||||
for _, obj := range resultSlice {
|
||||
if err := obj.doAfterSelectHooks(e); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,20 +45,20 @@ func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singula
|
|||
|
||||
results, err := e.Query(query, args...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to eager load {{$txt.ForeignTable.NameGo}}")
|
||||
return errors.Prefix("failed to eager load {{$txt.ForeignTable.NameGo}}", err)
|
||||
}
|
||||
defer results.Close()
|
||||
|
||||
var resultSlice []*{{$txt.ForeignTable.NameGo}}
|
||||
if err = queries.Bind(results, &resultSlice); err != nil {
|
||||
return errors.Wrap(err, "failed to bind eager loaded slice {{$txt.ForeignTable.NameGo}}")
|
||||
return errors.Prefix("failed to bind eager loaded slice {{$txt.ForeignTable.NameGo}}", err)
|
||||
}
|
||||
|
||||
{{if not $dot.NoHooks -}}
|
||||
if len({{$varNameSingular}}AfterSelectHooks) != 0 {
|
||||
for _, obj := range resultSlice {
|
||||
if err := obj.doAfterSelectHooks(e); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singula
|
|||
|
||||
results, err := e.Query(query, args...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to eager load {{.ForeignTable}}")
|
||||
return errors.Prefix("failed to eager load {{.ForeignTable}}", err)
|
||||
}
|
||||
defer results.Close()
|
||||
|
||||
|
@ -70,7 +70,7 @@ func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singula
|
|||
|
||||
err = results.Scan({{$foreignTable.Columns | columnNames | stringMap $dot.StringFuncs.titleCase | prefixStringSlice "&one." | join ", "}}, &localJoinCol)
|
||||
if err = results.Err(); err != nil {
|
||||
return errors.Wrap(err, "failed to plebian-bind eager loaded slice {{.ForeignTable}}")
|
||||
return errors.Prefix("failed to plebian-bind eager loaded slice {{.ForeignTable}}", err)
|
||||
}
|
||||
|
||||
resultSlice = append(resultSlice, one)
|
||||
|
@ -78,11 +78,11 @@ func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singula
|
|||
}
|
||||
|
||||
if err = results.Err(); err != nil {
|
||||
return errors.Wrap(err, "failed to plebian-bind eager loaded slice {{.ForeignTable}}")
|
||||
return errors.Prefix("failed to plebian-bind eager loaded slice {{.ForeignTable}}", err)
|
||||
}
|
||||
{{else -}}
|
||||
if err = queries.Bind(results, &resultSlice); err != nil {
|
||||
return errors.Wrap(err, "failed to bind eager loaded slice {{.ForeignTable}}")
|
||||
return errors.Prefix("failed to bind eager loaded slice {{.ForeignTable}}", err)
|
||||
}
|
||||
{{end}}
|
||||
|
||||
|
@ -90,7 +90,7 @@ func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singula
|
|||
if len({{.ForeignTable | singular | camelCase}}AfterSelectHooks) != 0 {
|
||||
for _, obj := range resultSlice {
|
||||
if err := obj.doAfterSelectHooks(e); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}G(insert bool, rel
|
|||
// Panics on error.
|
||||
func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}P(exec boil.Executor, insert bool, related *{{$txt.ForeignTable.NameGo}}) {
|
||||
if err := o.Set{{$txt.Function.Name}}(exec, insert, related); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}P(exec boil.Execut
|
|||
// Uses the global database handle and panics on error.
|
||||
func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}GP(insert bool, related *{{$txt.ForeignTable.NameGo}}) {
|
||||
if err := o.Set{{$txt.Function.Name}}(boil.GetDB(), insert, related); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}(exec boil.Executo
|
|||
var err error
|
||||
if insert {
|
||||
if err = related.Insert(exec); err != nil {
|
||||
return errors.Wrap(err, "failed to insert into foreign table")
|
||||
return errors.Prefix("failed to insert into foreign table", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}(exec boil.Executo
|
|||
}
|
||||
|
||||
if _, err = exec.Exec(updateQuery, values...); err != nil {
|
||||
return errors.Wrap(err, "failed to update local table")
|
||||
return errors.Prefix("failed to update local table", err)
|
||||
}
|
||||
|
||||
o.{{$txt.Function.LocalAssignment}} = related.{{$txt.Function.ForeignAssignment}}
|
||||
|
@ -110,7 +110,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}G(related *{{$t
|
|||
// Panics on error.
|
||||
func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}P(exec boil.Executor, related *{{$txt.ForeignTable.NameGo}}) {
|
||||
if err := o.Remove{{$txt.Function.Name}}(exec, related); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}P(exec boil.Exe
|
|||
// Uses the global database handle and panics on error.
|
||||
func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}GP(related *{{$txt.ForeignTable.NameGo}}) {
|
||||
if err := o.Remove{{$txt.Function.Name}}(boil.GetDB(), related); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}(exec boil.Exec
|
|||
o.{{$txt.LocalTable.ColumnNameGo}}.Valid = false
|
||||
if err = o.Update(exec, "{{.Column}}"); err != nil {
|
||||
o.{{$txt.LocalTable.ColumnNameGo}}.Valid = true
|
||||
return errors.Wrap(err, "failed to update local table")
|
||||
return errors.Prefix("failed to update local table", err)
|
||||
}
|
||||
|
||||
o.R.{{$txt.Function.Name}} = nil
|
||||
|
|
|
@ -21,7 +21,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}G(insert bool, rel
|
|||
// Panics on error.
|
||||
func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}P(exec boil.Executor, insert bool, related *{{$txt.ForeignTable.NameGo}}) {
|
||||
if err := o.Set{{$txt.Function.Name}}(exec, insert, related); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}P(exec boil.Execut
|
|||
// Uses the global database handle and panics on error.
|
||||
func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}GP(insert bool, related *{{$txt.ForeignTable.NameGo}}) {
|
||||
if err := o.Set{{$txt.Function.Name}}(boil.GetDB(), insert, related); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}(exec boil.Executo
|
|||
{{- end}}
|
||||
|
||||
if err = related.Insert(exec); err != nil {
|
||||
return errors.Wrap(err, "failed to insert into foreign table")
|
||||
return errors.Prefix("failed to insert into foreign table", err)
|
||||
}
|
||||
} else {
|
||||
updateQuery := fmt.Sprintf(
|
||||
|
@ -64,7 +64,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}(exec boil.Executo
|
|||
}
|
||||
|
||||
if _, err = exec.Exec(updateQuery, values...); err != nil {
|
||||
return errors.Wrap(err, "failed to update foreign table")
|
||||
return errors.Prefix("failed to update foreign table", err)
|
||||
}
|
||||
|
||||
related.{{$txt.Function.ForeignAssignment}} = o.{{$txt.Function.LocalAssignment}}
|
||||
|
@ -107,7 +107,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}G(related *{{$t
|
|||
// Panics on error.
|
||||
func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}P(exec boil.Executor, related *{{$txt.ForeignTable.NameGo}}) {
|
||||
if err := o.Remove{{$txt.Function.Name}}(exec, related); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}P(exec boil.Exe
|
|||
// Uses the global database handle and panics on error.
|
||||
func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}GP(related *{{$txt.ForeignTable.NameGo}}) {
|
||||
if err := o.Remove{{$txt.Function.Name}}(boil.GetDB(), related); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}(exec boil.Exec
|
|||
related.{{$txt.ForeignTable.ColumnNameGo}}.Valid = false
|
||||
if err = related.Update(exec, "{{.ForeignColumn}}"); err != nil {
|
||||
related.{{$txt.ForeignTable.ColumnNameGo}}.Valid = true
|
||||
return errors.Wrap(err, "failed to update local table")
|
||||
return errors.Prefix("failed to update local table", err)
|
||||
}
|
||||
|
||||
o.R.{{$txt.Function.Name}} = nil
|
||||
|
|
|
@ -24,7 +24,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Add{{$txt.Function.Name}}G(insert bool, rel
|
|||
// Panics on error.
|
||||
func (o *{{$txt.LocalTable.NameGo}}) Add{{$txt.Function.Name}}P(exec boil.Executor, insert bool, related ...*{{$txt.ForeignTable.NameGo}}) {
|
||||
if err := o.Add{{$txt.Function.Name}}(exec, insert, related...); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Add{{$txt.Function.Name}}P(exec boil.Execut
|
|||
// Uses the global database handle and panics on error.
|
||||
func (o *{{$txt.LocalTable.NameGo}}) Add{{$txt.Function.Name}}GP(insert bool, related ...*{{$txt.ForeignTable.NameGo}}) {
|
||||
if err := o.Add{{$txt.Function.Name}}(boil.GetDB(), insert, related...); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Add{{$txt.Function.Name}}(exec boil.Executo
|
|||
{{end -}}
|
||||
|
||||
if err = rel.Insert(exec); err != nil {
|
||||
return errors.Wrap(err, "failed to insert into foreign table")
|
||||
return errors.Prefix("failed to insert into foreign table", err)
|
||||
}
|
||||
}{{if not .ToJoinTable}} else {
|
||||
updateQuery := fmt.Sprintf(
|
||||
|
@ -71,7 +71,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Add{{$txt.Function.Name}}(exec boil.Executo
|
|||
}
|
||||
|
||||
if _, err = exec.Exec(updateQuery, values...); err != nil {
|
||||
return errors.Wrap(err, "failed to update foreign table")
|
||||
return errors.Prefix("failed to update foreign table", err)
|
||||
}
|
||||
|
||||
rel.{{$txt.Function.ForeignAssignment}} = o.{{$txt.Function.LocalAssignment}}
|
||||
|
@ -93,7 +93,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Add{{$txt.Function.Name}}(exec boil.Executo
|
|||
|
||||
_, err = exec.Exec(query, values...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to insert into join table")
|
||||
return errors.Prefix("failed to insert into join table", err)
|
||||
}
|
||||
}
|
||||
{{end -}}
|
||||
|
@ -152,7 +152,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}G(insert bool, rel
|
|||
// Panics on error.
|
||||
func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}P(exec boil.Executor, insert bool, related ...*{{$txt.ForeignTable.NameGo}}) {
|
||||
if err := o.Set{{$txt.Function.Name}}(exec, insert, related...); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}P(exec boil.Execut
|
|||
// Uses the global database handle and panics on error.
|
||||
func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}GP(insert bool, related ...*{{$txt.ForeignTable.NameGo}}) {
|
||||
if err := o.Set{{$txt.Function.Name}}(boil.GetDB(), insert, related...); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}(exec boil.Executo
|
|||
|
||||
_, err := exec.Exec(query, values...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to remove relationships before set")
|
||||
return errors.Prefix("failed to remove relationships before set", err)
|
||||
}
|
||||
|
||||
{{if .ToJoinTable -}}
|
||||
|
@ -230,7 +230,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}G(related ...*{
|
|||
// Panics on error.
|
||||
func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}P(exec boil.Executor, related ...*{{$txt.ForeignTable.NameGo}}) {
|
||||
if err := o.Remove{{$txt.Function.Name}}(exec, related...); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}P(exec boil.Exe
|
|||
// Uses the global database handle and panics on error.
|
||||
func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}GP(related ...*{{$txt.ForeignTable.NameGo}}) {
|
||||
if err := o.Remove{{$txt.Function.Name}}(boil.GetDB(), related...); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}(exec boil.Exec
|
|||
|
||||
_, err = exec.Exec(query, values...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to remove relationships before set")
|
||||
return errors.Prefix("failed to remove relationships before set", err)
|
||||
}
|
||||
{{else -}}
|
||||
for _, rel := range related {
|
||||
|
@ -277,7 +277,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}(exec boil.Exec
|
|||
}
|
||||
{{end -}}
|
||||
if err = rel.Update(exec, "{{.ForeignColumn}}"); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
{{end -}}
|
||||
|
|
|
@ -12,7 +12,7 @@ func Find{{$tableNameSingular}}G({{$pkArgs}}, selectCols ...string) (*{{$tableNa
|
|||
func Find{{$tableNameSingular}}GP({{$pkArgs}}, selectCols ...string) *{{$tableNameSingular}} {
|
||||
retobj, err := Find{{$tableNameSingular}}(boil.GetDB(), {{$pkNames | join ", "}}, selectCols...)
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
|
||||
return retobj
|
||||
|
@ -35,10 +35,10 @@ func Find{{$tableNameSingular}}(exec boil.Executor, {{$pkArgs}}, selectCols ...s
|
|||
|
||||
err := q.Bind({{$varNameSingular}}Obj)
|
||||
if err != nil {
|
||||
if errors.Cause(err) == sql.ErrNoRows {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, errors.Wrap(err, "{{.PkgName}}: unable to select from {{.Table.Name}}")
|
||||
return nil, errors.Prefix("{{.PkgName}}: unable to select from {{.Table.Name}}", err)
|
||||
}
|
||||
|
||||
return {{$varNameSingular}}Obj, nil
|
||||
|
@ -48,7 +48,7 @@ func Find{{$tableNameSingular}}(exec boil.Executor, {{$pkArgs}}, selectCols ...s
|
|||
func Find{{$tableNameSingular}}P(exec boil.Executor, {{$pkArgs}}, selectCols ...string) *{{$tableNameSingular}} {
|
||||
retobj, err := Find{{$tableNameSingular}}(exec, {{$pkNames | join ", "}}, selectCols...)
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
|
||||
return retobj
|
||||
|
@ -64,10 +64,10 @@ func FindOne{{$tableNameSingular}}(exec boil.Executor, filters {{$tableNameSingu
|
|||
Bind(obj)
|
||||
|
||||
if err != nil {
|
||||
if errors.Cause(err) == sql.ErrNoRows {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, errors.Wrap(err, "{{.PkgName}}: unable to select from {{.Table.Name}}")
|
||||
return nil, errors.Prefix("{{.PkgName}}: unable to select from {{.Table.Name}}", err)
|
||||
}
|
||||
|
||||
return obj, nil
|
||||
|
|
|
@ -10,7 +10,7 @@ func (o *{{$tableNameSingular}}) InsertG(whitelist ... string) error {
|
|||
// behavior description.
|
||||
func (o *{{$tableNameSingular}}) InsertGP(whitelist ... string) {
|
||||
if err := o.Insert(boil.GetDB(), whitelist...); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ func (o *{{$tableNameSingular}}) InsertGP(whitelist ... string) {
|
|||
// for whitelist behavior description.
|
||||
func (o *{{$tableNameSingular}}) InsertP(exec boil.Executor, whitelist ... string) {
|
||||
if err := o.Insert(exec, whitelist...); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ func (o *{{$tableNameSingular}}) InsertP(exec boil.Executor, whitelist ... strin
|
|||
// - All columns with a default, but non-zero are included (i.e. health = 75)
|
||||
func (o *{{$tableNameSingular}}) Insert(exec boil.Executor, whitelist ... string) error {
|
||||
if o == nil {
|
||||
return errors.New("{{.PkgName}}: no {{.Table.Name}} provided for insertion")
|
||||
return errors.Err("{{.PkgName}}: no {{.Table.Name}} provided for insertion")
|
||||
}
|
||||
|
||||
var err error
|
||||
|
@ -37,7 +37,7 @@ func (o *{{$tableNameSingular}}) Insert(exec boil.Executor, whitelist ... string
|
|||
|
||||
{{if not .NoHooks -}}
|
||||
if err := o.doBeforeInsertHooks(exec); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
{{- end}}
|
||||
|
||||
|
@ -59,11 +59,11 @@ func (o *{{$tableNameSingular}}) Insert(exec boil.Executor, whitelist ... string
|
|||
|
||||
cache.valueMapping, err = queries.BindMapping({{$varNameSingular}}Type, {{$varNameSingular}}Mapping, wl)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
cache.retMapping, err = queries.BindMapping({{$varNameSingular}}Type, {{$varNameSingular}}Mapping, returnColumns)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
if len(wl) != 0 {
|
||||
cache.query = fmt.Sprintf("INSERT INTO {{$schemaTable}} ({{.LQ}}%s{{.RQ}}) %%sVALUES (%s)%%s", strings.Join(wl, "{{.RQ}},{{.LQ}}"), strmangle.Placeholders(dialect.IndexPlaceholders, len(wl), 1, 1))
|
||||
|
@ -110,7 +110,7 @@ func (o *{{$tableNameSingular}}) Insert(exec boil.Executor, whitelist ... string
|
|||
_, err = exec.Exec(cache.query, vals...)
|
||||
{{- end}}
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "{{.PkgName}}: unable to insert into {{.Table.Name}}")
|
||||
return errors.Prefix("{{.PkgName}}: unable to insert into {{.Table.Name}}", err)
|
||||
}
|
||||
|
||||
{{if $canLastInsertID -}}
|
||||
|
@ -125,7 +125,7 @@ func (o *{{$tableNameSingular}}) Insert(exec boil.Executor, whitelist ... string
|
|||
{{if $canLastInsertID -}}
|
||||
lastID, err = result.LastInsertId()
|
||||
if err != nil {
|
||||
return ErrSyncFail
|
||||
return errors.Err(ErrSyncFail)
|
||||
}
|
||||
|
||||
{{$colName := index .Table.PKey.Columns 0 -}}
|
||||
|
@ -150,7 +150,7 @@ func (o *{{$tableNameSingular}}) Insert(exec boil.Executor, whitelist ... string
|
|||
|
||||
err = exec.QueryRow(cache.retQuery, identifierCols...).Scan(queries.PtrsFromMapping(value, cache.retMapping)...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "{{.PkgName}}: unable to populate default values for {{.Table.Name}}")
|
||||
return errors.Prefix("{{.PkgName}}: unable to populate default values for {{.Table.Name}}", err)
|
||||
}
|
||||
{{else}}
|
||||
if len(cache.retMapping) != 0 {
|
||||
|
@ -160,7 +160,7 @@ func (o *{{$tableNameSingular}}) Insert(exec boil.Executor, whitelist ... string
|
|||
}
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "{{.PkgName}}: unable to insert into {{.Table.Name}}")
|
||||
return errors.Prefix("{{.PkgName}}: unable to insert into {{.Table.Name}}", err)
|
||||
}
|
||||
{{end}}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ func (o *{{$tableNameSingular}}) UpdateG(whitelist ...string) error {
|
|||
// Panics on error. See Update for whitelist behavior description.
|
||||
func (o *{{$tableNameSingular}}) UpdateGP(whitelist ...string) {
|
||||
if err := o.Update(boil.GetDB(), whitelist...); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ func (o *{{$tableNameSingular}}) UpdateGP(whitelist ...string) {
|
|||
func (o *{{$tableNameSingular}}) UpdateP(exec boil.Executor, whitelist ... string) {
|
||||
err := o.Update(exec, whitelist...)
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ func (o *{{$tableNameSingular}}) Update(exec boil.Executor, whitelist ... string
|
|||
var err error
|
||||
{{if not .NoHooks -}}
|
||||
if err = o.doBeforeUpdateHooks(exec); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
{{end -}}
|
||||
|
||||
|
@ -62,7 +62,7 @@ func (o *{{$tableNameSingular}}) Update(exec boil.Executor, whitelist ... string
|
|||
}
|
||||
{{end -}}
|
||||
if len(wl) == 0 {
|
||||
return errors.New("{{.PkgName}}: unable to update {{.Table.Name}}, could not build whitelist")
|
||||
return errors.Err("{{.PkgName}}: unable to update {{.Table.Name}}, could not build whitelist")
|
||||
}
|
||||
|
||||
cache.query = fmt.Sprintf("UPDATE {{$schemaTable}} SET %s WHERE %s",
|
||||
|
@ -71,7 +71,7 @@ func (o *{{$tableNameSingular}}) Update(exec boil.Executor, whitelist ... string
|
|||
)
|
||||
cache.valueMapping, err = queries.BindMapping({{$varNameSingular}}Type, {{$varNameSingular}}Mapping, append(wl, {{$varNameSingular}}PrimaryKeyColumns...))
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ func (o *{{$tableNameSingular}}) Update(exec boil.Executor, whitelist ... string
|
|||
|
||||
_, err = exec.Exec(cache.query, values...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "{{.PkgName}}: unable to update {{.Table.Name}} row")
|
||||
return errors.Prefix("{{.PkgName}}: unable to update {{.Table.Name}} row", err)
|
||||
}
|
||||
|
||||
if !cached {
|
||||
|
@ -103,7 +103,7 @@ func (o *{{$tableNameSingular}}) Update(exec boil.Executor, whitelist ... string
|
|||
// UpdateAllP updates all rows with matching column names, and panics on error.
|
||||
func (q {{$tableNameSingular}}Query) UpdateAllP(cols M) {
|
||||
if err := q.UpdateAll(cols); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ func (q {{$tableNameSingular}}Query) UpdateAll(cols M) error {
|
|||
|
||||
_, err := q.Query.Exec()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "{{.PkgName}}: unable to update all for {{.Table.Name}}")
|
||||
return errors.Prefix("{{.PkgName}}: unable to update all for {{.Table.Name}}", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -127,14 +127,14 @@ func (o {{$tableNameSingular}}Slice) UpdateAllG(cols M) error {
|
|||
// UpdateAllGP updates all rows with the specified column values, and panics on error.
|
||||
func (o {{$tableNameSingular}}Slice) UpdateAllGP(cols M) {
|
||||
if err := o.UpdateAll(boil.GetDB(), cols); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateAllP updates all rows with the specified column values, and panics on error.
|
||||
func (o {{$tableNameSingular}}Slice) UpdateAllP(exec boil.Executor, cols M) {
|
||||
if err := o.UpdateAll(exec, cols); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ func (o {{$tableNameSingular}}Slice) UpdateAll(exec boil.Executor, cols M) error
|
|||
}
|
||||
|
||||
if len(cols) == 0 {
|
||||
return errors.New("{{.PkgName}}: update all requires at least one column argument")
|
||||
return errors.Err("{{.PkgName}}: update all requires at least one column argument")
|
||||
}
|
||||
|
||||
colNames := make([]string, len(cols))
|
||||
|
@ -176,7 +176,7 @@ func (o {{$tableNameSingular}}Slice) UpdateAll(exec boil.Executor, cols M) error
|
|||
|
||||
_, err := exec.Exec(sql, args...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "{{.PkgName}}: unable to update all in {{$varNameSingular}} slice")
|
||||
return errors.Prefix("{{.PkgName}}: unable to update all in {{$varNameSingular}} slice", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -9,7 +9,7 @@ func (o *{{$tableNameSingular}}) UpsertG({{if eq .DriverName "postgres"}}updateO
|
|||
// UpsertGP attempts an insert, and does an update or ignore on conflict. Panics on error.
|
||||
func (o *{{$tableNameSingular}}) UpsertGP({{if eq .DriverName "postgres"}}updateOnConflict bool, conflictColumns []string, {{end}}updateColumns []string, whitelist ...string) {
|
||||
if err := o.Upsert(boil.GetDB(), {{if eq .DriverName "postgres"}}updateOnConflict, conflictColumns, {{end}}updateColumns, whitelist...); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,21 +17,21 @@ func (o *{{$tableNameSingular}}) UpsertGP({{if eq .DriverName "postgres"}}update
|
|||
// UpsertP panics on error.
|
||||
func (o *{{$tableNameSingular}}) UpsertP(exec boil.Executor, {{if eq .DriverName "postgres"}}updateOnConflict bool, conflictColumns []string, {{end}}updateColumns []string, whitelist ...string) {
|
||||
if err := o.Upsert(exec, {{if eq .DriverName "postgres"}}updateOnConflict, conflictColumns, {{end}}updateColumns, whitelist...); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
// Upsert attempts an insert using an executor, and does an update or ignore on conflict.
|
||||
func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if eq .DriverName "postgres"}}updateOnConflict bool, conflictColumns []string, {{end}}updateColumns []string, whitelist ...string) error {
|
||||
if o == nil {
|
||||
return errors.New("{{.PkgName}}: no {{.Table.Name}} provided for upsert")
|
||||
return errors.Err("{{.PkgName}}: no {{.Table.Name}} provided for upsert")
|
||||
}
|
||||
|
||||
{{- template "timestamp_upsert_helper" . }}
|
||||
|
||||
{{if not .NoHooks -}}
|
||||
if err := o.doBeforeUpsertHooks(exec); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
{{- end}}
|
||||
|
||||
|
@ -87,7 +87,7 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if eq .DriverName
|
|||
}
|
||||
}
|
||||
if len(insert) == 0 {
|
||||
return errors.New("{{.PkgName}}: unable to upsert {{.Table.Name}}, could not build insert column list")
|
||||
return errors.Err("{{.PkgName}}: unable to upsert {{.Table.Name}}, could not build insert column list")
|
||||
}
|
||||
|
||||
ret = strmangle.SetMerge(ret, {{$varNameSingular}}ColumnsWithAuto)
|
||||
|
@ -104,7 +104,7 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if eq .DriverName
|
|||
{{end -}}
|
||||
|
||||
if len(update) == 0 {
|
||||
return errors.New("{{.PkgName}}: unable to upsert {{.Table.Name}}, could not build update column list")
|
||||
return errors.Err("{{.PkgName}}: unable to upsert {{.Table.Name}}, could not build update column list")
|
||||
}
|
||||
|
||||
{{if eq .DriverName "postgres"}}
|
||||
|
@ -129,12 +129,12 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if eq .DriverName
|
|||
|
||||
cache.valueMapping, err = queries.BindMapping({{$varNameSingular}}Type, {{$varNameSingular}}Mapping, {{if eq .DriverName "mssql"}}whitelist{{else}}insert{{end}})
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
if len(ret) != 0 {
|
||||
cache.retMapping, err = queries.BindMapping({{$varNameSingular}}Type, {{$varNameSingular}}Mapping, ret)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if eq .DriverName
|
|||
_, err = exec.Exec(cache.query, vals...)
|
||||
{{- end}}
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "{{.PkgName}}: unable to upsert for {{.Table.Name}}")
|
||||
return errors.Prefix("{{.PkgName}}: unable to upsert for {{.Table.Name}}", err)
|
||||
}
|
||||
|
||||
{{if $canLastInsertID -}}
|
||||
|
@ -174,7 +174,7 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if eq .DriverName
|
|||
{{if $canLastInsertID -}}
|
||||
lastID, err = result.LastInsertId()
|
||||
if err != nil {
|
||||
return ErrSyncFail
|
||||
return errors.Err(ErrSyncFail)
|
||||
}
|
||||
|
||||
{{$colName := index .Table.PKey.Columns 0 -}}
|
||||
|
@ -199,7 +199,7 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if eq .DriverName
|
|||
|
||||
err = exec.QueryRow(cache.retQuery, identifierCols...).Scan(returns...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "{{.PkgName}}: unable to populate default values for {{.Table.Name}}")
|
||||
return errors.Prefix("{{.PkgName}}: unable to populate default values for {{.Table.Name}}", err)
|
||||
}
|
||||
{{- else}}
|
||||
if len(cache.retMapping) != 0 {
|
||||
|
@ -211,7 +211,7 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if eq .DriverName
|
|||
_, err = exec.Exec(cache.query, vals...)
|
||||
}
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "{{.PkgName}}: unable to upsert {{.Table.Name}}")
|
||||
return errors.Prefix("{{.PkgName}}: unable to upsert {{.Table.Name}}", err)
|
||||
}
|
||||
{{- end}}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
// Panics on error.
|
||||
func (o *{{$tableNameSingular}}) DeleteP(exec boil.Executor) {
|
||||
if err := o.Delete(exec); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ func (o *{{$tableNameSingular}}) DeleteP(exec boil.Executor) {
|
|||
// DeleteG will match against the primary key column to find the record to delete.
|
||||
func (o *{{$tableNameSingular}}) DeleteG() error {
|
||||
if o == nil {
|
||||
return errors.New("{{.PkgName}}: no {{$tableNameSingular}} provided for deletion")
|
||||
return errors.Err("{{.PkgName}}: no {{$tableNameSingular}} provided for deletion")
|
||||
}
|
||||
|
||||
return o.Delete(boil.GetDB())
|
||||
|
@ -25,7 +25,7 @@ func (o *{{$tableNameSingular}}) DeleteG() error {
|
|||
// Panics on error.
|
||||
func (o *{{$tableNameSingular}}) DeleteGP() {
|
||||
if err := o.DeleteG(); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,12 @@ func (o *{{$tableNameSingular}}) DeleteGP() {
|
|||
// Delete will match against the primary key column to find the record to delete.
|
||||
func (o *{{$tableNameSingular}}) Delete(exec boil.Executor) error {
|
||||
if o == nil {
|
||||
return errors.New("{{.PkgName}}: no {{$tableNameSingular}} provided for delete")
|
||||
return errors.Err("{{.PkgName}}: no {{$tableNameSingular}} provided for delete")
|
||||
}
|
||||
|
||||
{{if not .NoHooks -}}
|
||||
if err := o.doBeforeDeleteHooks(exec); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
{{- end}}
|
||||
|
||||
|
@ -52,12 +52,12 @@ func (o *{{$tableNameSingular}}) Delete(exec boil.Executor) error {
|
|||
|
||||
_, err := exec.Exec(sql, args...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "{{.PkgName}}: unable to delete from {{.Table.Name}}")
|
||||
return errors.Prefix("{{.PkgName}}: unable to delete from {{.Table.Name}}", err)
|
||||
}
|
||||
|
||||
{{if not .NoHooks -}}
|
||||
if err := o.doAfterDeleteHooks(exec); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
{{- end}}
|
||||
|
||||
|
@ -67,21 +67,21 @@ func (o *{{$tableNameSingular}}) Delete(exec boil.Executor) error {
|
|||
// DeleteAllP deletes all rows, and panics on error.
|
||||
func (q {{$tableNameSingular}}Query) DeleteAllP() {
|
||||
if err := q.DeleteAll(); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteAll deletes all matching rows.
|
||||
func (q {{$tableNameSingular}}Query) DeleteAll() error {
|
||||
if q.Query == nil {
|
||||
return errors.New("{{.PkgName}}: no {{$tableNameSingular}}Query provided for delete all")
|
||||
return errors.Err("{{.PkgName}}: no {{$tableNameSingular}}Query provided for delete all")
|
||||
}
|
||||
|
||||
queries.SetDelete(q.Query)
|
||||
|
||||
_, err := q.Query.Exec()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "{{.PkgName}}: unable to delete all from {{.Table.Name}}")
|
||||
return errors.Prefix("{{.PkgName}}: unable to delete all from {{.Table.Name}}", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -90,14 +90,14 @@ func (q {{$tableNameSingular}}Query) DeleteAll() error {
|
|||
// DeleteAllGP deletes all rows in the slice, and panics on error.
|
||||
func (o {{$tableNameSingular}}Slice) DeleteAllGP() {
|
||||
if err := o.DeleteAllG(); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteAllG deletes all rows in the slice.
|
||||
func (o {{$tableNameSingular}}Slice) DeleteAllG() error {
|
||||
if o == nil {
|
||||
return errors.New("{{.PkgName}}: no {{$tableNameSingular}} slice provided for delete all")
|
||||
return errors.Err("{{.PkgName}}: no {{$tableNameSingular}} slice provided for delete all")
|
||||
}
|
||||
return o.DeleteAll(boil.GetDB())
|
||||
}
|
||||
|
@ -105,14 +105,14 @@ func (o {{$tableNameSingular}}Slice) DeleteAllG() error {
|
|||
// DeleteAllP deletes all rows in the slice, using an executor, and panics on error.
|
||||
func (o {{$tableNameSingular}}Slice) DeleteAllP(exec boil.Executor) {
|
||||
if err := o.DeleteAll(exec); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteAll deletes all rows in the slice, using an executor.
|
||||
func (o {{$tableNameSingular}}Slice) DeleteAll(exec boil.Executor) error {
|
||||
if o == nil {
|
||||
return errors.New("{{.PkgName}}: no {{$tableNameSingular}} slice provided for delete all")
|
||||
return errors.Err("{{.PkgName}}: no {{$tableNameSingular}} slice provided for delete all")
|
||||
}
|
||||
|
||||
if len(o) == 0 {
|
||||
|
@ -123,7 +123,7 @@ func (o {{$tableNameSingular}}Slice) DeleteAll(exec boil.Executor) error {
|
|||
if len({{$varNameSingular}}BeforeDeleteHooks) != 0 {
|
||||
for _, obj := range o {
|
||||
if err := obj.doBeforeDeleteHooks(exec); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,14 +145,14 @@ func (o {{$tableNameSingular}}Slice) DeleteAll(exec boil.Executor) error {
|
|||
|
||||
_, err := exec.Exec(sql, args...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "{{.PkgName}}: unable to delete all from {{$varNameSingular}} slice")
|
||||
return errors.Prefix("{{.PkgName}}: unable to delete all from {{$varNameSingular}} slice", err)
|
||||
}
|
||||
|
||||
{{if not .NoHooks -}}
|
||||
if len({{$varNameSingular}}AfterDeleteHooks) != 0 {
|
||||
for _, obj := range o {
|
||||
if err := obj.doAfterDeleteHooks(exec); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,21 +5,21 @@
|
|||
// ReloadGP refetches the object from the database and panics on error.
|
||||
func (o *{{$tableNameSingular}}) ReloadGP() {
|
||||
if err := o.ReloadG(); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
// ReloadP refetches the object from the database with an executor. Panics on error.
|
||||
func (o *{{$tableNameSingular}}) ReloadP(exec boil.Executor) {
|
||||
if err := o.Reload(exec); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
// ReloadG refetches the object from the database using the primary keys.
|
||||
func (o *{{$tableNameSingular}}) ReloadG() error {
|
||||
if o == nil {
|
||||
return errors.New("{{.PkgName}}: no {{$tableNameSingular}} provided for reload")
|
||||
return errors.Err("{{.PkgName}}: no {{$tableNameSingular}} provided for reload")
|
||||
}
|
||||
|
||||
return o.Reload(boil.GetDB())
|
||||
|
@ -30,7 +30,7 @@ func (o *{{$tableNameSingular}}) ReloadG() error {
|
|||
func (o *{{$tableNameSingular}}) Reload(exec boil.Executor) error {
|
||||
ret, err := Find{{$tableNameSingular}}(exec, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o." | join ", "}})
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
|
||||
*o = *ret
|
||||
|
@ -42,7 +42,7 @@ func (o *{{$tableNameSingular}}) Reload(exec boil.Executor) error {
|
|||
// Panics on error.
|
||||
func (o *{{$tableNameSingular}}Slice) ReloadAllGP() {
|
||||
if err := o.ReloadAllG(); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ func (o *{{$tableNameSingular}}Slice) ReloadAllGP() {
|
|||
// Panics on error.
|
||||
func (o *{{$tableNameSingular}}Slice) ReloadAllP(exec boil.Executor) {
|
||||
if err := o.ReloadAll(exec); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ func (o *{{$tableNameSingular}}Slice) ReloadAllP(exec boil.Executor) {
|
|||
// and overwrites the original object slice with the newly updated slice.
|
||||
func (o *{{$tableNameSingular}}Slice) ReloadAllG() error {
|
||||
if o == nil {
|
||||
return errors.New("{{.PkgName}}: empty {{$tableNameSingular}}Slice provided for reload all")
|
||||
return errors.Err("{{.PkgName}}: empty {{$tableNameSingular}}Slice provided for reload all")
|
||||
}
|
||||
|
||||
return o.ReloadAll(boil.GetDB())
|
||||
|
@ -86,7 +86,7 @@ func (o *{{$tableNameSingular}}Slice) ReloadAll(exec boil.Executor) error {
|
|||
|
||||
err := q.Bind(&{{$varNamePlural}})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "{{.PkgName}}: unable to reload all in {{$tableNameSingular}}Slice")
|
||||
return errors.Prefix("{{.PkgName}}: unable to reload all in {{$tableNameSingular}}Slice", err)
|
||||
}
|
||||
|
||||
*o = {{$varNamePlural}}
|
||||
|
|
|
@ -22,7 +22,7 @@ func {{$tableNameSingular}}Exists(exec boil.Executor, {{$pkArgs}}) (bool, error)
|
|||
|
||||
err := row.Scan(&exists)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "{{.PkgName}}: unable to check if {{.Table.Name}} exists")
|
||||
return false, errors.Prefix("{{.PkgName}}: unable to check if {{.Table.Name}} exists", err)
|
||||
}
|
||||
|
||||
return exists, nil
|
||||
|
@ -37,7 +37,7 @@ func {{$tableNameSingular}}ExistsG({{$pkArgs}}) (bool, error) {
|
|||
func {{$tableNameSingular}}ExistsGP({{$pkArgs}}) bool {
|
||||
e, err := {{$tableNameSingular}}Exists(boil.GetDB(), {{$pkNames | join ", "}})
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
|
||||
return e
|
||||
|
@ -47,7 +47,7 @@ func {{$tableNameSingular}}ExistsGP({{$pkArgs}}) bool {
|
|||
func {{$tableNameSingular}}ExistsP(exec boil.Executor, {{$pkArgs}}) bool {
|
||||
e, err := {{$tableNameSingular}}Exists(exec, {{$pkNames | join ", "}})
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
panic(errors.Err(err))
|
||||
}
|
||||
|
||||
return e
|
||||
|
|
|
@ -9,12 +9,12 @@ func Merge{{$tableNamePlural}}(exec boil.Executor, primaryID uint64, secondaryID
|
|||
if !ok {
|
||||
txdb, ok := exec.(boil.Beginner)
|
||||
if !ok {
|
||||
return errors.New("database does not support transactions")
|
||||
return errors.Err("database does not support transactions")
|
||||
}
|
||||
|
||||
tx, err = txdb.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
|
@ -31,16 +31,16 @@ func Merge{{$tableNamePlural}}(exec boil.Executor, primaryID uint64, secondaryID
|
|||
|
||||
primary, err := Find{{$tableNameSingular}}(tx, primaryID)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
} else if primary == nil {
|
||||
return errors.New("Primary {{$tableNameSingular}} not found")
|
||||
return errors.Err("primary {{$tableNameSingular}} not found")
|
||||
}
|
||||
|
||||
secondary, err := Find{{$tableNameSingular}}(tx, secondaryID)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
} else if secondary == nil {
|
||||
return errors.New("Secondary {{$tableNameSingular}} not found")
|
||||
return errors.Err("secondary {{$tableNameSingular}} not found")
|
||||
}
|
||||
|
||||
foreignKeys := []foreignKey{
|
||||
|
@ -89,12 +89,12 @@ func Merge{{$tableNamePlural}}(exec boil.Executor, primaryID uint64, secondaryID
|
|||
|
||||
err = primary.Update(tx)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
return err
|
||||
}
|
||||
|
||||
err = secondary.Delete(tx)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -29,7 +29,7 @@ func mergeModels(tx boil.Executor, primaryID uint64, secondaryID uint64, foreign
|
|||
for _, conflict := range conflictingKeys {
|
||||
err = deleteConflictsBeforeMerge(tx, conflict, primaryID, secondaryID)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ func mergeModels(tx boil.Executor, primaryID uint64, secondaryID uint64, foreign
|
|||
)
|
||||
_, err = tx.Exec(query, primaryID, secondaryID)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
return errors.Err(err)
|
||||
}
|
||||
}
|
||||
return checkMerge(tx, foreignKeys)
|
||||
|
@ -54,7 +54,7 @@ func deleteConflictsBeforeMerge(tx boil.Executor, conflict conflictingUniqueKey,
|
|||
if len(conflictingColumns) < 1 {
|
||||
return nil
|
||||
} else if len(conflictingColumns) > 1 {
|
||||
return errors.New("this doesnt work for unique keys with more than two columns (yet)")
|
||||
return errors.Err("this doesnt work for unique keys with more than two columns (yet)")
|
||||
}
|
||||
|
||||
query := fmt.Sprintf(
|
||||
|
@ -67,7 +67,7 @@ func deleteConflictsBeforeMerge(tx boil.Executor, conflict conflictingUniqueKey,
|
|||
rows, err := tx.Query(query, primaryID, secondaryID)
|
||||
defer rows.Close()
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
return errors.Err(err)
|
||||
}
|
||||
|
||||
args := []interface{}{secondaryID}
|
||||
|
@ -75,7 +75,7 @@ func deleteConflictsBeforeMerge(tx boil.Executor, conflict conflictingUniqueKey,
|
|||
var value string
|
||||
err = rows.Scan(&value)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
return errors.Err(err)
|
||||
}
|
||||
args = append(args, value)
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ func deleteConflictsBeforeMerge(tx boil.Executor, conflict conflictingUniqueKey,
|
|||
|
||||
_, err = tx.Exec(query, args...)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
return errors.Err(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ func checkMerge(tx boil.Executor, foreignKeys []foreignKey) error {
|
|||
rows, err := tx.Query(q, uniqueColumns...)
|
||||
defer rows.Close()
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
return errors.Err(err)
|
||||
}
|
||||
|
||||
for rows.Next() {
|
||||
|
@ -126,11 +126,11 @@ func checkMerge(tx boil.Executor, foreignKeys []foreignKey) error {
|
|||
var columnName string
|
||||
err = rows.Scan(&tableName, &columnName)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
return errors.Err(err)
|
||||
}
|
||||
|
||||
if _, exists := handledTablesColumns[tableName+"."+columnName]; !exists {
|
||||
return errors.New("Missing merge for " + tableName + "." + columnName)
|
||||
return errors.Err("missing merge for " + tableName + "." + columnName)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ type conflictingUniqueKey struct {
|
|||
// ErrSyncFail occurs during insert when the record could not be retrieved in
|
||||
// order to populate default value information. This usually happens when LastInsertId
|
||||
// fails or there was a primary key configuration that was not resolvable.
|
||||
var ErrSyncFail = errors.New("{{.PkgName}}: failed to synchronize data after insert")
|
||||
var ErrSyncFail = errors.Base("{{.PkgName}}: failed to synchronize data after insert")
|
||||
|
||||
type insertCache struct {
|
||||
query string
|
||||
|
|
|
@ -25,17 +25,17 @@ func (m *mssqlTester) setup() error {
|
|||
m.testDBName = randomize.StableDBName(m.dbName)
|
||||
|
||||
if err = m.dropTestDB(); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
if err = m.createTestDB(); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
|
||||
createCmd := exec.Command("sqlcmd", "-S", m.host, "-U", m.user, "-P", m.pass, "-d", m.testDBName)
|
||||
|
||||
f, err := os.Open("tables_schema.sql")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to open tables_schema.sql file")
|
||||
return errors.Prefix("failed to open tables_schema.sql file", err)
|
||||
}
|
||||
|
||||
defer f.Close()
|
||||
|
@ -43,12 +43,12 @@ func (m *mssqlTester) setup() error {
|
|||
createCmd.Stdin = newFKeyDestroyer(rgxMSSQLkey, f)
|
||||
|
||||
if err = createCmd.Start(); err != nil {
|
||||
return errors.Wrap(err, "failed to start sqlcmd command")
|
||||
return errors.Prefix("failed to start sqlcmd command", err)
|
||||
}
|
||||
|
||||
if err = createCmd.Wait(); err != nil {
|
||||
fmt.Println(err)
|
||||
return errors.Wrap(err, "failed to wait for sqlcmd command")
|
||||
return errors.Prefix("failed to wait for sqlcmd command", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -92,7 +92,7 @@ func (m *mssqlTester) teardown() error {
|
|||
}
|
||||
|
||||
if err := m.dropTestDB(); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -110,7 +110,7 @@ func (m *mssqlTester) runCmd(stdin, command string, args ...string) error {
|
|||
fmt.Println("failed running:", command, args)
|
||||
fmt.Println(stdout.String())
|
||||
fmt.Println(stderr.String())
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -30,14 +30,14 @@ func (m *mysqlTester) setup() error {
|
|||
m.testDBName = randomize.StableDBName(m.dbName)
|
||||
|
||||
if err = m.makeOptionFile(); err != nil {
|
||||
return errors.Wrap(err, "couldn't make option file")
|
||||
return errors.Prefix("couldn't make option file", err)
|
||||
}
|
||||
|
||||
if err = m.dropTestDB(); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
if err = m.createTestDB(); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
|
||||
dumpCmd := exec.Command("mysqldump", m.defaultsFile(), "--no-data", m.dbName)
|
||||
|
@ -48,22 +48,22 @@ func (m *mysqlTester) setup() error {
|
|||
createCmd.Stdin = newFKeyDestroyer(rgxMySQLkey, r)
|
||||
|
||||
if err = dumpCmd.Start(); err != nil {
|
||||
return errors.Wrap(err, "failed to start mysqldump command")
|
||||
return errors.Prefix("failed to start mysqldump command", err)
|
||||
}
|
||||
if err = createCmd.Start(); err != nil {
|
||||
return errors.Wrap(err, "failed to start mysql command")
|
||||
return errors.Prefix("failed to start mysql command", err)
|
||||
}
|
||||
|
||||
if err = dumpCmd.Wait(); err != nil {
|
||||
fmt.Println(err)
|
||||
return errors.Wrap(err, "failed to wait for mysqldump command")
|
||||
return errors.Prefix("failed to wait for mysqldump command", err)
|
||||
}
|
||||
|
||||
w.Close() // After dumpCmd is done, close the write end of the pipe
|
||||
|
||||
if err = createCmd.Wait(); err != nil {
|
||||
fmt.Println(err)
|
||||
return errors.Wrap(err, "failed to wait for mysql command")
|
||||
return errors.Prefix("failed to wait for mysql command", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -87,7 +87,7 @@ func (m *mysqlTester) defaultsFile() string {
|
|||
func (m *mysqlTester) makeOptionFile() error {
|
||||
tmp, err := ioutil.TempFile("", "optionfile")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create option file")
|
||||
return errors.Prefix("failed to create option file", err)
|
||||
}
|
||||
|
||||
isTCP := false
|
||||
|
@ -95,7 +95,7 @@ func (m *mysqlTester) makeOptionFile() error {
|
|||
if os.IsNotExist(err) {
|
||||
isTCP = true
|
||||
} else if err != nil {
|
||||
return errors.Wrap(err, "could not stat m.host")
|
||||
return errors.Prefix("could not stat m.host", err)
|
||||
}
|
||||
|
||||
fmt.Fprintln(tmp, "[client]")
|
||||
|
@ -139,7 +139,7 @@ func (m *mysqlTester) teardown() error {
|
|||
}
|
||||
|
||||
if err := m.dropTestDB(); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
|
||||
return os.Remove(m.optionFile)
|
||||
|
@ -159,7 +159,7 @@ func (m *mysqlTester) runCmd(stdin, command string, args ...string) error {
|
|||
fmt.Println("failed running:", command, args)
|
||||
fmt.Println(stdout.String())
|
||||
fmt.Println(stderr.String())
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -33,14 +33,14 @@ func (p *pgTester) setup() error {
|
|||
p.testDBName = randomize.StableDBName(p.dbName)
|
||||
|
||||
if err = p.makePGPassFile(); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
|
||||
if err = p.dropTestDB(); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
if err = p.createTestDB(); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
|
||||
dumpCmd := exec.Command("pg_dump", "--schema-only", p.dbName)
|
||||
|
@ -53,22 +53,22 @@ func (p *pgTester) setup() error {
|
|||
createCmd.Stdin = newFKeyDestroyer(rgxPGFkey, r)
|
||||
|
||||
if err = dumpCmd.Start(); err != nil {
|
||||
return errors.Wrap(err, "failed to start pg_dump command")
|
||||
return errors.Prefix("failed to start pg_dump command", err)
|
||||
}
|
||||
if err = createCmd.Start(); err != nil {
|
||||
return errors.Wrap(err, "failed to start psql command")
|
||||
return errors.Prefix("failed to start psql command", err)
|
||||
}
|
||||
|
||||
if err = dumpCmd.Wait(); err != nil {
|
||||
fmt.Println(err)
|
||||
return errors.Wrap(err, "failed to wait for pg_dump command")
|
||||
return errors.Prefix("failed to wait for pg_dump command", err)
|
||||
}
|
||||
|
||||
w.Close() // After dumpCmd is done, close the write end of the pipe
|
||||
|
||||
if err = createCmd.Wait(); err != nil {
|
||||
fmt.Println(err)
|
||||
return errors.Wrap(err, "failed to wait for psql command")
|
||||
return errors.Prefix("failed to wait for psql command", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -90,7 +90,7 @@ func (p *pgTester) runCmd(stdin, command string, args ...string) error {
|
|||
fmt.Println("failed running:", command, args)
|
||||
fmt.Println(stdout.String())
|
||||
fmt.Println(stderr.String())
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -108,7 +108,7 @@ func (p *pgTester) pgEnv() []string {
|
|||
func (p *pgTester) makePGPassFile() error {
|
||||
tmp, err := ioutil.TempFile("", "pgpass")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create option file")
|
||||
return errors.Prefix("failed to create option file", err)
|
||||
}
|
||||
|
||||
fmt.Fprintf(tmp, "%s:%d:postgres:%s", p.host, p.port, p.user)
|
||||
|
@ -145,12 +145,12 @@ func (p *pgTester) dropTestDB() error {
|
|||
func (p *pgTester) teardown() error {
|
||||
var err error
|
||||
if err = p.dbConn.Close(); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
p.dbConn = nil
|
||||
|
||||
if err = p.dropTestDB(); err != nil {
|
||||
return err
|
||||
return errors.Err(err)
|
||||
}
|
||||
|
||||
return os.Remove(p.pgPassFile)
|
||||
|
|
|
@ -143,5 +143,5 @@ func validateConfig(driverName string) error {
|
|||
).Check()
|
||||
}
|
||||
|
||||
return errors.New("not a valid driver name")
|
||||
return errors.Err("not a valid driver name")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue