From b160e5c1f4eddc9ac9e54e87d13da683f3cd1ede Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Wed, 10 May 2017 11:21:29 -0400 Subject: [PATCH] dont error if no rows found --- templates/03_finishers.tpl | 2 +- templates/14_find.tpl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/03_finishers.tpl b/templates/03_finishers.tpl index 841769b..13ea14d 100644 --- a/templates/03_finishers.tpl +++ b/templates/03_finishers.tpl @@ -19,7 +19,7 @@ func (q {{$tableNameSingular}}Query) One() (*{{$tableNameSingular}}, error) { err := q.Bind(o) if err != nil { if errors.Cause(err) == sql.ErrNoRows { - return nil, sql.ErrNoRows + return nil, nil } return nil, errors.Wrap(err, "{{.PkgName}}: failed to execute a one query for {{.Table.Name}}") } diff --git a/templates/14_find.tpl b/templates/14_find.tpl index e177959..b7f69db 100644 --- a/templates/14_find.tpl +++ b/templates/14_find.tpl @@ -36,7 +36,7 @@ func Find{{$tableNameSingular}}(exec boil.Executor, {{$pkArgs}}, selectCols ...s err := q.Bind({{$varNameSingular}}Obj) if err != nil { if errors.Cause(err) == sql.ErrNoRows { - return nil, sql.ErrNoRows + return nil, nil } return nil, errors.Wrap(err, "{{.PkgName}}: unable to select from {{.Table.Name}}") } @@ -65,7 +65,7 @@ func FindOne{{$tableNameSingular}}(exec boil.Executor, filters {{$tableNameSingu if err != nil { if errors.Cause(err) == sql.ErrNoRows { - return nil, sql.ErrNoRows + return nil, nil } return nil, errors.Wrap(err, "{{.PkgName}}: unable to select from {{.Table.Name}}") } @@ -81,7 +81,7 @@ func FindOne{{$tableNameSingular}}G(filters {{$tableNameSingular}}Filter) (*{{$t // FindOne{{$tableNameSingular}}OrInit retrieves a single record using filters, or initializes a new record if one is not found. func FindOne{{$tableNameSingular}}OrInit(exec boil.Executor, filters {{$tableNameSingular}}Filter) (*{{$tableNameSingular}}, error) { {{$varNameSingular}}Obj, err := FindOne{{$tableNameSingular}}(exec, filters) - if err != nil && errors.Cause(err) != sql.ErrNoRows { + if err != nil { return nil, err }