diff --git a/.gitignore b/.gitignore index c262bb5f0..8a83f574e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ .metadata/* *.swp *~ +spec/myplugin +spec/plugins +spec/platforms diff --git a/CHANGES.md b/CHANGES.md index 8e9372129..d69f1ceef 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,12 @@ # Changes +##### cordova-sqlite-legacy-core 1.0.5 + +###### cordova-sqlite-legacy-express-core 1.0.3 + +- Resolve Java 6/7/8 concurrent map compatibility issue reported in litehelpers/Cordova-sqlite-storage#726, THANKS to pointer by @NeoLSN (Jason Yang/楊朝傑) in litehelpers/Cordova-sqlite-storage#727. +- selfTest database cleanup do not ignore close or delete error on any platforms + ##### cordova-sqlite-legacy-core 1.0.4 - New workaround solution to BUG 666: close db before opening (ignore close error) diff --git a/README.md b/README.md index 31f8414ae..f9e42f5be 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase - REGEXP (Android/iOS/macOS) - SELECT BLOB data in Base64 format (all platforms Android/iOS/macOS/Windows) - Pre-populated database (Android/iOS/macOS/Windows) -- Amazon Fire-OS is dropped due to lack of support by Cordova. Android version should be used to deploy to Fire-OS 5.0(+) devices. For reference: [cordova/cordova-discuss#32 (comment)](https://github.com/cordova/cordova-discuss/issues/32#issuecomment-167021676) +- Amazon Fire-OS is dropped due to lack of support by Cordova. Android platform version should be used to deploy to Fire-OS 5.0(+) devices. For reference: [cordova/cordova-discuss#32 (comment)](https://github.com/cordova/cordova-discuss/issues/32#issuecomment-167021676) - Windows version (using a customized version of the performant [doo / SQLite3-WinRT](https://github.com/doo/SQLite3-WinRT) C++ component) has the following known limitations: - This version branch with dependency on platform toolset libraries included by Visual Studio 2015 ref: [litehelpers/Cordova-sqlite-storage#580](https://github.com/litehelpers/Cordova-sqlite-storage/issues/580) - 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. @@ -115,6 +115,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase ## Announcements +- Resolved Java 6/7/8 concurrent map compatibility issue reported in [litehelpers/Cordova-sqlite-storage#726](https://github.com/litehelpers/Cordova-sqlite-storage/issues/726), THANKS to pointer by [@NeoLSN (Jason Yang/楊朝傑)](https://github.com/NeoLSN) in [litehelpers/Cordova-sqlite-storage#727](https://github.com/litehelpers/Cordova-sqlite-storage/issues/727). - New workaround solution to [BUG 666 (litehelpers/Cordova-sqlite-storage#666)](https://github.com/litehelpers/Cordova-sqlite-storage/issues/666) (possible transaction issue after window.location change with possible data loss): attempt to close database before opening (ignore close error) - Windows 10 (UWP) build with /SAFESEH flag on Win32 (x86) target to specify "Image has Safe Exception Handlers" as described in - Fixed iOS/macOS platform version to use [PSPDFThreadSafeMutableDictionary.m](https://gist.github.com/steipete/5928916) to avoid threading issue ref: [litehelpers/Cordova-sqlite-storage#716](https://github.com/litehelpers/Cordova-sqlite-storage/issues/716) @@ -130,7 +131,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase - Android version currently uses the lightweight [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) by default configuration (may be changed as described below). - Self-test functions to verify proper installation and operation of this plugin - More explicit `openDatabase` and `deleteDatabase` `iosDatabaseLocation` option -- Added simple sql batch function +- Added straightforward sql batch function - [MetaMemoryT / websql-promise](https://github.com/MetaMemoryT/websql-promise) now provides a Promises-based interface to both Web SQL and this plugin - [SQLCipher](https://www.zetetic.net/sqlcipher/) for Android/iOS/macOS/Windows is supported by [litehelpers / Cordova-sqlcipher-adapter](https://github.com/litehelpers/Cordova-sqlcipher-adapter) @@ -197,7 +198,7 @@ As "strongly recommended" by [Web SQL Database API 8.5 SQL injection](https://ww ## Known issues - This plugin will NOT work on `cordova-android@7` due to issue with JAR and NDK library files as discussed in [litehelpers/Cordova-sqlite-storage#729](https://github.com/litehelpers/Cordova-sqlite-storage/issues/729). -- iOS/macOS platform version does not support certain rapidly repeated open-and-close or open-and-delete test scenarios due to how the implementation handles background processing +- The iOS/macOS platform versions do 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. - 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) - Execution of 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`) @@ -219,9 +220,11 @@ As "strongly recommended" by [Web SQL Database API 8.5 SQL injection](https://ww - iOS platform version may crash if deleteDatabase is called with an object in place of the database name - readTransaction does not reject ALTER, REINDEX, and REPLACE operations - readTransaction does *not* reject modification statements with extra semicolon(s) in the beginning -- extra executeSql callbacks triggered in a transaction after a failure that was not recovered by an error callback that returns false +- extra executeSql callbacks triggered in a transaction after a failure that was not recovered by an error callback (by returning false) - does not signal an error in case of excess parameter argument values given on iOS/macOS +Some additional issues are tracked in [open Cordova-sqlite-storage bug-general issues](https://github.com/litehelpers/Cordova-sqlite-storage/issues?q=is%3Aissue+is%3Aopen+label%3Abug-general). + ## Other limitations @@ -229,24 +232,26 @@ As "strongly recommended" by [Web SQL Database API 8.5 SQL injection](https://ww - ~~The db version, display name, and size parameter values are not supported and will be ignored.~~ (No longer supported by the API) - Absolute and relative subdirectory path(s) are not tested or supported. - This plugin will not work before the callback for the 'deviceready' event has been fired, as described in **Usage**. (This is consistent with the other Cordova plugins.) -- Extremely large records are not supported by this plugin. It is recommended to store images and similar binary data in separate files. TBD: specify maximum record. For future consideration: support in a version such as [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (available with GPL or commercial license options) +- Extremely large records are not supported by this plugin. It is recommended to store images and similar binary data in separate files. TBD: specify maximum record. For future consideration: support in a version such as [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (GPL or commercial license terms). - This plugin version will not work within a web worker (not properly supported by the Cordova framework). Use within a web worker is supported for Android/iOS in [litehelpers / cordova-sqlite-evmax-ext-workers-legacy-build-free](https://github.com/litehelpers/cordova-sqlite-evmax-ext-workers-legacy-build-free) (GPL or premium commercial license terms). - In-memory database `db=window.sqlitePlugin.openDatabase({name: ':memory:', ...})` is currently not supported. - The Android platform version cannot properly support more than 100 open database files due to the threading model used. - SQL error messages reported by Windows platform version are not consistent with Android/iOS/macOS platform versions. -- UNICODE `\u2028` (line separator) and `\u2029` (paragraph separator) characters are currently not supported and known to be broken on iOS, macOS, and Android platform versions due to JSON issues reported in [Cordova bug CB-9435](https://issues.apache.org/jira/browse/CB-9435) and [cordova/cordova-discuss#57](https://github.com/cordova/cordova-discuss/issues/57). This is fixed with a workaround for iOS/macOS in: [litehelpers / Cordova-sqlite-evplus-legacy-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-free) and [litehelpers / Cordova-sqlite-evplus-legacy-attach-detach-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-attach-detach-free) (available with GPL or special commercial license options) as well as [litehelpers / Cordova-sqlite-evplus-legacy-workers-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-workers-free) (available with GPL or premium commercial license options) +- UNICODE `\u2028` (line separator) and `\u2029` (paragraph separator) characters are currently not supported and known to be broken on iOS, macOS, and Android platform versions due to JSON issues reported in [Cordova bug CB-9435](https://issues.apache.org/jira/browse/CB-9435) and [cordova/cordova-discuss#57](https://github.com/cordova/cordova-discuss/issues/57). This is fixed with a workaround for iOS/macOS in: [litehelpers / Cordova-sqlite-evplus-legacy-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-free) and [litehelpers / Cordova-sqlite-evplus-legacy-attach-detach-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-attach-detach-free) (GPL or special commercial license terms) as well as [litehelpers / Cordova-sqlite-evplus-legacy-workers-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-workers-free) (GPL or premium commercial license terms). - The BLOB data type is not fully supported by this version branch. SELECT BLOB in Base64 format is supported by [litehelpers / cordova-sqlite-ext](https://github.com/litehelpers/cordova-sqlite-ext) (permissive license terms) and [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (GPL or commercial license options). - Truncation in case of UNICODE `\u0000` (same as `\0`) character on Android (default Android-sqlite-connector database implementation) and Windows. - Case-insensitive matching and other string manipulations on Unicode characters, which is provided by optional ICU integration in the sqlite source and working with recent versions of Android, is not supported for any target platforms. -- The iOS/macOS platform version uses a thread pool but with only one thread working at a time due to "synchronized" database access +- The iOS/macOS platform version uses a thread pool but with only one thread working at a time due to "synchronized" database access. - Some large query results may be slow, also due to the JSON implementation. -- ATTACH to another database file is not supported by this version branch. Attach/detach is supported (along with the memory and iOS UNICODE `\u2028` line separator / `\u2029` paragraph separator fixes) in [litehelpers / Cordova-sqlite-evplus-legacy-attach-detach-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-attach-detach-free) (available with GPL or special commercial license terms). +- ATTACH to another database file is not supported by this version branch. Attach/detach is supported (along with the memory and iOS UNICODE `\u2028` line separator / `\u2029` paragraph separator fixes) in [litehelpers / Cordova-sqlite-evplus-legacy-attach-detach-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-attach-detach-free) (GPL or special commercial license terms). - UPDATE/DELETE with LIMIT or ORDER BY is not supported. - WITH clause is not supported on some older Android platform versions in case the `androidDatabaseImplementation: 2` (built-in android.database implementation) option is used. - User-defined savepoints are not supported and not expected to be compatible with the transaction locking mechanism used by this plugin. In addition, the use of BEGIN/COMMIT/ROLLBACK statements is not supported. - Problems have been reported when using this plugin with Crosswalk (for Android). It may help to install Crosswalk as a plugin instead of using Crosswalk to create the project. - Does not work with [axemclion / react-native-cordova-plugin](https://github.com/axemclion/react-native-cordova-plugin) since the `window.sqlitePlugin` object is *not* properly exported (ES5 feature). It is recommended to use [andpor / react-native-sqlite-storage](https://github.com/andpor/react-native-sqlite-storage) for SQLite database access with React Native Android/iOS instead. +Additional limitations are tracked in [open Cordova-sqlite-storage doc-todo issues](https://github.com/litehelpers/Cordova-sqlite-storage/issues?q=is%3Aissue+is%3Aopen+label%3Adoc-todo). + ## Further testing needed @@ -259,7 +264,7 @@ As "strongly recommended" by [Web SQL Database API 8.5 SQL injection](https://ww - Actual behavior when using SAVEPOINT(s) - R-Tree is not fully tested with Android - UNICODE characters not fully tested -- Use with TRIGGER(s), JOIN and ORDER BY RANDOM +- ORDER BY RANDOM() (ref: [litehelpers/Cordova-sqlite-storage#334](https://github.com/litehelpers/Cordova-sqlite-storage/issues/334)) - UPDATE/DELETE with LIMIT or ORDER BY (newer Android/iOS versions) - Integration with JXCore for Cordova (must be built without sqlite(3) built-in) - Delete an open database inside a statement or transaction callback. @@ -310,12 +315,22 @@ Documented in: [brodybits / Avoiding-some-Cordova-pitfalls](https://github.com/b ## Major TODOs -- Integrate with IndexedDBShim and some other libraries such as Sequelize, Squel.js, WebSqlSync, Persistence.js, Knex, etc. +- More formal documentation of API, especially for non-standard functions +- Browser platform +- IndexedDBShim adapter (possibly based on IndexedDBShim) +- Further cleanup of [support](#support) section +- Resolve or document remaining [open Cordova-sqlite-storage bugs](https://github.com/litehelpers/Cordova-sqlite-storage/issues?q=is%3Aissue+is%3Aopen+label%3Abug-general) +- Resolve [cordova-sqlite-help doc-todo issues](https://github.com/litehelpers/Cordova-sqlite-help/issues?q=is%3Aissue%20label%3Adoc-todo) and [cordova-sqlite-storage doc-todo issues](https://github.com/litehelpers/Cordova-sqlite-storage/issues?q=is%3Aissue+is%3Aopen+label%3Adoc-todo) + + ## For future considertion - Auto-vacuum option -- Browser platform +- Support for extremely large records in a version such as [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (available with GPL or commercial license options) +- Integrate with some other libraries such as Sequelize, Squel.js, WebSqlSync, Persistence.js, Knex, etc. + + ## Alternatives @@ -873,7 +888,7 @@ Other resource (apparently for Ionic 1): -## Before asking for help +## Before seeking help First steps: - Verify that you have followed the steps in [brodybits / Cordova-quick-start-checklist](https://github.com/brodybits/Cordova-quick-start-checklist) @@ -1021,6 +1036,8 @@ To run from a windows powershell (here is a sample for android target): # Adapters +**GENERAL:** The adapters described here are community maintained. + ## Lawnchair Adapter - [litehelpers / cordova-sqlite-lawnchair-adapter](https://github.com/litehelpers/cordova-sqlite-lawnchair-adapter) @@ -1029,12 +1046,16 @@ To run from a windows powershell (here is a sample for android target): - [nolanlawson / pouchdb-adapter-cordova-sqlite](https://github.com/nolanlawson/pouchdb-adapter-cordova-sqlite) +## Adapters wanted + +- IndexedDBShim adapter (possibly based on IndexedDBShim) + ## Source tree -- `SQLitePlugin.coffee.md`: platform-independent (Literate CoffeeScript, can be compiled with a recent CoffeeScript compiler) -- `www`: platform-independent Javascript as generated from `SQLitePlugin.coffee.md` (and committed!) +- `SQLitePlugin.coffee.md`: platform-independent (Literate CoffeeScript, can be compiled with a recent CoffeeScript (1.x) compiler) +- `www`: platform-independent Javascript as generated from `SQLitePlugin.coffee.md` using `coffeescript@1` (and committed!) - `src`: platform-specific source code - `node_modules`: placeholder for external dependencies - `scripts`: installation hook script to fetch the external dependencies via `npm` diff --git a/SQLitePlugin.coffee.md b/SQLitePlugin.coffee.md index d9ffc12ab..a82e3b7d0 100644 --- a/SQLitePlugin.coffee.md +++ b/SQLitePlugin.coffee.md @@ -874,24 +874,20 @@ , (tx2_err) -> SelfTest.finishWithError errorcb, "readTransaction error: #{tx2_err}" + , () -> - # CLEANUP & FINISH: - db.close () -> - SQLiteFactory.deleteDatabase {name: SelfTest.DBNAME, location: 'default'}, successcb, (cleanup_err)-> - # TBD IGNORE THIS ERROR on Windows (and WP8): - if /Windows /.test(navigator.userAgent) or /IEMobile/.test(navigator.userAgent) - console.log "IGNORE CLEANUP (DELETE) ERROR: #{JSON.stringify cleanup_err} (Windows/WP8)" - successcb() + + # CLEANUP & FINISH: + db.close () -> + SelfTest.cleanupAndFinish successcb, errorcb + return + + , (close_err) -> + # DO NOT IGNORE CLOSE ERROR ON ANY PLATFORM: + SelfTest.finishWithError errorcb, "close error: #{close_err}" return - SelfTest.finishWithError errorcb, "Cleanup error: #{cleanup_err}" - , (close_err) -> - # TBD IGNORE THIS ERROR on Windows (and WP8): - if /Windows /.test(navigator.userAgent) or /IEMobile/.test(navigator.userAgent) - console.log "IGNORE close ERROR: #{JSON.stringify close_err} (Windows/WP8)" - SQLiteFactory.deleteDatabase {name: SelfTest.DBNAME, location: 'default'}, successcb, successcb return - SelfTest.finishWithError errorcb, "close error: #{close_err}" , (select_err) -> SelfTest.finishWithError errorcb, "SELECT error: #{select_err}" @@ -903,13 +899,22 @@ SelfTest.finishWithError errorcb, "Open database error: #{open_err}" return + cleanupAndFinish: (successcb, errorcb) -> + SQLiteFactory.deleteDatabase {name: SelfTest.DBNAME, location: 'default'}, successcb, (cleanup_err)-> + # DO NOT IGNORE CLEANUP DELETE ERROR ON ANY PLATFORM: + SelfTest.finishWithError errorcb, "CLEANUP DELETE ERROR: #{cleanup_err}" + return + return + finishWithError: (errorcb, message) -> console.log "selfTest ERROR with message: #{message}" SQLiteFactory.deleteDatabase {name: SelfTest.DBNAME, location: 'default'}, -> errorcb newSQLError message - # FUTURE TODO: return - # FUTURE TODO log err2 - , (err2)-> errorcb newSQLError "Cleanup error: #{err2} for error: #{message}" + return + , (err2)-> + console.log "selfTest CLEANUP DELETE ERROR #{err2}" + errorcb newSQLError "CLEANUP DELETE ERROR: #{err2} for error: #{message}" + return return ## Exported API: diff --git a/package.json b/package.json index 7addf8dd4..c8723c1ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-sqlite-legacy-core", - "version": "1.0.4", + "version": "1.0.5", "description": "Native interface to SQLite for PhoneGap/Cordova (legacy core version branch)", "cordova": { "id": "cordova-sqlite-legacy-core", @@ -20,6 +20,7 @@ "ecosystem:cordova", "cordova-android", "cordova-ios", + "cordova-osx", "cordova-windows" ], "author": "various", diff --git a/plugin.xml b/plugin.xml index 2121bc60a..f88fb2b90 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.0.5"> Cordova sqlite storage plugin - legacy core version branch diff --git a/spec/config.xml b/spec/config.xml index 4177ccb82..bd3ab6fbe 100644 --- a/spec/config.xml +++ b/spec/config.xml @@ -1,7 +1,7 @@ - Cordova-sqlite-spec + cordova-sqlite-spec Runs the unit tests suite for the Cordova SQLite plugin. diff --git a/spec/platforms/.gitignore b/spec/platforms/.gitignore deleted file mode 100644 index 5e7d2734c..000000000 --- a/spec/platforms/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore everything in this directory -* -# Except this file -!.gitignore diff --git a/spec/plugins/.gitignore b/spec/plugins/.gitignore deleted file mode 100644 index 5e7d2734c..000000000 --- a/spec/plugins/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore everything in this directory -* -# Except this file -!.gitignore diff --git a/spec/www/spec/db-open-close-delete-test.js b/spec/www/spec/db-open-close-delete-test.js index b40012e44..bef8a4d5a 100755 --- a/spec/www/spec/db-open-close-delete-test.js +++ b/spec/www/spec/db-open-close-delete-test.js @@ -143,8 +143,7 @@ var mytests = function() { } } - test_it(suiteName + ' test sqlitePlugin.deleteDatabase()', function () { - stop(); + it(suiteName + ' test sqlitePlugin.deleteDatabase()', function (done) { var db = openDatabase("DB-Deletable", "1.0", "Demo", DEFAULT_SIZE); function createAndInsertStuff() { @@ -155,9 +154,14 @@ var mytests = function() { tx.executeSql('INSERT INTO test VALUES (?)', ['foo']); }); }, function (err) { - ok(false, 'create and insert tx failed with ERROR: ' + JSON.stringify(err)); + // NOT EXPECTED: console.log('create and insert tx failed with ERROR: ' + JSON.stringify(err)); - start(); + expect(false).toBe(true); + expect(err).toBeDefined(); + expect(err.message).toBeDefined(); + expect(err.message).toBe('--'); + done(); + }, function () { // check that we can read it db.transaction(function(tx) { @@ -165,9 +169,13 @@ var mytests = function() { equal(res.rows.item(0).name, 'foo'); }); }, function (err) { - ok(false, 'SELECT tx failed with ERROR: ' + JSON.stringify(err)); + // NOT EXPECTED: console.log('SELECT tx failed with ERROR: ' + JSON.stringify(err)); - start(); + expect(false).toBe(true); + expect(err).toBeDefined(); + expect(err.message).toBeDefined(); + expect(err.message).toBe('--'); + done(); }, function () { deleteAndConfirmDeleted(); }); @@ -182,30 +190,38 @@ var mytests = function() { db.transaction(function (tx) { tx.executeSql('SELECT name FROM test', []); }, function (err) { - ok(true, 'got an expected transaction error'); + // EXPECTED RESULT: + expect(err).toBeDefined(); + expect(err.message).toBeDefined(); testDeleteError(); }, function () { + // SUCCESS CALLBACK NOT EXPECTED: console.log('UNEXPECTED SUCCESS: expected a transaction error'); - ok(false, 'expected a transaction error'); - start(); + expect(false).toBe(true); + done(); }); }, function (err) { + // NOT EXPECTED - DO NOT IGNORE ON ANY PLATFORM: console.log("ERROR: " + JSON.stringify(err)); - ok(false, 'error: ' + err); - start(); + expect(false).toBe(true); + expect(err).toBeDefined(); + expect(err.message).toBeDefined(); + expect(err.message).toBe('--'); + done(); }); } function testDeleteError() { // should throw an error if the db doesn't exist deleteDatabase("Foo-Doesnt-Exist", function () { + // SUCCESS CALLBACK NOT EXPECTED: console.log('UNEXPECTED SUCCESS: expected a delete error'); - ok(false, 'expected error'); - start(); + expect(false).toBe(true); + done(); }, function (err) { - ok(!!err, 'got error like we expected'); - - start(); + // EXPECTED RESULT: + expect(err).toBeDefined(); + done(); }); } diff --git a/spec/www/spec/db-tx-string-test.js b/spec/www/spec/db-tx-string-test.js index 5e8e10415..9926f07c1 100755 --- a/spec/www/spec/db-tx-string-test.js +++ b/spec/www/spec/db-tx-string-test.js @@ -229,6 +229,7 @@ var mytests = function() { if (isWP8) pending('BROKEN on WP(8)'); // [BUG #202] UNICODE characters not working with WP(8) if (!isWebSql && !isWindows && isAndroid) pending('SKIP for Android plugin (cordova-android 6.x BUG: cordova/cordova-discuss#57)'); if (!isWebSql && !isWindows && !isAndroid && !isWP8) pending('SKIP for iOS/macOS plugin (Cordova BUG: CB-9435)'); + if (isWebSql && !isWindows && isAndroid) pending('SKIP for Android Web SQL'); // TBD SKIP for Android Web for now // NOTE: since the above test shows the UNICODE line separator (\u2028) // is seen by the sqlite implementation OK, it is now concluded that diff --git a/spec/www/spec/db-tx-value-bindings-test.js b/spec/www/spec/db-tx-value-bindings-test.js index ae27f6f6b..406520353 100755 --- a/spec/www/spec/db-tx-value-bindings-test.js +++ b/spec/www/spec/db-tx-value-bindings-test.js @@ -352,11 +352,13 @@ var mytests = function() { // we would like to know, so the test is coded to fail if it starts // working there. if(isWebSql) { + /* SKIP IN THIS VERSION BRANCH: ok(expected.indexOf(name) === -1, 'field value: ' + JSON.stringify(name) + ' should not be in this until a bug is fixed ' + JSON.stringify(expected)); equal(name.length, 0, 'length of field === 0'); + // */ start(); return; } diff --git a/src/android/io/sqlc/SQLitePlugin.java b/src/android/io/sqlc/SQLitePlugin.java index 55e34ec78..dad0c034f 100755 --- a/src/android/io/sqlc/SQLitePlugin.java +++ b/src/android/io/sqlc/SQLitePlugin.java @@ -8,15 +8,18 @@ import android.annotation.SuppressLint; -import android.util.Base64; import android.util.Log; import java.io.File; + import java.lang.IllegalArgumentException; import java.lang.Number; -import java.util.concurrent.ConcurrentHashMap; + +import java.util.Map; import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.LinkedBlockingQueue; + import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,19 +30,24 @@ import org.json.JSONException; import org.json.JSONObject; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.IOException; - public class SQLitePlugin extends CordovaPlugin { /** * Multiple database runner map (static). - * NOTE: no public static accessor to db (runner) map since it would not work with db threading. - * FUTURE put DBRunner into a public class that can provide external accessor. + * + * NOTE: no public static accessor to db (runner) map since it is not + * expected to work properly with db threading. + * + * FUTURE TBD put DBRunner into a public class that can provide external accessor. + * + * ADDITIONAL NOTE: Storing as Map to avoid portabiity issue + * between Java 6/7/8 as discussed in: + * https://gist.github.com/AlainODea/1375759b8720a3f9f094 + * + * THANKS to @NeoLSN (Jason Yang/楊朝傑) for giving the pointer in: + * https://github.com/litehelpers/Cordova-sqlite-storage/issues/727 */ - static ConcurrentHashMap dbrmap = new ConcurrentHashMap(); + static Map dbrmap = new ConcurrentHashMap(); /** * NOTE: Using default constructor, no explicit constructor. diff --git a/www/SQLitePlugin.js b/www/SQLitePlugin.js index a605e7883..f53aa105b 100644 --- a/www/SQLitePlugin.js +++ b/www/SQLitePlugin.js @@ -760,28 +760,10 @@ }, function(tx2_err) { return SelfTest.finishWithError(errorcb, "readTransaction error: " + tx2_err); }, function() { - return db.close(function() { - return SQLiteFactory.deleteDatabase({ - name: SelfTest.DBNAME, - location: 'default' - }, successcb, function(cleanup_err) { - if (/Windows /.test(navigator.userAgent) || /IEMobile/.test(navigator.userAgent)) { - console.log("IGNORE CLEANUP (DELETE) ERROR: " + (JSON.stringify(cleanup_err)) + " (Windows/WP8)"); - successcb(); - return; - } - return SelfTest.finishWithError(errorcb, "Cleanup error: " + cleanup_err); - }); + db.close(function() { + SelfTest.cleanupAndFinish(successcb, errorcb); }, function(close_err) { - if (/Windows /.test(navigator.userAgent) || /IEMobile/.test(navigator.userAgent)) { - console.log("IGNORE close ERROR: " + (JSON.stringify(close_err)) + " (Windows/WP8)"); - SQLiteFactory.deleteDatabase({ - name: SelfTest.DBNAME, - location: 'default' - }, successcb, successcb); - return; - } - return SelfTest.finishWithError(errorcb, "close error: " + close_err); + SelfTest.finishWithError(errorcb, "close error: " + close_err); }); }); }); @@ -795,15 +777,24 @@ return SelfTest.finishWithError(errorcb, "Open database error: " + open_err); }); }, + cleanupAndFinish: function(successcb, errorcb) { + SQLiteFactory.deleteDatabase({ + name: SelfTest.DBNAME, + location: 'default' + }, successcb, function(cleanup_err) { + SelfTest.finishWithError(errorcb, "CLEANUP DELETE ERROR: " + cleanup_err); + }); + }, finishWithError: function(errorcb, message) { console.log("selfTest ERROR with message: " + message); SQLiteFactory.deleteDatabase({ name: SelfTest.DBNAME, location: 'default' }, function() { - return errorcb(newSQLError(message)); + errorcb(newSQLError(message)); }, function(err2) { - return errorcb(newSQLError("Cleanup error: " + err2 + " for error: " + message)); + console.log("selfTest CLEANUP DELETE ERROR " + err2); + errorcb(newSQLError("CLEANUP DELETE ERROR: " + err2 + " for error: " + message)); }); } };