mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
fix(filters): could not delete filter without actions (#1275)
* fix(database): hot fix for deleting filter. This fixes the no sql row set, no idea why it does that but removing the row check I added fixes it, Not sure if it affects others rowsAffected in the delete function. * fix: imports --------- Co-authored-by: ze0s <43699394+zze0s@users.noreply.github.com>
This commit is contained in:
parent
4d13d08c87
commit
c0f8ecfa9e
2 changed files with 2 additions and 24 deletions
|
@ -402,17 +402,11 @@ func (r *ActionRepo) Delete(ctx context.Context, req *domain.DeleteActionRequest
|
|||
return errors.Wrap(err, "error building query")
|
||||
}
|
||||
|
||||
result, err := r.db.handler.ExecContext(ctx, query, args...)
|
||||
_, err = r.db.handler.ExecContext(ctx, query, args...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error executing query")
|
||||
}
|
||||
|
||||
if rowsAffected, err := result.RowsAffected(); err != nil {
|
||||
return errors.Wrap(err, "error getting rows affected")
|
||||
} else if rowsAffected == 0 {
|
||||
return domain.ErrRecordNotFound
|
||||
}
|
||||
|
||||
r.log.Debug().Msgf("action.delete: %v", req.ActionId)
|
||||
|
||||
return nil
|
||||
|
@ -428,17 +422,11 @@ func (r *ActionRepo) DeleteByFilterID(ctx context.Context, filterID int) error {
|
|||
return errors.Wrap(err, "error building query")
|
||||
}
|
||||
|
||||
result, err := r.db.handler.ExecContext(ctx, query, args...)
|
||||
_, err = r.db.handler.ExecContext(ctx, query, args...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error executing query")
|
||||
}
|
||||
|
||||
if rowsAffected, err := result.RowsAffected(); err != nil {
|
||||
return errors.Wrap(err, "error getting rows affected")
|
||||
} else if rowsAffected == 0 {
|
||||
return domain.ErrRecordNotFound
|
||||
}
|
||||
|
||||
r.log.Debug().Msgf("action.deleteByFilterID: %v", filterID)
|
||||
|
||||
return nil
|
||||
|
|
|
@ -408,11 +408,6 @@ func TestActionRepo_Delete(t *testing.T) {
|
|||
_ = downloadClientRepo.Delete(context.Background(), createdClient.ID)
|
||||
})
|
||||
|
||||
t.Run(fmt.Sprintf("Delete_Fails_No_Record [%s]", dbType), func(t *testing.T) {
|
||||
err := repo.Delete(context.Background(), &domain.DeleteActionRequest{ActionId: 9999})
|
||||
assert.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run(fmt.Sprintf("Delete_Fails_Context_Timeout [%s]", dbType), func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Nanosecond)
|
||||
defer cancel()
|
||||
|
@ -465,11 +460,6 @@ func TestActionRepo_DeleteByFilterID(t *testing.T) {
|
|||
_ = downloadClientRepo.Delete(context.Background(), createdClient.ID)
|
||||
})
|
||||
|
||||
t.Run(fmt.Sprintf("DeleteByFilterID_Fails_No_Record [%s]", dbType), func(t *testing.T) {
|
||||
err := repo.DeleteByFilterID(context.Background(), 9999)
|
||||
assert.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run(fmt.Sprintf("DeleteByFilterID_Fails_Context_Timeout [%s]", dbType), func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Nanosecond)
|
||||
defer cancel()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue