From 5dee03b2de0c560a6dbb503924d42ece69c39237 Mon Sep 17 00:00:00 2001 From: tianma-if Date: Fri, 25 Sep 2026 18:42:48 +0800 Subject: [PATCH] fix(api): delete notebooks with null slugs --- apps/api/src/notebook-service.test.mjs | 4 ++-- apps/api/src/notebook-service.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/api/src/notebook-service.test.mjs b/apps/api/src/notebook-service.test.mjs index 7d3e22a3..5ddaa4cb 100644 --- a/apps/api/src/notebook-service.test.mjs +++ b/apps/api/src/notebook-service.test.mjs @@ -239,9 +239,9 @@ describe("notebook identity", () => { const fixture = createFixture(); try { fixture.sqlite.exec(` - UPDATE notebooks SET name = '注册考试' WHERE id = 'nb_notes'; + UPDATE notebooks SET name = '注册考试', slug = NULL WHERE id = 'nb_notes'; INSERT INTO notebooks (id, workspace_id, parent_id, name, slug, is_deleted, created_at, updated_at) VALUES - ('nb_law', 'ws_1', 'nb_notes', '法律法规', 'law', 0, '2026-09-10T00:00:00.000Z', '2026-09-10T00:00:00.000Z'), + ('nb_law', 'ws_1', 'nb_notes', '法律法规', NULL, 0, '2026-09-10T00:00:00.000Z', '2026-09-10T00:00:00.000Z'), ('nb_history', 'ws_1', 'nb_notes', '建筑史', 'history', 0, '2026-09-10T00:00:00.000Z', '2026-09-10T00:00:00.000Z'), ('nb_outline', 'ws_1', 'nb_history', '大纲', 'outline', 0, '2026-09-10T00:00:00.000Z', '2026-09-10T00:00:00.000Z'); INSERT INTO memos (id, workspace_id, notebook_id, title, is_deleted, updated_at) diff --git a/apps/api/src/notebook-service.ts b/apps/api/src/notebook-service.ts index e818b47f..b6e4729c 100644 --- a/apps/api/src/notebook-service.ts +++ b/apps/api/src/notebook-service.ts @@ -324,7 +324,7 @@ export const deleteNotebookRecord = async ( `UPDATE notebooks SET is_deleted = 1, deleted_at = ?, updated_at = ? WHERE workspace_id = ? AND is_deleted = 0 AND id IN (${placeholders}) - AND slug <> 'inbox' AND id <> 'nb_inbox' AND id <> ?` + AND (slug IS NULL OR slug <> 'inbox') AND id <> 'nb_inbox' AND id <> ?` ).bind(now, now, workspaceId, ...chunk, inboxId); }); statements.push(auditStatement(db, actor.actorType, actor.actorId, "notebook.delete", "notebook", id, {