Skip to content

Commit 27b206d

Browse files
authored
Merge pull request #38 from powersync-ja/update-core
Update powersync-sqlite-core to 0.4.0
2 parents e87e9e9 + 122648e commit 27b206d

24 files changed

+48
-31
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
branches: ['master']
1111

1212
env:
13-
EM_VERSION: 3.1.64
13+
EM_VERSION: 4.0.9
1414
EM_CACHE_FOLDER: 'emsdk-cache'
1515

1616
jobs:

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# dependencies
2-
SQLITE_VERSION = 3.47.2
3-
MC_SQLITE_VERSION = 1.9.2
2+
SQLITE_VERSION = 3.50.1
3+
MC_SQLITE_VERSION = 2.1.3
44
SQLITE_TARBALL_URL = https://www.sqlite.org/src/tarball/sqlite.tar.gz?r=version-${SQLITE_VERSION}
55
MC_SQLITE_URL = https://github.com/utelle/SQLite3MultipleCiphers/releases/download/v${MC_SQLITE_VERSION}/sqlite3mc-${MC_SQLITE_VERSION}-sqlite-${SQLITE_VERSION}-amalgamation.zip
66
EXTENSION_FUNCTIONS = extension-functions.c

demo/hello/hello.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// to use. Note that an asynchronous VFS requires an asynchronous build
55
// (Asyncify or JSPI). As of 2024-05-26, JSPI is only available behind
66
// a flag on Chromium browsers.
7-
// import SQLiteESMFactory from '../dist/wa-sqlite.mjs';
7+
// import SQLiteESMFactory from '../../dist/wa-sqlite.mjs';
88
import SQLiteESMFactory from '../../dist/wa-sqlite-async.mjs';
9-
// import SQLiteESMFactory from '../dist/wa-sqlite-jspi.mjs';
9+
// import SQLiteESMFactory from '../../dist/wa-sqlite-jspi.mjs';
1010

1111
// Uncomment one of the following imports to choose a VFS. Note that an
1212
// asynchronous VFS requires an asynchronous build, and an VFS using
@@ -19,11 +19,11 @@ import SQLiteESMFactory from '../../dist/wa-sqlite-async.mjs';
1919
// clear the appropriate storage for things to work.
2020
import { IDBBatchAtomicVFS as MyVFS } from '../../src/examples/IDBBatchAtomicVFS.js';
2121
// import { IDBMirrorVFS as MyVFS } from '../../src/examples/IDBMirrorVFS.js';
22-
// import { AccessHandlePoolVFS as MyVFS } from '../src/examples/AccessHandlePoolVFS.js';
23-
// import { OPFSAdaptiveVFS as MyVFS } from '../src/examples/OPFSAdaptiveVFS.js';
22+
// import { AccessHandlePoolVFS as MyVFS } from '../../src/examples/AccessHandlePoolVFS.js';
23+
// import { OPFSAdaptiveVFS as MyVFS } from '../../src/examples/OPFSAdaptiveVFS.js';
2424
// import { OPFSAnyContextVFS as MyVFS } from '../../src/examples/OPFSAnyContextVFS.js';
25-
// import { OPFSCoopSyncVFS as MyVFS } from '../src/examples/OPFSCoopSyncVFS.js';
26-
// import { OPFSPermutedVFS as MyVFS } from '../src/examples/OPFSPermutedVFS.js';
25+
// import { OPFSCoopSyncVFS as MyVFS } from '../../src/examples/OPFSCoopSyncVFS.js';
26+
// import { OPFSPermutedVFS as MyVFS } from '../../src/examples/OPFSPermutedVFS.js';
2727

2828
import * as SQLite from '../../src/sqlite-api.js';
2929

dist/mc-wa-sqlite-async.mjs

Lines changed: 1 addition & 2 deletions
Large diffs are not rendered by default.

dist/mc-wa-sqlite-async.wasm

329 KB
Binary file not shown.

dist/mc-wa-sqlite-jspi.mjs

Lines changed: 1 addition & 2 deletions
Large diffs are not rendered by default.

dist/mc-wa-sqlite-jspi.wasm

190 KB
Binary file not shown.

dist/mc-wa-sqlite.mjs

Lines changed: 1 addition & 2 deletions
Large diffs are not rendered by default.

dist/mc-wa-sqlite.wasm

190 KB
Binary file not shown.

dist/wa-sqlite-async-dynamic-main.mjs

Lines changed: 1 addition & 2 deletions
Large diffs are not rendered by default.
7.8 KB
Binary file not shown.

dist/wa-sqlite-async.mjs

Lines changed: 1 addition & 2 deletions
Large diffs are not rendered by default.

dist/wa-sqlite-async.wasm

261 KB
Binary file not shown.

dist/wa-sqlite-dynamic-main.mjs

Lines changed: 1 addition & 2 deletions
Large diffs are not rendered by default.

dist/wa-sqlite-dynamic-main.wasm

3.64 KB
Binary file not shown.

dist/wa-sqlite-jspi.mjs

Lines changed: 1 addition & 2 deletions
Large diffs are not rendered by default.

dist/wa-sqlite-jspi.wasm

123 KB
Binary file not shown.

dist/wa-sqlite.mjs

Lines changed: 1 addition & 2 deletions
Large diffs are not rendered by default.

dist/wa-sqlite.wasm

123 KB
Binary file not shown.

powersync-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.3.14
1+
v0.4.0

src/extra_exported_runtime_methods.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
"stringToUTF16",
1111
"stringToUTF32",
1212
"AsciiToString",
13+
"HEAP32",
14+
"HEAPU8",
1315
"UTF8ToString",
1416
"UTF16ToString",
1517
"UTF32ToString",
1618
"intArrayFromString",
1719
"intArrayToString",
18-
"writeArrayToMemory",
19-
"loadDynamicLibrary"
20+
"writeArrayToMemory"
2021
]

src/sqlite-api.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ export function Factory(Module) {
4545
const tmp = Module._malloc(8);
4646
const tmpPtr = [tmp, tmp + 4];
4747

48+
const textEncoder = new TextEncoder();
4849
// Convert a JS string to a C string. sqlite3_malloc is used to allocate
4950
// memory (use sqlite3_free to deallocate).
5051
function createUTF8(s) {
5152
if (typeof s !== 'string') return 0;
52-
const utf8 = new TextEncoder().encode(s);
53+
const utf8 = textEncoder.encode(s);
5354
const zts = Module._sqlite3_malloc(utf8.byteLength + 1);
5455
Module.HEAPU8.set(utf8, zts);
5556
Module.HEAPU8[zts + utf8.byteLength] = 0;
@@ -135,6 +136,8 @@ export function Factory(Module) {
135136
}
136137
case 'string':
137138
return sqlite3.bind_text(stmt, i, value);
139+
case "boolean":
140+
return sqlite3.bind_int(stmt, i, value ? 1 : 0);
138141
default:
139142
if (value instanceof Uint8Array || Array.isArray(value)) {
140143
return sqlite3.bind_blob(stmt, i, value);
@@ -686,7 +689,7 @@ export function Factory(Module) {
686689
const onFinally = [];
687690
try {
688691
// Encode SQL string to UTF-8.
689-
const utf8 = new TextEncoder().encode(sql);
692+
const utf8 = textEncoder.encode(sql);
690693

691694
// Copy encoded string to WebAssembly memory. The SQLite docs say
692695
// zero-termination is a minor optimization so add room for that.

src/types/globals.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ declare function setValue(ptr: number, value: number, type: string): number;
1111
declare function mergeInto(library: object, methods: object): void;
1212
declare function __onTablesChanged(db: number, opType: number, tableName: number, rowId: number);
1313
declare var HEAPU8: Uint8Array;
14-
declare var HEAPU32: Uint32Array;
14+
declare var HEAP32: Int32Array;
1515
declare var LibraryManager;
1616
declare var Module;
1717
declare var _vfsAccess;

test/api_statements.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,27 @@ export function api_statements(context) {
238238
}
239239
});
240240

241+
it('should bind boolean', async function() {
242+
let rc;
243+
const sql = 'SELECT ?';
244+
const storeValue = true;
245+
const expectedRetrievedValue = 1;
246+
247+
for await (const stmt of i(sqlite3.statements(db, sql))) {
248+
// Comlink intercepts the 'bind' property so use an alias.
249+
rc = await sqlite3.bind$(stmt, 1, storeValue);
250+
expect(rc).toEqual(SQLite.SQLITE_OK);
251+
252+
while ((rc = await sqlite3.step(stmt)) !== SQLite.SQLITE_DONE) {
253+
expect(rc).toEqual(SQLite.SQLITE_ROW);
254+
255+
expect(await sqlite3.column_count(stmt)).toEqual(1);
256+
expect(await sqlite3.column_type(stmt, 0)).toEqual(SQLite.SQLITE_INTEGER);
257+
expect(await sqlite3.column_int(stmt, 0)).toEqual(expectedRetrievedValue);
258+
}
259+
}
260+
});
261+
241262
it('should bind collection array', async function() {
242263
let rc;
243264
const sql = 'VALUES (?, ?, ?, ?, ?)';

0 commit comments

Comments
 (0)