Skip to content

Open source personal finance application

fix(convex): validate category name uniqueness on parentId change

Ilya Komichev47f82ac50869
diff --git a/convex/categories.ts b/convex/categories.ts
index ab95eaf7..7ff91e1e 100644
--- a/convex/categories.ts
+++ b/convex/categories.ts
@@ -86,8 +86,8 @@ async function updateCategoryCore(
if (args.parentId !== undefined && args.parentId !== 0)
await validateParentId(ctx, args.parentId, userId, id)
- if (args.name !== undefined)
- await validateNameUniqueness(ctx, args.name, args.parentId ?? category.parentId, userId, id)
+ if (args.name !== undefined || args.parentId !== undefined)
+ await validateNameUniqueness(ctx, args.name ?? category.name, args.parentId ?? category.parentId, userId, id)
if (args.parentId !== undefined)
await syncChildIdsOnParentChange(ctx, id, category.parentId, args.parentId, userId)