diff --git a/src/services/platforms/CapacitorPlatformService.ts b/src/services/platforms/CapacitorPlatformService.ts index e004147f..d67187b8 100644 --- a/src/services/platforms/CapacitorPlatformService.ts +++ b/src/services/platforms/CapacitorPlatformService.ts @@ -179,11 +179,28 @@ export class CapacitorPlatformService implements PlatformService { sql: string, params: unknown[] = [], ): Promise { + // Convert parameters to SQLite-compatible types + const convertedParams = params.map((param) => { + if (param === null || param === undefined) { + return null; + } + if (typeof param === 'object' && param !== null) { + // Convert objects and arrays to JSON strings + return JSON.stringify(param); + } + if (typeof param === 'boolean') { + // Convert boolean to integer (0 or 1) + return param ? 1 : 0; + } + // Numbers, strings, bigints, and buffers are already supported + return param; + }); + return new Promise((resolve, reject) => { const operation: QueuedOperation = { type, sql, - params, + params: convertedParams, resolve: (value: unknown) => resolve(value as R), reject, };