Skip to content

Update powersync-sqlite-core to 0.4.0 #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
branches: ['master']

env:
EM_VERSION: 3.1.64
EM_VERSION: 4.0.9
EM_CACHE_FOLDER: 'emsdk-cache'

jobs:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dependencies
SQLITE_VERSION = 3.47.2
MC_SQLITE_VERSION = 1.9.2
SQLITE_VERSION = 3.50.1
MC_SQLITE_VERSION = 2.1.3
SQLITE_TARBALL_URL = https://www.sqlite.org/src/tarball/sqlite.tar.gz?r=version-${SQLITE_VERSION}
MC_SQLITE_URL = https://github.com/utelle/SQLite3MultipleCiphers/releases/download/v${MC_SQLITE_VERSION}/sqlite3mc-${MC_SQLITE_VERSION}-sqlite-${SQLITE_VERSION}-amalgamation.zip
EXTENSION_FUNCTIONS = extension-functions.c
Expand Down
12 changes: 6 additions & 6 deletions demo/hello/hello.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
// to use. Note that an asynchronous VFS requires an asynchronous build
// (Asyncify or JSPI). As of 2024-05-26, JSPI is only available behind
// a flag on Chromium browsers.
// import SQLiteESMFactory from '../dist/wa-sqlite.mjs';
// import SQLiteESMFactory from '../../dist/wa-sqlite.mjs';
import SQLiteESMFactory from '../../dist/wa-sqlite-async.mjs';
// import SQLiteESMFactory from '../dist/wa-sqlite-jspi.mjs';
// import SQLiteESMFactory from '../../dist/wa-sqlite-jspi.mjs';

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

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

Expand Down
3 changes: 1 addition & 2 deletions dist/mc-wa-sqlite-async.mjs

Large diffs are not rendered by default.

Binary file modified dist/mc-wa-sqlite-async.wasm
Binary file not shown.
3 changes: 1 addition & 2 deletions dist/mc-wa-sqlite-jspi.mjs

Large diffs are not rendered by default.

Binary file modified dist/mc-wa-sqlite-jspi.wasm
Binary file not shown.
3 changes: 1 addition & 2 deletions dist/mc-wa-sqlite.mjs

Large diffs are not rendered by default.

Binary file modified dist/mc-wa-sqlite.wasm
Binary file not shown.
3 changes: 1 addition & 2 deletions dist/wa-sqlite-async-dynamic-main.mjs

Large diffs are not rendered by default.

Binary file modified dist/wa-sqlite-async-dynamic-main.wasm
Binary file not shown.
3 changes: 1 addition & 2 deletions dist/wa-sqlite-async.mjs

Large diffs are not rendered by default.

Binary file modified dist/wa-sqlite-async.wasm
Binary file not shown.
3 changes: 1 addition & 2 deletions dist/wa-sqlite-dynamic-main.mjs

Large diffs are not rendered by default.

Binary file modified dist/wa-sqlite-dynamic-main.wasm
Binary file not shown.
3 changes: 1 addition & 2 deletions dist/wa-sqlite-jspi.mjs

Large diffs are not rendered by default.

Binary file modified dist/wa-sqlite-jspi.wasm
Binary file not shown.
3 changes: 1 addition & 2 deletions dist/wa-sqlite.mjs

Large diffs are not rendered by default.

Binary file modified dist/wa-sqlite.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion powersync-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.3.14
v0.4.0
5 changes: 3 additions & 2 deletions src/extra_exported_runtime_methods.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
"stringToUTF16",
"stringToUTF32",
"AsciiToString",
"HEAP32",
"HEAPU8",
"UTF8ToString",
"UTF16ToString",
"UTF32ToString",
"intArrayFromString",
"intArrayToString",
"writeArrayToMemory",
"loadDynamicLibrary"
"writeArrayToMemory"
]
7 changes: 5 additions & 2 deletions src/sqlite-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ export function Factory(Module) {
const tmp = Module._malloc(8);
const tmpPtr = [tmp, tmp + 4];

const textEncoder = new TextEncoder();
// Convert a JS string to a C string. sqlite3_malloc is used to allocate
// memory (use sqlite3_free to deallocate).
function createUTF8(s) {
if (typeof s !== 'string') return 0;
const utf8 = new TextEncoder().encode(s);
const utf8 = textEncoder.encode(s);
const zts = Module._sqlite3_malloc(utf8.byteLength + 1);
Module.HEAPU8.set(utf8, zts);
Module.HEAPU8[zts + utf8.byteLength] = 0;
Expand Down Expand Up @@ -135,6 +136,8 @@ export function Factory(Module) {
}
case 'string':
return sqlite3.bind_text(stmt, i, value);
case "boolean":
return sqlite3.bind_int(stmt, i, value ? 1 : 0);
default:
if (value instanceof Uint8Array || Array.isArray(value)) {
return sqlite3.bind_blob(stmt, i, value);
Expand Down Expand Up @@ -686,7 +689,7 @@ export function Factory(Module) {
const onFinally = [];
try {
// Encode SQL string to UTF-8.
const utf8 = new TextEncoder().encode(sql);
const utf8 = textEncoder.encode(sql);

// Copy encoded string to WebAssembly memory. The SQLite docs say
// zero-termination is a minor optimization so add room for that.
Expand Down
2 changes: 1 addition & 1 deletion src/types/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ declare function setValue(ptr: number, value: number, type: string): number;
declare function mergeInto(library: object, methods: object): void;
declare function __onTablesChanged(db: number, opType: number, tableName: number, rowId: number);
declare var HEAPU8: Uint8Array;
declare var HEAPU32: Uint32Array;
declare var HEAP32: Int32Array;
declare var LibraryManager;
declare var Module;
declare var _vfsAccess;
Expand Down
21 changes: 21 additions & 0 deletions test/api_statements.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,27 @@ export function api_statements(context) {
}
});

it('should bind boolean', async function() {
let rc;
const sql = 'SELECT ?';
const storeValue = true;
const expectedRetrievedValue = 1;

for await (const stmt of i(sqlite3.statements(db, sql))) {
// Comlink intercepts the 'bind' property so use an alias.
rc = await sqlite3.bind$(stmt, 1, storeValue);
expect(rc).toEqual(SQLite.SQLITE_OK);

while ((rc = await sqlite3.step(stmt)) !== SQLite.SQLITE_DONE) {
expect(rc).toEqual(SQLite.SQLITE_ROW);

expect(await sqlite3.column_count(stmt)).toEqual(1);
expect(await sqlite3.column_type(stmt, 0)).toEqual(SQLite.SQLITE_INTEGER);
expect(await sqlite3.column_int(stmt, 0)).toEqual(expectedRetrievedValue);
}
}
});

it('should bind collection array', async function() {
let rc;
const sql = 'VALUES (?, ?, ?, ?, ?)';
Expand Down
Loading