diff options
| author | MohamedBassem <me@mbassem.com> | 2024-04-26 12:31:28 +0100 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-04-26 12:31:28 +0100 |
| commit | 0b02f94215d6215c1abef503043e612dd4f4f4df (patch) | |
| tree | 18124d3d042f54274540356f5942fa4c0e631e2a | |
| parent | 5aabbec42afcabce826fff14a667a2ca3b0b701f (diff) | |
| download | karakeep-0b02f94215d6215c1abef503043e612dd4f4f4df.tar.zst | |
fix: Fix error when merging empty tags
| -rw-r--r-- | packages/trpc/routers/tags.ts | 20 |
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 |
