Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70804

Ionic capacitor android: SQLite plugin - executeSql API always returns a rejected promise

$
0
0

ionic version - 6.18.1
cordova --version: 11.0.0
Angular CLI: 13.1.4
Android: 12 (SDK: 31)

executeSql API always returns a rejected promise even for successful execution of queries. For instance, the following table creation returns an error but the table is created successfully - I’ve verified this by downloading the .db file and opening it with DB Browser for SQLite.

query = `CREATE TABLE IF NOT EXISTS test_table 
                 id INTEGER PRIMARY KEY NOT NULL,
                 col1 INTEGER NULL DEFAULT NULL,
                 col2 CHAR(20) NULL DEFAULT NULL,
                 col3 CHAR(20) NULL DEFAULT NULL,`
        this.dbEngine
            .executeSql(query)
            .then(() => {
                console.log('Table created');
            })
            .catch((e) => {
                console.log(`Table creation error: ${JSON.stringify(e)}`);
            });

Android Logcat has the following output:

Msg: Table creation error: {"rows":{"length":0},"rowsAffected":0}

I have also verified successful insertions into the table but the promise is always returned as rejected. Any query executed with executeSql returns as rejected. But the same query executed with sqlBatch returns a resolved promise.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 70804

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>