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 {