From 4062b8bb6fd613235bb7fea38e8767ffc4cdba2d Mon Sep 17 00:00:00 2001 From: Mitchell R Date: Sun, 24 May 2026 02:29:46 +0200 Subject: [PATCH] fix(db): SQLite adapter coerce true/false to 1/0 in params MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit node:sqlite rejects JS booleans as bind params. SQLite adapter now converts true→1, false→0 before binding. Mirrors the PG compat approach from the other direction. Co-Authored-By: Claude Opus 4.6 (1M context) --- server/src/plugins/service-store/sqlite-adapter.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/plugins/service-store/sqlite-adapter.ts b/server/src/plugins/service-store/sqlite-adapter.ts index 5b77531..c32f2d0 100644 --- a/server/src/plugins/service-store/sqlite-adapter.ts +++ b/server/src/plugins/service-store/sqlite-adapter.ts @@ -40,9 +40,13 @@ export class SqliteAdapter implements DbAdapter { return s; } + private coerce(params: ReadonlyArray): any[] { + return params.map((v) => (v === true ? 1 : v === false ? 0 : v)); + } + async run(sql: string, params: ReadonlyArray = []): Promise { const stmt = this.prep(sql); - const r = stmt.run(...(params as any[])); + const r = stmt.run(...this.coerce(params)); return { lastInsertRowid: typeof r.lastInsertRowid === "bigint" ? r.lastInsertRowid : BigInt(r.lastInsertRowid), @@ -52,13 +56,13 @@ export class SqliteAdapter implements DbAdapter { async get(sql: string, params: ReadonlyArray = []): Promise { const stmt = this.prep(sql); - const r = stmt.get(...(params as any[])); + const r = (stmt.get as any)(...this.coerce(params)); return r as T | undefined; } async all(sql: string, params: ReadonlyArray = []): Promise { const stmt = this.prep(sql); - return stmt.all(...(params as any[])) as T[]; + return (stmt.all as any)(...this.coerce(params)) as T[]; } async exec(sql: string): Promise {