@@ -118,22 +118,22 @@ export class CapacitorSQLiteAdapter extends BaseObserver<DBAdapterListener> impl
118118 }
119119
120120 protected generateLockContext ( db : SQLiteDBConnection ) : LockContext {
121+ const _query = async ( query : string , params : any [ ] = [ ] ) => {
122+ const result = await db . query ( query , params ) ;
123+ const arrayResult = result . values ?? [ ] ;
124+ return {
125+ rowsAffected : 0 ,
126+ rows : {
127+ _array : arrayResult ,
128+ length : arrayResult . length ,
129+ item : ( idx : number ) => arrayResult [ idx ]
130+ }
131+ } ;
132+ } ;
133+
121134 const _execute = async ( query : string , params : any [ ] = [ ] ) : Promise < QueryResult > => {
122135 const platform = Capacitor . getPlatform ( ) ;
123136
124- const _query = async ( query : string , params : any [ ] = [ ] ) => {
125- const result = await db . query ( query , params ) ;
126- const arrayResult = result . values ?? [ ] ;
127- return {
128- rowsAffected : 0 ,
129- rows : {
130- _array : arrayResult ,
131- length : arrayResult . length ,
132- item : ( idx : number ) => arrayResult [ idx ]
133- }
134- } ;
135- } ;
136-
137137 if ( db . getConnectionReadOnly ( ) ) {
138138 return _query ( query , params ) ;
139139 }
@@ -175,24 +175,9 @@ export class CapacitorSQLiteAdapter extends BaseObserver<DBAdapterListener> impl
175175 ? ( sql : string , params ?: any [ ] ) => monitorQuery ( sql , ( ) => _execute ( sql , params ) )
176176 : _execute ;
177177
178- const _executeQuery = async ( query : string , params ?: any [ ] ) : Promise < QueryResult > => {
179- let result = await db . query ( query , params ) ;
180-
181- let arrayResult = result . values ?? [ ] ;
182-
183- return {
184- rowsAffected : 0 ,
185- rows : {
186- _array : arrayResult ,
187- length : arrayResult . length ,
188- item : ( idx : number ) => arrayResult [ idx ]
189- }
190- } ;
191- } ;
192-
193178 const executeQuery = this . options . debugMode
194- ? ( sql : string , params ?: any [ ] ) => monitorQuery ( sql , ( ) => _executeQuery ( sql , params ) )
195- : _executeQuery ;
179+ ? ( sql : string , params ?: any [ ] ) => monitorQuery ( sql , ( ) => _query ( sql , params ) )
180+ : _query ;
196181
197182 const getAll = async < T > ( query : string , params ?: any [ ] ) : Promise < T [ ] > => {
198183 const result = await executeQuery ( query , params ) ;
0 commit comments