Skip to content

Commit

Permalink
Merge branch 'cordova-sqlite-ext-common' into latest
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher J. Brody committed Oct 14, 2021
2 parents d5da41c + ab7c40e commit 5add83a
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 22 deletions.
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]> for fixes to open/close callbacks and repeated open/close/delete operations
Expand Down
12 changes: 12 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 22 additions & 12 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 10 additions & 6 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
<source-file src="src/android/io/sqlc/SQLiteConnectorDatabase.java" target-dir="src/io/sqlc"/>

<!-- Android-sqlite-connector [jar]: -->
<lib-file src="node_modules/cordova-sqlite-ext-deps/libs/sqlite-connector.jar" />
<lib-file src="node_modules/cordova-sqlite-ext-deps/libs/sqlite-native-ndk-connector.jar" />
<!-- Android-sqlite-connector native driver [native libs in jar]: -->
<lib-file src="node_modules/cordova-sqlite-ext-deps/libs/sqlite-native-driver.jar" />
<lib-file src="node_modules/cordova-sqlite-ext-deps/libs/sqlite-ndk-native-driver.jar" />
</platform>

<!-- iOS -->
Expand All @@ -60,8 +60,10 @@
<header-file src="node_modules/cordova-sqlite-ext-deps/sqlite3-base64/sqlite3_base64.h" />
<source-file src="node_modules/cordova-sqlite-ext-deps/sqlite3-base64/sqlite3_base64.c" />

<header-file src="node_modules/cordova-sqlite-ext-deps/libb64-encode/cencode.h" />
<source-file src="node_modules/cordova-sqlite-ext-deps/libb64-encode/cencode.c" />
<header-file src="node_modules/cordova-sqlite-ext-deps/libb64-core/cencode.h" />
<source-file src="node_modules/cordova-sqlite-ext-deps/libb64-core/cencode.c" />
<header-file src="node_modules/cordova-sqlite-ext-deps/libb64-core/cdecode.h" />
<source-file src="node_modules/cordova-sqlite-ext-deps/libb64-core/cdecode.c" />

<header-file src="node_modules/cordova-sqlite-ext-deps/sqlite3.h" />
<source-file src="node_modules/cordova-sqlite-ext-deps/sqlite3.c"
Expand Down Expand Up @@ -90,8 +92,10 @@
<header-file src="node_modules/cordova-sqlite-ext-deps/sqlite3-base64/sqlite3_base64.h" />
<source-file src="node_modules/cordova-sqlite-ext-deps/sqlite3-base64/sqlite3_base64.c" />

<header-file src="node_modules/cordova-sqlite-ext-deps/libb64-encode/cencode.h" />
<source-file src="node_modules/cordova-sqlite-ext-deps/libb64-encode/cencode.c" />
<header-file src="node_modules/cordova-sqlite-ext-deps/libb64-core/cencode.h" />
<source-file src="node_modules/cordova-sqlite-ext-deps/libb64-core/cencode.c" />
<header-file src="node_modules/cordova-sqlite-ext-deps/libb64-core/cdecode.h" />
<source-file src="node_modules/cordova-sqlite-ext-deps/libb64-core/cdecode.c" />

<header-file src="node_modules/cordova-sqlite-ext-deps/sqlite3.h" />
<source-file src="node_modules/cordova-sqlite-ext-deps/sqlite3.c"
Expand Down
1 change: 1 addition & 0 deletions spec/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<script src="spec/db-open-close-delete-test.js"></script>
<script src="spec/ext-tx-blob-test.js"></script>
<script src="spec/base64-encode-test.js"></script>
<script src="spec/blobfrombase64-test.js"></script>

</head>

Expand Down
159 changes: 159 additions & 0 deletions spec/www/spec/blobfrombase64-test.js
Original file line number Diff line number Diff line change
@@ -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<scenarioCount; ++i) {

describe(scenarioList[i] + ': BLOBFROMBASE64 encoding test(s)', function() {
var scenarioName = scenarioList[i];
var suiteName = scenarioName + ': ';
var isWebSql = (i === 1);
var isImpl2 = (i === 2);

// NOTE: MUST be defined in proper describe function scope, NOT outer scope:
var openDatabase = function(name, ignored1, ignored2, ignored3) {
if (isImpl2) {
return window.sqlitePlugin.openDatabase({
// prevent reuse of database from default db implementation:
name: 'i2-'+name,
androidDatabaseImplementation: 2,
androidLockWorkaround: 1,
iosDatabaseLocation: 'Documents'
});
}
if (isWebSql) {
return window.openDatabase(name, "1.0", "Demo", DEFAULT_SIZE);
} else {
return window.sqlitePlugin.openDatabase({name: name, location: 'default'});
}
}

describe(suiteName + 'SELECT BLOBFROMBASE64 value test(s)', function() {

it(suiteName + "SELECT HEX(BLOBFROMBASE64('AQID')) [X'010203'] INLINE", function(done) {
if (isWebSql) pending('SKIP: BLOBFROMBASE64 not supported by Web SQL');
if (!isWebSql && isAndroid && isImpl2) pending("SKIP: BLOBFROMBASE64 not supported with androidDatabaseProvider: 'system'");

var db = openDatabase('SELECT-BLOBFROMBASE64-AQID-AS-HEX-VALUE-INLINE.db');

db.transaction(function(tx) {
tx.executeSql("SELECT HEX(BLOBFROMBASE64('AQID')) AS hex_value", [], function(ignored, rs) {
expect(rs).toBeDefined();
expect(rs.rows).toBeDefined();
expect(rs.rows.length).toBe(1);
expect(rs.rows.item(0).hex_value).toBe('010203');

// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
});
}, MYTIMEOUT);

it(suiteName + "SELECT HEX of BLOBFROMBASE64 with 'AQID' [X'010203'] parameter", function(done) {
if (isWebSql) pending('SKIP: BLOBFROMBASE64 not supported by Web SQL');
if (!isWebSql && isAndroid && isImpl2) pending("SKIP: BLOBFROMBASE64 not supported with androidDatabaseProvider: 'system'");

var db = openDatabase('SELECT-HEX-of-BLOBFROMBASE64-AQID-AS-HEX-VALUE.db');

db.transaction(function(tx) {
tx.executeSql("SELECT HEX(BLOBFROMBASE64(?)) AS hex_value", ['AQID'], function(ignored, rs) {
expect(rs).toBeDefined();
expect(rs.rows).toBeDefined();
expect(rs.rows.length).toBe(1);
expect(rs.rows.item(0).hex_value).toBe('010203');

// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
});
}, MYTIMEOUT);

it(suiteName + "SELECT HEX of BLOBFROMBASE64 with 'AQID AQIE AQIF' [X'010203010204010205' - spaces ignored] parameter", function(done) {
if (isWebSql) pending('SKIP: BLOBFROMBASE64 not supported by Web SQL');
if (!isWebSql && isAndroid && isImpl2) pending("SKIP: BLOBFROMBASE64 not supported with androidDatabaseProvider: 'system'");

var db = openDatabase('SELECT-HEX-of-BLOBFROMBASE64-AQID-AS-HEX-VALUE.db');

db.transaction(function(tx) {
tx.executeSql("SELECT HEX(BLOBFROMBASE64(?)) AS hex_value", ['AQID AQIE AQIF'], function(ignored, rs) {
expect(rs).toBeDefined();
expect(rs.rows).toBeDefined();
expect(rs.rows.length).toBe(1);
expect(rs.rows.item(0).hex_value).toBe('010203010204010205');

// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
});
}, MYTIMEOUT);

});

describe(suiteName + 'INSERT BLOB data from BLOBFROMBASE64 & check stored data', function() {

it(suiteName + "INSERT BLOBFROMBASE64 from 'AQID AQIE AQIF' [X'010203010204010205' - spaces ignored], SELECT as BASE64, and check type", function(done) {
if (isWebSql) pending('SKIP: BLOBFROMBASE64 not supported by Web SQL');
if (!isWebSql && isAndroid && isImpl2) pending("SKIP: BLOBFROMBASE64 not supported with androidDatabaseProvider: 'system'");

var db = openDatabase('INSERT-BLOBFROMBASE64-AQID-AQIE-AQIF-and-check.db');

db.transaction(function(tx) {
tx.executeSql('DROP TABLE IF EXISTS tt');
tx.executeSql('CREATE TABLE tt (data)');
tx.executeSql("INSERT INTO tt VALUES(BLOBFROMBASE64(?))", ["AQID AQIE AQIF"]);
}, function(error) {
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('--');
done();
}, function() {
db.transaction(function(tx2) {
tx2.executeSql("SELECT HEX(data) AS hex_value from tt", [], function(ignored, rs) {
expect(rs).toBeDefined();
expect(rs.rows).toBeDefined();
expect(rs.rows.length).toBe(1);
expect(rs.rows.item(0).hex_value).toBe('010203010204010205');

tx2.executeSql("SELECT TYPEOF(data) AS value_type from tt", [], function(ignored, rs2) {
expect(rs2).toBeDefined();
expect(rs2.rows).toBeDefined();
expect(rs2.rows.length).toBe(1);
expect(rs2.rows.item(0).value_type).toBe('blob');

// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
});
});
});
}, MYTIMEOUT);



});

});

}

}

if (window.hasBrowser) mytests();
else exports.defineAutoTests = mytests;

/* vim: set expandtab : */
10 changes: 7 additions & 3 deletions src/windows/SQLite3-WinRT-sync/SQLite3/SQLite3.Shared.vcxitems
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>%(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>
<AdditionalIncludeDirectories>%(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</AdditionalIncludeDirectories>
<AdditionalOptions>/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)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps\libb64-encode\cencode.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps\libb64-core\cencode.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps\libb64-core\cdecode.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps\sqlite3-base64\sqlite3_base64.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps\sqlite3.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Constants.h" />
Expand All @@ -33,7 +34,10 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps\sqlite3-base64\sqlite3_base64.c">
<CompileAsWinRT>false</CompileAsWinRT>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps\libb64-encode\cencode.c">
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps\libb64-core\cencode.c">
<CompileAsWinRT>false</CompileAsWinRT>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps\libb64-core\cdecode.c">
<CompileAsWinRT>false</CompileAsWinRT>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)pch.cpp">
Expand Down

0 comments on commit 5add83a

Please sign in to comment.