From 1637c6209d230fef40b0a151c9bcaa887fab71cf Mon Sep 17 00:00:00 2001 From: ze0s <43699394+zze0s@users.noreply.github.com> Date: Fri, 21 Jul 2023 20:17:39 +0200 Subject: [PATCH] fix(downloadclient): could not delete (#1020) * fix(downloadclient): could not delete client * fix(downloadclient): postgres fix tx options --- internal/database/download_client.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/database/download_client.go b/internal/database/download_client.go index 56f7939..f46b260 100644 --- a/internal/database/download_client.go +++ b/internal/database/download_client.go @@ -257,7 +257,7 @@ func (r *DownloadClientRepo) Update(ctx context.Context, client domain.DownloadC } func (r *DownloadClientRepo) Delete(ctx context.Context, clientID int) error { - tx, err := r.db.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelWriteCommitted}) + tx, err := r.db.BeginTx(ctx, &sql.TxOptions{}) if err != nil { return err } @@ -323,6 +323,11 @@ func (r *DownloadClientRepo) deleteClientFromAction(ctx context.Context, tx *Tx, var filterID int if err = queryBuilder.QueryRowContext(ctx).Scan(&filterID); err != nil { + // this will throw when the client is not connected to any actions + // it is not an error in this case + if errors.Is(err, sql.ErrNoRows) { + return nil + } return errors.Wrap(err, "error executing query") }