Skip to content

Commit

Permalink
Test emoji & INLINE BLOB; other parameter checks; other test/doc fixes
Browse files Browse the repository at this point in the history
ISSUES documented:
- emojis and other 4-octet UTF-8 characters on Android-sqlite-connector & Windows
  ref: storesafe#564
- INLINE BLOB values on Android-sqlite-connector & Windows
- In case of too many parameters the plugin reports INCORRECT error code 0
  (SQLError.UNKNOWN_ERR) while Android/iOS (WebKit) Web SQL reports
  correct error code
- The results data objects are not immutable as specified/implied by:
  https://www.w3.org/TR/webdatabase/#database-query-results
  • Loading branch information
Christopher J. Brody committed Sep 23, 2016
1 parent bd07f26 commit 60fefa8
Show file tree
Hide file tree
Showing 5 changed files with 656 additions and 144 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ License for Android and Windows versions: MIT or Apache 2.0

License for iOS version: MIT only

|Android Circle-CI (**full** suite)|iOS Travis-CI (*very* limited suite)|
|Android Circle-CI (**full** suite)|iOS Travis-CI (partial suite)|
|-----------------------|----------------------|
|[![Circle CI](https://circleci.com/gh/litehelpers/Cordova-sqlite-storage.svg?style=svg)](https://circleci.com/gh/litehelpers/Cordova-sqlite-storage)|[![Build Status](https://travis-ci.org/litehelpers/Cordova-sqlite-storage.svg)](https://travis-ci.org/litehelpers/Cordova-sqlite-storage)|

Expand Down Expand Up @@ -124,6 +124,8 @@ See the [Sample section](#sample) for a sample with a more detailed explanation.
- Issue with UNICODE `\u0000` character (same as `\0`)
- No background processing
- INCORRECT error code (0) and INCONSISTENT error message (missing actual error info) in error callbacks ref: [litehelpers/Cordova-sqlite-storage#539](https://github.com/litehelpers/Cordova-sqlite-storage/issues/539)
- Issue with emojis and other 4-octet UTF-8 characters (apparently not stored correctly)
- Not possible to read BLOB column values
- It is **not** possible to use this plugin with the default "Any CPU" target. A specific target CPU type **must** be specified when building an app with this plugin.
- FTS3, FTS4, and R-Tree support is tested working OK in this version (for all target platforms in this version branch Android/iOS/Windows)
- Android is supported back to SDK 10 (a.k.a. Gingerbread, Android 2.3.3); support for older versions is available upon request.
Expand Down Expand Up @@ -317,14 +319,16 @@ As "strongly recommended" by [Web SQL Database API 8.5 SQL injection](https://ww
- This plugin does *not* support the synchronous Web SQL interfaces.
- It is possible to request a SQL statement list such as "SELECT 1; SELECT 2" within a single SQL statement string, however the plugin will only execute the first statement and silently ignore the others ref: [litehelpers/Cordova-sqlite-storage#551](https://github.com/litehelpers/Cordova-sqlite-storage/issues/551)
- It is possible to insert multiple rows like: `transaction.executeSql('INSERT INTO MyTable VALUES (?,?),(?,?)', ['Alice', 101, 'Betty', 102]);` which was not supported by SQLite 3.6.19 as referenced by [Web SQL API section 5](https://www.w3.org/TR/webdatabase/#web-sql). The iOS WebKit Web SQL implementation seems to support this as well.
- Unlike the HTML5/[Web SQL API](http://www.w3.org/TR/webdatabase/) this plugin handles executeSql calls with too few parameters without error reporting.
- Unlike the HTML5/[Web SQL API](http://www.w3.org/TR/webdatabase/) this plugin handles executeSql calls with too few parameters without error reporting. In case of too many parameters this plugin reports error code 0 (SQLError.UNKNOWN_ERR) while Android/iOS (WebKit) Web SQL correctly reports error code 5 (SQLError.SYNTAX_ERR) ref: https://www.w3.org/TR/webdatabase/#dom-sqlexception-code-syntax
- Known issue(s) with handling of `Infinity` values (positive or negative) and certain ASCII/UNICODE characters as described below.
- Boolean `true` and `false` values are handled by converting them to the "true" and "false" TEXT string values, same as WebKit Web SQL on Android and iOS. This does not seem to be 100% correct as discussed in: [litehelpers/Cordova-sqlite-storage#545](https://github.com/litehelpers/Cordova-sqlite-storage/issues/545)
- Certain errors such as CREATE VIRTUAL TABLE USING bogus module are reported with error code 5 (SQLError.SYNTAX_ERR) on Android and iOS. This happens to be the case for WebKit Web SQL (Android/iOS).
- A number of uncategorized errors are reported with error code 5 (SQLError.SYNTAX_ERR) on Android and iOS by both WebKit Web SQL and this plugin.
- Issues with error code on Windows as well as Android with the `androidDatabaseImplementation: 2` setting described below.
- In case of an issue that causes an API function to throw an exception (Android/iOS WebKit) Web SQL includes includes a code member with value of 0 (SQLError.UNKNOWN_ERR) in the exception while the plugin includes no such code member.
- This plugin supports some non-standard features as documented below.
- Results of SELECT with BLOB data such as `SELECT LOWER(X'40414243') AS myresult`, `SELECT X'40414243' AS myresult`, or reading data stored by `INSERT INTO MyTable VALUES (X'40414243')` are not consistent on Android in case the built-in Android database is used (using the `androidDatabaseImplementation: 2` setting in `window.sqlitePlugin.openDatabase`) or Windows. (These work with Android/iOS WebKit Web SQL and have been supported by SQLite for a number of years.)
- The results data objects are not immutable as specified/implied by [Web SQL API section 4.5](https://www.w3.org/TR/webdatabase/#database-query-results).

### Security of deleted data

Expand All @@ -343,7 +347,8 @@ See **Security of sensitive data** in the [Security](#security) section above.

- iOS version does not support certain rapidly repeated open-and-close or open-and-delete test scenarios due to how the implementation handles background processing
- As described below, auto-vacuum is NOT enabled by default.
- INSERT statement that affects multiple rows (due to SELECT cause or using TRIGGER(s), for example) does not report proper rowsAffected on Android in case the built-in Android database used (using the `androidDatabaseImplementation` option in `window.sqlitePlugin.openDatabase`)
- The Android and Windows versions do not always handle four-byte UTF-8 characters emoji characters such as `\u1F603` (SMILING FACE, MOUTH OPEN) correctly ref: [litehelpers/Cordova-sqlite-storage#564](https://github.com/litehelpers/Cordova-sqlite-storage/issues/564). It is sometimes possible to store and retrieve such characters but certain operations hex conversions do not work properly with the default [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) database implementation. It is suspected that such characters would be stored incorrectly in the Android and Windows versions. This is not an issue in case the built-in Android database is used (using the `androidDatabaseImplementation: 2` setting in `window.sqlitePlugin.openDatabase`)
- INSERT statement that affects multiple rows (due to SELECT cause or using TRIGGER(s), for example) reports incorrect rowsAffected on Android in case the built-in Android database used (using the `androidDatabaseImplementation` option in `window.sqlitePlugin.openDatabase`)
- Memory issue observed when adding a large number of records due to the JSON implementation which is improved in [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (available with GPL or commercial license options)
- Infinity (positive or negative) values are not supported (known to be broken on Android, may cause a crash on iOS ref: [litehelpers/Cordova-sqlite-storage#405](https://github.com/litehelpers/Cordova-sqlite-storage/issues/405))
- A stability issue was reported on the iOS version when in use together with [SockJS](http://sockjs.org/) client such as [pusher-js](https://github.com/pusher/pusher-js) at the same time (see [litehelpers/Cordova-sqlite-storage#196](https://github.com/litehelpers/Cordova-sqlite-storage/issues/196)). The workaround is to call sqlite functions and [SockJS](http://sockjs.org/) client functions in separate ticks (using setTimeout with 0 timeout).
Expand All @@ -352,7 +357,7 @@ See **Security of sensitive data** in the [Security](#security) section above.
- Close/delete database bugs described below.
- When a database is opened and deleted without closing, the iOS version is known to leak resources.
- It is NOT possible to open multiple databases with the same name but in different locations (iOS version).
- Incorrect or missing insertId/rowsAffected in results for INSERT/UPDATE/DELETE SQL statements with extra semicolon(s) in the beginning for Android in case the `androidDatabaseImplementation: 2` (built-in android.database implementation) option is used.
- Incorrect or missing rowsAffected in results for INSERT/UPDATE/DELETE SQL statements with extra semicolon(s) in the beginning for Android in case the `androidDatabaseImplementation: 2` (built-in android.database implementation) option is used.

Some more known issues are tracked in the [open Cordova-sqlite-storage bugs](https://github.com/litehelpers/Cordova-sqlite-storage/issues?q=is%3Aissue+is%3Aopen+label%3Abug).

Expand Down Expand Up @@ -402,7 +407,7 @@ Some more limitations are tracked in the [open Cordova-sqlite-storage documentat
- Delete an open database inside a statement or transaction callback.
- WITH clause (not supported by some older sqlite3 versions)
- _Handling of invalid transaction and transaction.executeSql arguments_
- _Emojis and other 4-octet UTF-8 characters_
- More emojis and other 4-octet UTF-8 characters

<!-- END Further testing needed -->

Expand Down
14 changes: 7 additions & 7 deletions spec/www/spec/db-tx-error-handling-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ var mytests = function() {
expect(ex.message).toBeDefined();

if (!isWebSql)
expect(ex.code).toBe(0); // [UNKNOWN_ERR]
expect(ex.code).toBe(0); // (SQLite.UNKNOWN_ERR)

if (!isWebSql)
expect(ex.message).toMatch(/transaction expected a function/);
Expand Down Expand Up @@ -441,7 +441,7 @@ var mytests = function() {
expect(ex.message).toBeDefined();

if (!isWebSql)
expect(ex.code).toBe(0); // [UNKNOWN_ERR]
expect(ex.code).toBe(0); // (SQLite.UNKNOWN_ERR)

if (!isWebSql)
expect(ex.message).toMatch(/transaction expected a function/);
Expand Down Expand Up @@ -580,7 +580,7 @@ var mytests = function() {
else if (isWebSql)
expect(error.message).toMatch(/the SQLTransactionCallback was null or threw an exception/);
else if (isAndroid)
expect(error.message).toMatch(/Cannot call method 'toString' of undefined/);
expect(error.message).toMatch(/Cannot .* 'toString' of undefined/);
else
expect(error.message).toMatch(/undefined is not an object \(evaluating 'sql\.toString'\)/);

Expand Down Expand Up @@ -969,7 +969,7 @@ var mytests = function() {
else if (isWindows)
expect(error.message).toMatch(/Unable to get property 'toString' of undefined or null reference/);
else if (isAndroid)
expect(error.message).toMatch(/Cannot call method 'toString' of null/);
expect(error.message).toMatch(/Cannot .* 'toString' of null/);
else
expect(error.message).toMatch(/null is not an object \(evaluating 'sql\.toString'\)/);

Expand Down Expand Up @@ -1155,7 +1155,7 @@ var mytests = function() {
else if (isWindows)
expect(error.message).toMatch(/Unable to get property 'toString' of undefined or null reference/);
else if (isAndroid)
expect(error.message).toMatch(/Cannot call method 'toString' of undefined/);
expect(error.message).toMatch(/Cannot .* 'toString' of undefined/);
else
expect(error.message).toMatch(/undefined is not an object \(evaluating 'sql\.toString'\)/);

Expand Down Expand Up @@ -1215,7 +1215,7 @@ var mytests = function() {
else if (isWindows)
expect(ex.message).toMatch(/Unable to get property 'toString' of undefined or null reference/);
else if (!isWebSql && isAndroid)
expect(ex.message).toMatch(/Cannot call method 'toString' of undefined/);
expect(ex.message).toMatch(/Cannot .* 'toString' of undefined/);
else if (!isWebSql)
expect(ex.message).toMatch(/undefined is not an object \(evaluating 'sql\.toString'\)/);
else if (isAndroid)
Expand All @@ -1239,7 +1239,7 @@ var mytests = function() {
else if (isWindows)
expect(error.message).toMatch(/Unable to get property 'toString' of undefined or null reference/);
else if (!isWebSql && isAndroid)
expect(error.message).toMatch(/Cannot call method 'toString' of undefined/);
expect(error.message).toMatch(/Cannot .* 'toString' of undefined/);
else if (!isWebSql)
expect(error.message).toMatch(/undefined is not an object \(evaluating 'sql\.toString'\)/);
else
Expand Down
Loading

0 comments on commit 60fefa8

Please sign in to comment.