From 66cd3d5c4fae195bcc6b6c940f885c47f3a2dca7 Mon Sep 17 00:00:00 2001 From: 4gray Date: Sat, 2 May 2026 01:00:33 +0200 Subject: [PATCH] fix(database): wrap placeholder in sql template for prepared favorite update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drizzle's .set() expects a column-typed value or an SQL fragment, not a bare Placeholder. The earlier prepared-statement refactor (313230ab) passed sql.placeholder('position') directly, which compiled clean under ts-jest's isolated-modules mode but failed the full type check during nx build: TS2322: Type 'Placeholder<"position", any>' is not assignable to type 'number | SQL | SQLiteColumn<...>' Wrap the placeholder in sql\`...\` so it resolves to SQL at compile time. Behavior at runtime is identical — the placeholder is still bound at execute() time per chunk. Co-Authored-By: Claude Opus 4.7 (1M context) Entire-Checkpoint: 746d41da84ff --- .../src/app/database/operations/favorites.operations.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/electron-backend/src/app/database/operations/favorites.operations.ts b/apps/electron-backend/src/app/database/operations/favorites.operations.ts index c6c96988b..bfd6d5e1c 100644 --- a/apps/electron-backend/src/app/database/operations/favorites.operations.ts +++ b/apps/electron-backend/src/app/database/operations/favorites.operations.ts @@ -168,9 +168,11 @@ export async function reorderGlobalFavorites( let current = 0; const total = updates.length; + // Drizzle's .set() doesn't accept a bare Placeholder — wrap it in an + // sql template so the value resolves to SQL at compile time. const updateFavoritePosition = db .update(schema.favorites) - .set({ position: sql.placeholder('position') }) + .set({ position: sql`${sql.placeholder('position')}` }) .where(eq(schema.favorites.contentId, sql.placeholder('contentId'))) .prepare();