Silently stops after first SQL statement in statement list
brodycj opened this issue · comments
Here is a test case that shows a possible silent data loss scenario if a statement list contains multiple INSERT statements:
it(suiteName + 'INSERT statement list (NOT covered by Web SQL standard) - ' +
(isWebSql ? 'Web SQL ERROR' : 'PLUGIN DEVIATION WITH DATA LOSS'), function(done) {
var db = openDatabase('INSERT-statement-list-test.db', '1.0', 'Test', DEFAULT_SIZE);
db.transaction(function(tx) {
tx.executeSql('DROP TABLE IF EXISTS TestList;');
tx.executeSql('CREATE TABLE TestList (data);');
// NOT supported by Web SQL, plugin BROKEN:
tx.executeSql('INSERT INTO TestList VALUES (1); INSERT INTO TestList VALUES(2);');
}, function(error) {
// ERROR RESULT (expected for Web SQL):
if (!isWebSql)
expect('Plugin behavior changed').toBe('--');
expect(error).toBeDefined();
// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
}, function() {
if (isWebSql)
expect('Unexpected result for Web SQL').toBe('--');
db.transaction(function(tx2) {
tx2.executeSql('SELECT * FROM TestList', [], function(ignored, resultSet) {
// CORRECT RESULT:
//expect(resultSet.rows.length).toBe(2);
// ACTUAL RESULT for plugin WITH DATA LOSS:
expect(resultSet.rows.length).toBe(1);
// FIRST ROW CORRECT:
expect(resultSet.rows.item(0).data).toBe(1);
// SECOND ROW MISSING:
//expect(resultSet.rows.item(1).data).toBe(2);
// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
});
});
}, MYTIMEOUT);
(WebKit) Web SQL rejects such a SQL statement list. The plugin should also reject such a SQL statement list and report an error.
To fix for iOS should be straightforward: When calling sqlite3_prepare_v2 check
the OUT pzTail
pointer to ensure there is no other statement afterwards. (And test what happens if a user adds one or more extra semicolons, with and without extra spaces in between, in both Web SQL and plugin.) This is expected to be more difficult for Android and Windows due to the extra library layers involved.
Hi,
I am developing on a project that could actually benefit from the capability of running multiple statements within the same query.
Is there any chance to add support for the capability rather than just throwing an exception as described in #685 ?