Skip to content

Commit e15f1cb

Browse files
author
Christopher J. Brody
committed
test & doc INCONSISTENT error message formatting
on Android (with android-database-sqlcipher) ref: #95
1 parent 90d69c0 commit e15f1cb

File tree

2 files changed

+35
-66
lines changed

2 files changed

+35
-66
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ See **Security of sensitive data** in the [Security](#security) section above.
495495
- In case of ignored INSERT OR IGNORE statement WebKit Web SQL (Android/iOS) reports insertId with an old INSERT row id value while the plugin reports insertId: undefined.
496496
- In case of a SQL error handler that does not recover the transaction, WebKit Web SQL (Android/iOS) would incorrectly report error code 0 while the plugin would report the same error code as in the SQL error handler. (In case of an error with no SQL error handler then Android/iOS WebKit Web SQL would report the same error code that would have been reported in the SQL error hander.)
497497
- In case a transaction function throws an exception, the message and code if present are reported by the plugin but *not* by (WebKit) Web SQL.
498+
- Inconsistent error message formatting on Android (using custom build of [`sqlcipher/android-database-sqlcipher`](https://github.com/sqlcipher/android-database-sqlcipher)) ([brodybits/cordova-sqlcipher-adapter#95](https://github.com/brodybits/cordova-sqlcipher-adapter/issues/95)), for example: `incomplete input: , while compiling: INSERT INTO test_table .data. VALUES`
498499
- SQL error messages are inconsistent on Windows.
499500
- There are some other differences in the SQL error messages reported by WebKit Web SQL and this plugin. NOTE that unlike the android.database.sqlite implementation on Android 4.x(+) SQLCipher for Android does not seem to include the error code in most of the error message.
500501

spec/www/spec/db-tx-error-mapping-test.js

+34-66
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ var mytests = function() {
2727
// TBD QUICK TEST WORKAROUND for Android:
2828
if (!isWindows && isAndroid && i === 0) continue;
2929

30-
// GENERAL: SKIP ALL on WP8 for now
31-
describe(scenarioList[i] + ': db tx error mapping test(s)' +
32-
((isWindows && !isWP8) ?
33-
' [Windows version with INCORRECT error code (0) & INCONSISTENT error message (missing actual error info)]' :
34-
''), function() {
30+
describe(scenarioList[i] + ': db tx error mapping test(s) [TBD INCORRECT & INCONSISTENT error message on Windows - missing actual error info ref: litehelpers/Cordova-sqlite-storage#539]', function() {
3531
var scenarioName = scenarioList[i];
3632
var suiteName = scenarioName + ': ';
3733
var isWebSql = (i === 1);
@@ -84,9 +80,7 @@ var mytests = function() {
8480

8581
// GENERAL NOTE: ERROR MESSAGES are subject to improvements and other possible changes.
8682

87-
it(suiteName + 'syntax error: command with misspelling', function(done) {
88-
if (isWP8) pending('SKIP for WP(8)'); // SKIP for now
89-
83+
it(suiteName + 'syntax error: command with misspelling [INCONSISTENT error message formatting on Android (android-database-sqlcipher)]', function(done) {
9084
var db = openDatabase("Syntax-error-test.db", "1.0", "Demo", DEFAULT_SIZE);
9185
expect(db).toBeDefined();
9286

@@ -119,12 +113,9 @@ var mytests = function() {
119113
expect(error.message).toMatch(/could not prepare statement.*1 near \"SLCT\": syntax error/);
120114
else if (isWindows)
121115
expect(error.message).toMatch(/Error preparing an SQLite statement/);
122-
else if (isAndroid && !isImpl2)
123-
expect(error.message).toMatch(/sqlite3_prepare_v2 failure:.*near \"SLCT\": syntax error/);
124-
/* ** TBD QUICK TEST WORKAROUND for Android [SQLCipher for Android error message missing error code]:
125-
else if (isAndroid && isImpl2)
126-
expect(error.message).toMatch(/near \"SLCT\": syntax error.*code 1.*while compiling: SLCT 1/);
127-
// TBD END of QUICK TEST WORKAROUND */
116+
else if (isAndroid) // (android-database-sqlcipher)
117+
// INCONSISTENT error message formatting on Android (...)
118+
expect(error.message).toMatch(/near .SLCT.: syntax error: , while compiling: SLCT 1/);
128119
else
129120
expect(error.message).toMatch(/near \"SLCT\": syntax error/);
130121

@@ -163,9 +154,7 @@ var mytests = function() {
163154
});
164155
}, MYTIMEOUT);
165156

166-
it(suiteName + 'INSERT syntax error [VALUES in the wrong place] with a trailing space [XXX TBD ...]', function(done) {
167-
// if (isWP8) pending('...') TBD GONE (not needed)
168-
157+
it(suiteName + 'INSERT with VALUES in the wrong place (and with a trailing space) [INCONSISTENT error message formatting on Android (android-database-sqlcipher); TBD "incomplete input" vs "syntax error" message IGNORED on (WebKit) Web SQL on Android 7.0(+) & iOS 12.0(+)]', function(done) {
169158
var db = openDatabase("INSERT-Syntax-error-test.db", "1.0", "Demo", DEFAULT_SIZE);
170159
expect(db).toBeDefined();
171160

@@ -201,6 +190,9 @@ var mytests = function() {
201190
expect(error.message).toMatch(/could not prepare statement.*/); // XXX TBD (...)
202191
else if (isWindows)
203192
expect(error.message).toMatch(/Error preparing an SQLite statement/);
193+
else if (isAndroid) // (android-database-sqlcipher)
194+
// TBD INCONSISTENT ERROR MESSAGE:
195+
expect(error.message).toMatch(/incomplete input: , while compiling: INSERT INTO test_table .data. VALUES/);
204196
else
205197
expect(error.message).toMatch(/incomplete input/); // XXX TBD (...)
206198

@@ -227,6 +219,9 @@ var mytests = function() {
227219
expect(error.message).toMatch(/callback raised an exception.*or.*error callback did not return false/);
228220
else if (isWindows)
229221
expect(error.message).toMatch(/error callback did not return false.*Error preparing an SQLite statement/);
222+
else if (isAndroid) // (android-database-sqlcipher)
223+
// TBD INCONSISTENT ERROR MESSAGE:
224+
expect(error.message).toMatch(/error callback did not return false: incomplete input: , while compiling: INSERT/);
230225
//* else // XXX TBD (...)
231226
//* expect(error.message).toMatch(...)
232227

@@ -290,10 +285,8 @@ var mytests = function() {
290285
expect(error.message).toMatch(/SQLite3 step error result code: 1/);
291286
else if (isAndroid && !isImpl2)
292287
expect(error.message).toMatch(/sqlite3_step failure: UNIQUE constraint failed: test_table\.data/);
293-
/* ** TBD QUICK TEST WORKAROUND for Android [SQLCipher for Android error message missing error code]:
294-
else if (isAndroid && isImpl2)
295-
expect(error.message).toMatch(/constraint failure/);
296-
// TBD END of QUICK TEST WORKAROUND */
288+
else if (isAndroid) // (android-database-sqlcipher)
289+
expect(error.message).toMatch(/constraint failure: error code 19: UNIQUE constraint failed: test_table.data/);
297290
else
298291
expect(error.message).toMatch(/UNIQUE constraint failed: test_table\.data/);
299292

@@ -332,7 +325,7 @@ var mytests = function() {
332325
});
333326
}, MYTIMEOUT);
334327

335-
it(suiteName + 'SELECT uper("Test") (misspelled function name) [INCORRECT error code WebKit Web SQL & plugin]', function(done) {
328+
it(suiteName + 'SELECT uper("Test") (misspelled function name) [INCONSISTENT error message formatting on Android (android-database-sqlcipher); INCORRECT error code WebKit Web SQL & plugin]', function(done) {
336329
if (isWP8) pending('SKIP for WP(8)'); // FUTURE TBD
337330

338331
var db = openDatabase("Misspelled-function-name-error-test.db", "1.0", "Demo", DEFAULT_SIZE);
@@ -368,12 +361,9 @@ var mytests = function() {
368361
expect(error.message).toMatch(/could not prepare statement.*1 no such function: uper/);
369362
else if (isWindows)
370363
expect(error.message).toMatch(/Error preparing an SQLite statement/);
371-
else if (isAndroid && !isImpl2)
372-
expect(error.message).toMatch(/sqlite3_prepare_v2 failure:.*no such function: uper/);
373-
/* ** TBD QUICK TEST WORKAROUND for Android [SQLCipher for Android error message missing error code]:
374-
else if (isAndroid && isImpl2)
375-
expect(error.message).toMatch(/no such function: uper.*code 1/);
376-
// TBD END of QUICK TEST WORKAROUND */
364+
else if (isAndroid) // (android-database-sqlcipher)
365+
// INCONSISTENT error message formatting on Android (...)
366+
expect(error.message).toMatch(/no such function: uper: , while compiling: SELECT uper..Test/);
377367
else
378368
expect(error.message).toMatch(/no such function: uper/);
379369

@@ -412,9 +402,7 @@ var mytests = function() {
412402
});
413403
}, MYTIMEOUT);
414404

415-
it(suiteName + 'SELECT FROM bogus table (other database error) [INCORRECT error code WebKit Web SQL & plugin]', function(done) {
416-
if (isWP8) pending('SKIP for WP(8)'); // FUTURE TBD
417-
405+
it(suiteName + 'SELECT FROM bogus table (other database error) [INCONSISTENT error message formatting on Android (android-database-sqlcipher); INCORRECT error code WebKit Web SQL & plugin]', function(done) {
418406
var db = openDatabase("SELECT-FROM-bogus-table-error-test.db", "1.0", "Demo", DEFAULT_SIZE);
419407
expect(db).toBeDefined();
420408

@@ -448,12 +436,9 @@ var mytests = function() {
448436
expect(error.message).toMatch(/could not prepare statement.*1 no such table: BogusTable/);
449437
else if (isWindows)
450438
expect(error.message).toMatch(/Error preparing an SQLite statement/);
451-
else if (isAndroid && !isImpl2)
452-
expect(error.message).toMatch(/sqlite3_prepare_v2 failure:.*no such table: BogusTable/);
453-
/* ** TBD QUICK TEST WORKAROUND for Android [SQLCipher for Android error message missing error code]:
454-
else if (isAndroid && isImpl2)
455-
expect(error.message).toMatch(/no such table: BogusTable.*code 1/);
456-
// TBD END of QUICK TEST WORKAROUND */
439+
else if (isAndroid) // (android-database-sqlcipher)
440+
// TBD INCONSISTENT ERROR MESSAGE:
441+
expect(error.message).toMatch(/no such table: BogusTable: , while compiling: SELECT . FROM BogusTable/);
457442
else
458443
expect(error.message).toMatch(/no such table: BogusTable/);
459444

@@ -491,9 +476,7 @@ var mytests = function() {
491476
});
492477
}, MYTIMEOUT);
493478

494-
it(suiteName + 'INSERT missing column [INCORRECT error code WebKit Web SQL & plugin]', function(done) {
495-
if (isWP8) pending('SKIP for WP(8)'); // FUTURE TBD
496-
479+
it(suiteName + 'INSERT missing column [INCONSISTENT error message formatting on Android (android-database-sqlcipher); INCORRECT error code WebKit Web SQL & plugin]', function(done) {
497480
var db = openDatabase("INSERT-missing-column-test.db", "1.0", "Demo", DEFAULT_SIZE);
498481
expect(db).toBeDefined();
499482

@@ -528,12 +511,9 @@ var mytests = function() {
528511
expect(error.message).toMatch(/could not prepare statement.*1 table test_table has 2 columns but 1 values were supplied/);
529512
else if (isWindows)
530513
expect(error.message).toMatch(/Error preparing an SQLite statement/);
531-
else if (isAndroid && !isImpl2)
532-
expect(error.message).toMatch(/sqlite3_prepare_v2 failure:.*table test_table has 2 columns but 1 values were supplied/);
533-
/* ** TBD QUICK TEST WORKAROUND for Android [SQLCipher for Android error message missing error code]:
534-
else if (isAndroid && isImpl2)
535-
expect(error.message).toMatch(/table test_table has 2 columns but 1 values were supplied.*code 1.*while compiling: INSERT INTO test_table/);
536-
// TBD END of QUICK TEST WORKAROUND */
514+
else if (isAndroid) // (android-database-sqlcipher)
515+
// INCONSISTENT error message formatting on Android (...)
516+
expect(error.message).toMatch(/table test_table has 2 columns but 1 values were supplied: , while compiling: INSERT INTO test_table/);
537517
else
538518
expect(error.message).toMatch(/table test_table has 2 columns but 1 values were supplied/);
539519

@@ -572,9 +552,7 @@ var mytests = function() {
572552
});
573553
}, MYTIMEOUT);
574554

575-
it(suiteName + 'INSERT wrong column name [INCORRECT error code WebKit Web SQL & plugin]', function(done) {
576-
if (isWP8) pending('SKIP for WP(8)'); // FUTURE TBD
577-
555+
it(suiteName + 'INSERT wrong column name [INCONSISTENT error message formatting on Android (android-database-sqlcipher); INCORRECT error code WebKit Web SQL & plugin]', function(done) {
578556
var db = openDatabase("INSERT-wrong-column-name-test.db", "1.0", "Demo", DEFAULT_SIZE);
579557
expect(db).toBeDefined();
580558

@@ -609,12 +587,9 @@ var mytests = function() {
609587
expect(error.message).toMatch(/could not prepare statement.*1 table test_table has no column named wrong_column/);
610588
else if (isWindows)
611589
expect(error.message).toMatch(/Error preparing an SQLite statement/);
612-
else if (isAndroid && !isImpl2)
613-
expect(error.message).toMatch(/sqlite3_prepare_v2 failure:.*table test_table has no column named wrong_column/);
614-
/* ** TBD QUICK TEST WORKAROUND for Android [SQLCipher for Android error message missing error code]:
615-
else if (isAndroid && isImpl2)
616-
expect(error.message).toMatch(/table test_table has no column named wrong_column.*code 1.*while compiling: INSERT INTO test_table/);
617-
// TBD END of QUICK TEST WORKAROUND */
590+
else if (isAndroid) // (android-database-sqlcipher)
591+
// INCONSISTENT error message formatting on Android (...)
592+
expect(error.message).toMatch(/table test_table has no column named wrong_column: , while compiling: INSERT INTO test_table/);
618593
else
619594
expect(error.message).toMatch(/table test_table has no column named wrong_column/);
620595

@@ -694,8 +669,6 @@ var mytests = function() {
694669
expect(error.message).toMatch(/could not prepare statement.*1 not authorized/);
695670
else if (isWindows)
696671
expect(error.message).toMatch(/SQLite3 step error result code: 1/);
697-
else if (isAndroid && !isImpl2)
698-
expect(error.message).toMatch(/sqlite3_step failure: no such module: bogus/);
699672
/* ** TBD QUICK TEST WORKAROUND for Android [SQLCipher for Android error message missing error code]:
700673
else if (isAndroid && isImpl2)
701674
expect(error.message).toMatch(/no such module: bogus.*code 1/);
@@ -739,9 +712,7 @@ var mytests = function() {
739712

740713
// TESTS with no SQL error handler:
741714

742-
it(suiteName + 'transaction.executeSql syntax error (command with misspelling) with no SQL error handler', function(done) {
743-
if (isWP8) pending('SKIP for WP(8)'); // FUTURE TBD
744-
715+
it(suiteName + 'transaction.executeSql syntax error (command with misspelling) with no SQL error handler [INCONSISTENT error message formatting on Android (android-database-sqlcipher)]', function(done) {
745716
db = openDatabase('tx-sql-syntax-error-with-no-sql-error-handler-test.db');
746717
db.transaction(function(transaction) {
747718
transaction.executeSql('SLCT 1');
@@ -765,12 +736,9 @@ var mytests = function() {
765736
expect(error.message).toMatch(/could not prepare statement.*1 near \"SLCT\": syntax error/);
766737
else if (isWindows)
767738
expect(error.message).toMatch(/a statement with no error handler failed: Error preparing an SQLite statement/);
768-
else if (isAndroid && !isImpl2)
769-
expect(error.message).toMatch(/sqlite3_prepare_v2 failure:.*near \"SLCT\": syntax error/);
770-
/* ** TBD QUICK TEST WORKAROUND for Android [SQLCipher for Android error message missing error code]:
771-
else if (isAndroid && isImpl2)
772-
expect(error.message).toMatch(/a statement with no error handler failed: near \"SLCT\": syntax error.*code 1.*while compiling: SLCT 1/);
773-
// TBD END of QUICK TEST WORKAROUND */
739+
else if (isAndroid) // (android-database-sqlcipher)
740+
// INCONSISTENT error message formatting on Android (...)
741+
expect(error.message).toMatch(/a statement with no error handler failed: near .SLCT.: syntax error: , while compiling: SLCT 1/);
774742
else
775743
expect(error.message).toMatch(/a statement with no error handler failed.*near \"SLCT\": syntax error/);
776744

0 commit comments

Comments
 (0)