storesafe/cordova-sqlcipher-adapter

Inconsistent error message formatting on Android (with android-database-sqlcipher)

brodybits opened this issue · 0 comments

for example: table test_table has no column named wrong_column: , while compiling: INSERT INTO test_table

Here is an example of a more consistent error message from android-database-sqlcipher, as verified by test suite on this plugin: constraint failure: error code 19: UNIQUE constraint failed: test_table.data

Here is a test case that reproduces this issue on Android (updated):

  it(suiteName + 'INSERT wrong column name', function(done) {
    var db = window.sqlitePlugin.openDatabase({
      name: 'INSERT-wrong-column-name-test.db',
      location: 'default'
    });
    expect(db).toBeDefined();

    db.transaction(function(tx) {
      tx.executeSql('DROP TABLE IF EXISTS test_table');
      tx.executeSql('CREATE TABLE IF NOT EXISTS test_table (data)');

      tx.executeSql('INSERT INTO test_table (wrong_column) VALUES (123)', null, function(tx) {
        // NOT EXPECTED:
        done.fail();
      }, function(tx, error) {
        expect(error).toBeDefined();
        expect(error.code).toBeDefined();
        expect(error.message).toBeDefined();

        expect(error.message).toMatch(/table test_table has no column named wrong_column: , while compiling: INSERT INTO test_table/);
        done();
      })
    })
  })

I hope to get this resolved in sqlcipher/android-database-sqlcipher someday.


reported on sqlcipher/android-database-sqlcipher: sqlcipher/android-database-sqlcipher#502