mirror of
https://github.com/absmach/supermq.git
synced 2026-06-23 07:30:25 +00:00
MG-72 - Fix NamedQueryContext not returning sql.ErrNoRows (#73)
This commit is contained in:
@@ -100,15 +100,11 @@ func (cr configRepository) RetrieveByID(ctx context.Context, domainID, id string
|
||||
}
|
||||
row, err := cr.db.NamedQueryContext(ctx, q, dbcfg)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return bootstrap.Config{}, errors.Wrap(repoerr.ErrNotFound, err)
|
||||
}
|
||||
|
||||
return bootstrap.Config{}, errors.Wrap(repoerr.ErrViewEntity, err)
|
||||
}
|
||||
|
||||
if ok := row.Next(); !ok {
|
||||
return bootstrap.Config{}, errors.Wrap(repoerr.ErrNotFound, row.Err())
|
||||
if !row.Next() {
|
||||
return bootstrap.Config{}, errors.Wrap(repoerr.ErrNotFound, sql.ErrNoRows)
|
||||
}
|
||||
|
||||
if err := row.StructScan(&dbcfg); err != nil {
|
||||
@@ -205,14 +201,11 @@ func (cr configRepository) RetrieveByExternalID(ctx context.Context, externalID
|
||||
|
||||
row, err := cr.db.NamedQueryContext(ctx, q, dbcfg)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return bootstrap.Config{}, errors.Wrap(repoerr.ErrNotFound, err)
|
||||
}
|
||||
return bootstrap.Config{}, errors.Wrap(repoerr.ErrViewEntity, err)
|
||||
}
|
||||
|
||||
if ok := row.Next(); !ok {
|
||||
return bootstrap.Config{}, errors.Wrap(repoerr.ErrNotFound, row.Err())
|
||||
if !row.Next() {
|
||||
return bootstrap.Config{}, errors.Wrap(repoerr.ErrNotFound, sql.ErrNoRows)
|
||||
}
|
||||
|
||||
if err := row.StructScan(&dbcfg); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user