@@ -18,6 +18,7 @@ import {
1818import { PowerSyncCore } from '../plugin/PowerSyncCore.js' ;
1919import { messageForErrorCode } from '../plugin/PowerSyncPlugin.js' ;
2020import { CapacitorSQLiteOpenFactoryOptions , DEFAULT_SQLITE_OPTIONS } from './CapacitorSQLiteOpenFactory.js' ;
21+ import { normalizeIOSSqliteParams } from './sqliteParams.js' ;
2122/**
2223 * Monitors the execution time of a query and logs it to the performance timeline.
2324 */
@@ -39,13 +40,15 @@ class CapacitorConnectionPool extends BaseObserver<DBAdapterListener> implements
3940 protected initializedPromise : Promise < void > ;
4041 protected writeMutex : Mutex ;
4142 protected readMutex : Mutex ;
43+ protected readonly platform : string ;
4244
4345 constructor ( protected options : CapacitorSQLiteOpenFactoryOptions ) {
4446 super ( ) ;
4547 this . _writeConnection = null ;
4648 this . _readConnection = null ;
4749 this . writeMutex = new Mutex ( ) ;
4850 this . readMutex = new Mutex ( ) ;
51+ this . platform = Capacitor . getPlatform ( ) ;
4952 this . initializedPromise = this . init ( ) ;
5053 }
5154
@@ -98,8 +101,7 @@ class CapacitorConnectionPool extends BaseObserver<DBAdapterListener> implements
98101
99102 await this . _readConnection . open ( ) ;
100103
101- const platform = Capacitor . getPlatform ( ) ;
102- if ( platform == 'android' ) {
104+ if ( this . platform == 'android' ) {
103105 /**
104106 * SQLCipher for Android enables dynamic loading of extensions.
105107 * On iOS we use a static auto extension registration.
@@ -132,13 +134,11 @@ class CapacitorConnectionPool extends BaseObserver<DBAdapterListener> implements
132134 } ;
133135
134136 const _execute = async ( query : string , params : any [ ] = [ ] ) : Promise < QueryResult > => {
135- const platform = Capacitor . getPlatform ( ) ;
136-
137137 if ( db . getConnectionReadOnly ( ) ) {
138138 return _query ( query , params ) ;
139139 }
140140
141- if ( platform == 'android' ) {
141+ if ( this . platform == 'android' ) {
142142 // Android: use query for SELECT and executeSet for mutations
143143 // We cannot use `run` here for both cases.
144144 if ( query . toLowerCase ( ) . trim ( ) . startsWith ( 'select' ) ) {
@@ -158,7 +158,8 @@ class CapacitorConnectionPool extends BaseObserver<DBAdapterListener> implements
158158 }
159159
160160 // iOS (and other platforms): use run("all")
161- const result = await db . run ( query , params , false , 'all' ) ;
161+ const sqliteParams = this . platform == 'ios' ? normalizeIOSSqliteParams ( params ) : params ;
162+ const result = await db . run ( query , sqliteParams , false , 'all' ) ;
162163 const resultSet = result . changes ?. values ?? [ ] ;
163164 return {
164165 insertId : result . changes ?. lastId ,
0 commit comments