From 0b02f94215d6215c1abef503043e612dd4f4f4df Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Fri, 26 Apr 2024 12:31:28 +0100 Subject: fix: Fix error when merging empty tags --- packages/trpc/routers/tags.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/trpc/routers/tags.ts b/packages/trpc/routers/tags.ts index 4806079a..b95570ae 100644 --- a/packages/trpc/routers/tags.ts +++ b/packages/trpc/routers/tags.ts @@ -252,15 +252,17 @@ export const tagsAppRouter = router({ .returning(); // Re-attach them to the new tag - await trx - .insert(tagsOnBookmarks) - .values( - unlinked.map((u) => ({ - ...u, - tagId: input.intoTagId, - })), - ) - .onConflictDoNothing(); + if (unlinked.length > 0) { + await trx + .insert(tagsOnBookmarks) + .values( + unlinked.map((u) => ({ + ...u, + tagId: input.intoTagId, + })), + ) + .onConflictDoNothing() + } // Delete the old tags const deletedTags = await trx -- cgit v1.2.3-70-g09d2