Fix missing RowsAffected checks in cookie update methods

Address PR review comments: capture Exec result and check
RowsAffected() == 0 to return ErrResourceNotFound in
Cookie.Update, CookieCategory.Update, and CookieCategory.UpdateRank.
Also update coredata and relay contributor docs accordingly.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-04-21 15:24:54 +04:00
parent 8dfed9fff2
commit 82748f870f
4 changed files with 23 additions and 5 deletions

View File

@@ -327,7 +327,7 @@ WHERE
}
maps.Copy(args, scope.SQLArguments())
_, err := tx.Exec(ctx, q, args)
result, err := tx.Exec(ctx, q, args)
if err != nil {
if pgErr, ok := errors.AsType[*pgconn.PgError](err); ok {
if pgErr.Code == "23505" && pgErr.ConstraintName == "idx_cookies_unique_name_per_banner" {
@@ -337,6 +337,10 @@ WHERE
return fmt.Errorf("cannot update cookie: %w", err)
}
if result.RowsAffected() == 0 {
return ErrResourceNotFound
}
return nil
}