dont error if no rows found
This commit is contained in:
parent
ed43c9078f
commit
b160e5c1f4
2 changed files with 4 additions and 4 deletions
|
@ -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}}")
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue