aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/trpc/routers/tags.ts20
1 files 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