From 9006d92819fb2d156389113fc7c67f93f2f2901e Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 5 Nov 2023 19:22:24 +0200 Subject: [PATCH] Fix not being able to remove all owners of badges --- app/features/badges/BadgeRepository.server.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/features/badges/BadgeRepository.server.ts b/app/features/badges/BadgeRepository.server.ts index aaed3b39b..526808502 100644 --- a/app/features/badges/BadgeRepository.server.ts +++ b/app/features/badges/BadgeRepository.server.ts @@ -119,14 +119,16 @@ export function replaceOwners({ .where("badgeId", "=", badgeId) .execute(); - await trx - .insertInto("TournamentBadgeOwner") - .values( - ownerIds.map((userId) => ({ - badgeId, - userId, - })), - ) - .execute(); + if (ownerIds.length > 0) { + await trx + .insertInto("TournamentBadgeOwner") + .values( + ownerIds.map((userId) => ({ + badgeId, + userId, + })), + ) + .execute(); + } }); }