fix: capacitor driver PRAGMA bug (#11467)

* fix: capacitor driver PRAGMA bug

add usage of query method for PRAGMA queries in CapacitorQueryRunner.ts;
add usage of execute method for PRAGMA queries in CapacitorDriver.ts;
PRAGMA statements must be executed with query method in CapacitorQueryRunner.ts to be able to return results used in AbstractSqliteQueryRunner, not just success indicator, otherwise error appears: tableColumn.type.indexOf is not a function.;
PRAGMA statements must be executed with execute method in CapacitorDriver.ts, otherwise error appears: prepareSQL step failed rc: 100 message: another row available

* fix: npm format
This commit is contained in:
Alex Azartsev 2025-05-14 14:27:50 +02:00 committed by GitHub
parent b8dbca515e
commit d325d9e63d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 5 deletions

View File

@ -80,7 +80,7 @@ export class CapacitorDriver extends AbstractSqliteDriver {
// we need to enable foreign keys in sqlite to make sure all foreign key related features
// working properly. this also makes onDelete to work with sqlite.
await connection.run(`PRAGMA foreign_keys = ON`)
await connection.execute(`PRAGMA foreign_keys = ON`)
if (
this.options.journalMode &&
@ -88,7 +88,7 @@ export class CapacitorDriver extends AbstractSqliteDriver {
this.options.journalMode,
) !== -1
) {
await connection.run(
await connection.execute(
`PRAGMA journal_mode = ${this.options.journalMode}`,
)
}

View File

@ -81,9 +81,7 @@ export class CapacitorQueryRunner extends AbstractSqliteQueryRunner {
].indexOf(command) !== -1
) {
raw = await databaseConnection.execute(query, false)
} else if (
["INSERT", "UPDATE", "DELETE", "PRAGMA"].indexOf(command) !== -1
) {
} else if (["INSERT", "UPDATE", "DELETE"].indexOf(command) !== -1) {
raw = await databaseConnection.run(query, parameters, false)
} else {
raw = await databaseConnection.query(query, parameters || [])