diff --git a/AUTHORS.md b/AUTHORS.md index f7d48286..87cdb8d3 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -12,6 +12,7 @@ - Extracted from DroidGap by @brodybits (Chris Brody) - Transaction batch processing of Android version by @marcucio +- NDK response type enhancements to android-sqlite-native-ndk-connector & android-sqlite-ndk-native-driver by Luis Silva of OutSystems - Maintained by @brodybits (Chris Brody) - Fixes to support old Android versions by @nolanlawson - Thanks to Mark Oppenheim for fixes to open/close callbacks and repeated open/close/delete operations diff --git a/CHANGES.md b/CHANGES.md index a71e0058..f2bf6ddc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,18 @@ ### cordova-sqlite-ext 6.0.0-dev +### cordova-sqlite-ext-common 5.1.0 + +- use cordova-sqlite-ext-deps 4.0.0 with Android JARs built from android-sqlite-native-ndk-connector and android-sqlite-ndk-native-driver, with enhancements by Luis Silva of OutSystems needed for some Android 11 devices + +### cordova-sqlite-ext-common 5.0.1 + +- fix: use cordova-sqlite-ext-deps 3.0.1 - with quick workaround update needed for BLOBFROMBASE64 on Android ARM target CPUs + +### cordova-sqlite-ext-common 5.0.0 + +- feat: add BLOBFROMBASE64 using cordova-sqlite-ext-deps 3.0.0 - BREAKING CHANGE due to removed Android pre-5.1 support + ### cordova-sqlite-ext-common 4.0.0 ### cordova-sqlite-storage-commoncore 2.0.0 diff --git a/README.md b/README.md index 3861b3f4..ab551fe9 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,6 @@ in an upcoming major release - see [`xpbrew/cordova-sqlite-storage#922`](https:/ some highlights: -- drop support for Android pre-5.1, which will also be dropped by `cordova-android`, including deprecated `armeabi` target (superseded by `armeabi-v7a`, seems to be not supported by Android 5.0) - more info in [`xpbrew/cordova-sqlite-storage#922`](https://github.com/xpbrew/cordova-sqlite-storage/issues/922) - error `code` will always be `0` (which is already the case on Windows); actual SQLite3 error code will be part of the error `message` member whenever possible (see [`xpbrew/cordova-sqlite-storage#821`](https://github.com/xpbrew/cordova-sqlite-storage/issues/821)) - drop support for location: 0-2 values in openDatabase call (please use `location: 'default'` or `iosDatabaseLocation` setting in openDatabase as documented below) - throw an exception in case of `androidDatabaseImplementation: 2` setting which is now superseded by `androidDatabaseProvider: 'system'` setting @@ -49,7 +48,7 @@ under consideration: ## About this plugin version -Version with extra features: REGEXP (Android/iOS/macOS), BASE64, and pre-populated databases +_Version with extra features: REGEXP (Android/iOS/macOS), BASE64, BLOBFROMBASE64, and pre-populated databases_ This plugin version uses a `before_plugin_install` hook to install sqlite3 library dependencies from `cordova-sqlite-ext-deps` via npm. @@ -67,7 +66,7 @@ This plugin version uses a `before_plugin_install` hook to install sqlite3 libra ### Multiple SQLite problem on Android -This plugin uses a non-standard [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) implementation on Android. In case an application access the SAME database using multiple plugins there is a risk of data corruption ref: [xpbrew/cordova-sqlite-storage#626](https://github.com/xpbrew/cordova-sqlite-storage/issues/626)) as described in and . +This plugin uses non-standard [`android-sqlite-native-ndk-connector`](https://github.com/brodybits/android-sqlite-native-ndk-connector) implementation with [`android-sqlite-ndk-native-driver`](https://github.com/brodybits/android-sqlite-ndk-native-driver) on Android. In case an application access the **same** database using multiple plugins there is a risk of data corruption ref: [`storesafe/cordova-sqlite-storage#626`](https://github.com/storesafe/cordova-sqlite-storage/issues/626)) as described in and . The workaround is to use the `androidDatabaseProvider: 'system'` setting as described in the [Android database provider](#android-database-provider) section below: @@ -204,7 +203,7 @@ See the [Sample section](#sample) for a sample with a more detailed explanation - Use of other systems such as Cordova Plugman, PhoneGap CLI, PhoneGap Build, and Intel XDK is no longer supported by this plugin version since they do not honor the `before_plugin_install` hook. The supported solution is to use [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (GPL or commercial license terms); deprecated alternative with permissive license terms is available at: [brodybits / cordova-sqlite-legacy-build-support](https://github.com/brodybits/cordova-sqlite-legacy-build-support) (very limited testing, very limited updates). - This plugin version includes the following extra (non-standard) features: - Pre-populated database support for all platforms Android/iOS/Windows; - - BASE64 integrated from [brodybits / sqlite3-base64](https://github.com/brodybits/sqlite3-base64), using [brodybits / libb64-encode](https://github.com/brodybits/libb64-encode) (based on by Chris Venter, public domain) + - BASE64 and BLOBFROMBASE64 integrated from [brodybits / sqlite3-base64](https://github.com/brodybits/sqlite3-base64), using [brodybits / libb64-core](https://github.com/brodybits/libb64-core) (based on by Chris Venter, public domain) - REGEXP for Android (default Android-sqlite-connector database implementation), iOS, and macOS using [brodybits / sqlite3-regexp-cached](https://github.com/brodybits/sqlite3-regexp-cached) (based on by Alexey Tourbin, public domain) - _BLOB column values are NO LONGER automatically converted to Base64 format. MUST use SELECT BASE64(column) to return column value in Base64 format as documented below._ - SQLite `3.32.3` included when building (all platforms), with the following compile-time definitions: @@ -233,7 +232,7 @@ See the [Sample section](#sample) for a sample with a more detailed explanation - - The iOS database location is now mandatory, as documented below. - This version branch supports the use of two (2) possible Android sqlite database implementations: - - default: lightweight [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector), using _the SQLite3 NDK component built from [brodybits / Android-sqlite-ext-native-driver](https://github.com/brodybits/Android-sqlite-ext-native-driver)_ + - default: _lightweight [`android-sqlite-native-ndk-connector`](https://github.com/brodybits/android-sqlite-native-ndk-connector), using SQLite3 NDK component built from [`android-sqlite-ndk-native-driver`](https://github.com/brodybits/android-sqlite-ndk-native-driver)_ - optional: Android system database implementation, using the `androidDatabaseProvider: 'system'` setting in `sqlitePlugin.openDatabase()` call as described in the [Android database provider](#android-database-provider) section below. - Support for WP8 along with Windows 8.1/Windows Phone 8.1/Windows 10 using Visual Studio 2015 is available in: [brodybits / cordova-sqlite-legacy-build-support](https://github.com/brodybits/cordova-sqlite-legacy-build-support) - 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) @@ -291,7 +290,7 @@ and window functions - macOS ("osx" platform) is now supported - New [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) plugin version with Android JSON and SQL statement handling implemented in C, as well as support for PhoneGap Build, Intel XDK, etc. (GPL or commercial license terms). Handles large SQL batches in less than half the time as this plugin version. Also supports arbitrary database location on Android. - Published [brodybits / Cordova-quick-start-checklist](https://github.com/brodybits/Cordova-quick-start-checklist) and [brodybits / Avoiding-some-Cordova-pitfalls](https://github.com/brodybits/Avoiding-some-Cordova-pitfalls). -- Android platform version currently uses the lightweight [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) by default configuration (may be changed as described below). +- Android platform version currently uses lightweight 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 straightforward sql batch function @@ -631,8 +630,8 @@ Some additional issues are tracked in [open cordova-sqlite-storage bug-general i - SELECT BLOB column value type is not supported consistently across all platforms (not supported on Windows). It is recommended to use the built-in HEX function to SELECT BLOB column data in hexadecimal format, working consistently across all platforms. As an alternative: SELECT BLOB in Base64 format is supported by this plugin version, _[`brodybits/cordova-sqlite-ext`](https://github.com/brodybits/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)_. - Database files with certain multi-byte UTF-8 characters are not tested and not expected to work consistently across all platform implementations. - Issues with UNICODE `\u0000` character (same as `\0`): - - Encoding issue reproduced on Android (default [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) implementation with [Android-sqlite-ext-native-driver](https://github.com/brodybits/Android-sqlite-ext-native-driver), using Android NDK) - - Truncation in case of argument value with UNICODE `\u0000` character reproduced on (WebKit) Web SQL as well as plugin on Android (default [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) implementation with [Android-sqlite-ext-native-driver](https://github.com/brodybits/Android-sqlite-ext-native-driver), using Android NDK) and Windows + - Encoding issue reproduced on Android (default [`android-sqlite-native-ndk-connector`](https://github.com/brodybits/android-sqlite-native-ndk-connector) implementation with [`android-sqlite-ndk-native-driver`](https://github.com/brodybits/android-sqlite-ndk-native-driver), using Android NDK) + - Truncation in case of argument value with UNICODE `\u0000` character reproduced on (WebKit) Web SQL as well as plugin on Android (default [`android-sqlite-native-ndk-connector`](https://github.com/brodybits/android-sqlite-native-ndk-connector) implementation with [`android-sqlite-ndk-native-driver`](https://github.com/brodybits/android-sqlite-ndk-native-driver), using Android NDK), browser, and Windows - SQL error reported in case of inline value string with with UNICODE `\u0000` character on (WebKit) Web SQL, plugin on Android with use of the `androidDatabaseProvider: 'system'` setting, and plugin on _some_ other platforms - 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. @@ -857,7 +856,7 @@ var db = window.sqlitePlugin.openDatabase({name: 'my.db', location: 'default'}, **WARNING:** The new "default" location value is different from the old default location used until March 2016 and would break an upgrade for an app that was using the old default setting (`location: 0`, same as using `iosDatabaseLocation: 'Documents'`) on iOS. The recommended solution is to continue to open the database from the same location, using `iosDatabaseLocation: 'Documents'`. -**WARNING 2:** As described above: by default this plugin uses a non-standard [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) implementation on Android. In case an application access the **same** database using multiple plugins there is a risk of data corruption ref: [xpbrew/cordova-sqlite-storage#626](https://github.com/xpbrew/cordova-sqlite-storage/issues/626)) as described in and . The workaround is to use the `androidDatabaseProvider: 'system'` setting as described in the **Android sqlite implementation** section below. +**WARNING 2:** As described above: by default this plugin uses a non-standard implementation on Android. In case an application access the **same** database using multiple plugins there is a risk of data corruption ref: [`storesafe/cordova-sqlite-storage#626`](https://github.com/storesafe/cordova-sqlite-storage/issues/626)) as described in and . The workaround is to use the `androidDatabaseProvider: 'system'` setting as described in the **Android sqlite implementation** section below. To specify a different location (affects iOS/macOS *only*): @@ -996,7 +995,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase ### Android database provider -By default, this plugin uses [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector), which is lightweight and should be more efficient than the Android system database provider. To use the built-in Android system database provider implementation instead: +By default, this plugin uses , which is lightweight and should be more efficient than the Android system database provider. To use the built-in Android system database provider implementation instead: ```js var db = window.sqlitePlugin.openDatabase({ @@ -1009,7 +1008,7 @@ var db = window.sqlitePlugin.openDatabase({ (Use of the `androidDatabaseImplementation: 2` setting which is now replaced by `androidDatabaseProvider: 'system'` is now deprecated and may be removed in the near future.) **IMPORTANT:** -- As described above: by default this plugin uses a non-standard [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) implementation on Android. In case an application access the **same** database using multiple plugins there is a risk of data corruption ref: [xpbrew/cordova-sqlite-storage#626](https://github.com/xpbrew/cordova-sqlite-storage/issues/626)) as described in and . The workaround is to use the `androidDatabaseProvider: 'system'` setting as described here. +- As described above: by default this plugin uses a non-standard `android-sqlite-native-ndk-connector` implementation on Android. In case an application access the **same** database using multiple plugins there is a risk of data corruption ref: [xpbrew/cordova-sqlite-storage#626](https://github.com/xpbrew/cordova-sqlite-storage/issues/626)) as described in and . The workaround is to use the `androidDatabaseProvider: 'system'` setting as described here. - In case of the `androidDatabaseProvider: 'system'` setting, [xpbrew/cordova-sqlite-storage#193](https://github.com/xpbrew/cordova-sqlite-storage/issues/193) reported (as observed by a number of app developers in the past) that in certain Android versions, if the app is stopped or aborted without closing the database then there is an unexpected database lock and the data that was inserted is lost. The workaround is described below. @@ -1022,7 +1021,7 @@ var db = window.sqlitePlugin.openDatabase({ The cause of this issue remains unknown. Of interest: [android / platform_external_sqlite commit d4f30d0d15](https://github.com/android/platform_external_sqlite/commit/d4f30d0d1544f8967ee5763c4a1680cb0553039f) which references and includes the sqlite commit at: http://www.sqlite.org/src/info/6c4c2b7dba -This is *not* an issue when the default [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) database implementation is used, which is the case when no `androidDatabaseProvider` or `androidDatabaseImplementation` setting is used. +This is *not* an issue when the default `android-sqlite-native-ndk-connector` database implementation is used, which is the case when no `androidDatabaseProvider` or `androidDatabaseImplementation` setting is used. There is an optional workaround that simply closes and reopens the database file at the end of every transaction that is committed. The workaround is enabled by opening the database with options as follows: @@ -1258,6 +1257,17 @@ db.readTransaction(function(tx) { NOTICE: This is *not* supported in case a database is opened with the `androidDatabaseImplementation: 2` option. +### INSERT BLOB data from BASE64 string value + +```Javascript +db.transaction(function(tx) { + tx.executeSql("INSERT INTO MyTable (data) VALUES (BLOBFROMBASE64(?))", ["AQID"], function(tx, resultSet) { + console.log("insertId: " + resultSet.insertId + " -- probably 1"); + console.log("rowsAffected: " + resultSet.rowsAffected + " -- should be 1"); + }); +}); +``` + ## Background processing The threading model depends on which platform version is used: diff --git a/package.json b/package.json index 8062377e..1016aa8d 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ }, "homepage": "https://github.com/litehelpers/cordova-sqlite-ext", "dependencies": { - "cordova-sqlite-ext-deps": "2.1.1" + "cordova-sqlite-ext-deps": "4.0.0" }, "scripts": { "clean-spec": "rm -rf spec/[mnp]* && git cl spec/config.xml spec/package.json && git status --ignored", diff --git a/plugin.xml b/plugin.xml index 02f9db2b..1ab6d6b6 100644 --- a/plugin.xml +++ b/plugin.xml @@ -34,9 +34,9 @@ - + - + @@ -60,8 +60,10 @@ - - + + + + - - + + + + + diff --git a/spec/www/spec/blobfrombase64-test.js b/spec/www/spec/blobfrombase64-test.js new file mode 100755 index 00000000..a2b05ab3 --- /dev/null +++ b/spec/www/spec/blobfrombase64-test.js @@ -0,0 +1,159 @@ +/* 'use strict'; */ + +var MYTIMEOUT = 12000; + +var DEFAULT_SIZE = 5000000; // max to avoid popup in safari/ios + +var isWindows = /Windows /.test(navigator.userAgent); // Windows (...) +var isAndroid = !isWindows && /Android/.test(navigator.userAgent); + +var scenarioList = [ + isAndroid ? 'Plugin-implementation-default' : 'Plugin', + 'HTML5', + 'Plugin-implementation-2' +]; + +var scenarioCount = (!!window.hasWebKitBrowser) ? (isAndroid ? 3 : 2) : 1; + +var mytests = function() { + + for (var i=0; i - %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory);$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps;$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps\sqlite3-base64;$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps\libb64-encode + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory);$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps;$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps\sqlite3-base64;$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps\libb64-core /DSQLITE_THREADSAFE=1 /DSQLITE_DEFAULT_SYNCHRONOUS=3 /DSQLITE_DEFAULT_MEMSTATUS=0 /DSQLITE_OMIT_DECLTYPE /DSQLITE_OMIT_DEPRECATED /DSQLITE_OMIT_PROGRESS_CALLBACK /DSQLITE_OMIT_SHARED_CACHE /DSQLITE_TEMP_STORE=2 /DSQLITE_OMIT_LOAD_EXTENSION /DSQLITE_ENABLE_FTS3 /DSQLITE_ENABLE_FTS3_PARENTHESIS /DSQLITE_ENABLE_FTS4 /DSQLITE_ENABLE_FTS5 /DSQLITE_ENABLE_RTREE /DSQLITE_ENABLE_JSON1 /DSQLITE_DEFAULT_PAGE_SIZE=4096 /DSQLITE_DEFAULT_CACHE_SIZE=-2000 /DSQLITE_OS_WINRT %(AdditionalOptions) - + + @@ -33,7 +34,10 @@ false - + + false + + false