Skip to content

Commit fe737c4

Browse files
committed
Tweaks.
1 parent 428dd6c commit fe737c4

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

packages/wa-sqlite-driver/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@journeyapps/wa-sqlite": "^1.3.2",
1919
"@sqlite-js/driver": "workspace:^",
2020
"async-mutex": "^0.5.0",
21-
"wa-sqlite": "^1.0.0"
21+
"wa-sqlite": "[email protected]:rhashimoto/wa-sqlite.git#v1.0.9"
2222
},
2323
"devDependencies": {
2424
"@sqlite-js/driver-tests": "workspace:^",

packages/wa-sqlite-driver/src/wa-sqlite-driver.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as SQLite from '@journeyapps/wa-sqlite';
22
import SQLiteESMFactory from '@journeyapps/wa-sqlite/dist/wa-sqlite-async.mjs';
3+
// import * as SQLite from 'wa-sqlite';
4+
// import SQLiteESMFactory from 'wa-sqlite/dist/wa-sqlite-async.mjs';
35
import {
46
PrepareOptions,
57
ResetOptions,
@@ -14,10 +16,10 @@ import {
1416
UpdateListener
1517
} from '@sqlite-js/driver';
1618
import * as mutex from 'async-mutex';
17-
import { OPFSCoopSyncVFS2 } from './OPFSCoopSyncVFS2';
1819

1920
// Initialize SQLite.
2021
export const module = await SQLiteESMFactory();
22+
console.log('module', module);
2123
export const sqlite3 = SQLite.Factory(module);
2224

2325
const m = new mutex.Mutex();
@@ -233,7 +235,8 @@ class StatementImpl implements SqliteDriverStatement {
233235
while ((await sqlite3.step(stmt)) === SQLite.SQLITE_ROW) {}
234236

235237
const changes = sqlite3.changes(this.db);
236-
const lastInsertRowId = BigInt(sqlite3.last_insert_id(this.db));
238+
// const lastInsertRowId = BigInt(sqlite3.last_insert_id(this.db));
239+
const lastInsertRowId = 0n;
237240

238241
return { changes, lastInsertRowId };
239242
} catch (e: any) {
@@ -253,26 +256,20 @@ class StatementImpl implements SqliteDriverStatement {
253256

254257
export class WaSqliteConnection implements SqliteDriverConnection {
255258
db: number;
256-
vfs: OPFSCoopSyncVFS2;
257259

258260
statements = new Set<StatementImpl>();
259261

260-
static async open(
261-
filename: string,
262-
vfs: OPFSCoopSyncVFS2
263-
): Promise<WaSqliteConnection> {
262+
static async open(filename: string): Promise<WaSqliteConnection> {
264263
// Open the database.
265264
const db = await sqlite3.open_v2(filename);
266-
return new WaSqliteConnection(db, vfs, filename);
265+
return new WaSqliteConnection(db, filename);
267266
}
268267

269268
constructor(
270269
db: number,
271-
vfs: OPFSCoopSyncVFS2,
272270
public path: string
273271
) {
274272
this.db = db;
275-
this.vfs = vfs;
276273
}
277274

278275
async close() {
@@ -290,7 +287,8 @@ export class WaSqliteConnection implements SqliteDriverConnection {
290287

291288
async getLastChanges(): Promise<SqliteChanges> {
292289
const changes = sqlite3.changes(this.db);
293-
const lastInsertRowId = BigInt(sqlite3.last_insert_id(this.db));
290+
// const lastInsertRowId = BigInt(sqlite3.last_insert_id(this.db));
291+
const lastInsertRowId = 0n;
294292

295293
return { changes, lastInsertRowId };
296294
}

packages/wa-sqlite-driver/src/wa-sqlite-worker.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { setupDriverWorker } from './worker_threads';
44
import { IDBBatchAtomicVFS } from '@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js';
55
import { OPFSAdaptiveVFS } from '@journeyapps/wa-sqlite/src/examples/OPFSAdaptiveVFS.js';
66
import { OPFSPermutedVFS } from '@journeyapps/wa-sqlite/src/examples/OPFSPermutedVFS.js';
7+
import { IDBBatchAtomicVFS as IDBBatchAtomicVFS0 } from 'wa-sqlite/src/examples/IDBBatchAtomicVFS.js';
8+
79
let vfs: any | null = null;
810
setupDriverWorker({
911
async openConnection(options) {
@@ -17,7 +19,7 @@ setupDriverWorker({
1719
// options.readonly ?? false
1820
// );
1921
// IDBBatchAtomicVFS - breaks hard (database disk image is malformed)
20-
// vfs = await (IDBBatchAtomicVFS as any).create('test.db', module);
22+
vfs = await (IDBBatchAtomicVFS0 as any).create('test.db', module);
2123
// OPFSAdaptiveVFS - works great
2224
// vfs = await (OPFSAdaptiveVFS as any).create('test.db', module, {
2325
// ifAvailable: true,
@@ -29,12 +31,12 @@ setupDriverWorker({
2931
// });
3032

3133
// database disk image is malformed
32-
vfs = await (OPFSPermutedVFS as any).create('test.db', module);
34+
// vfs = await (OPFSPermutedVFS as any).create('test.db', module);
3335

3436
// @ts-ignore
3537
sqlite3.vfs_register(vfs as any, true);
3638

37-
const con = await WaSqliteConnection.open(options.path, vfs);
39+
const con = await WaSqliteConnection.open(options.path);
3840
using stmt = await con.prepare('PRAGMA busy_timeout = 10000');
3941
await stmt.step();
4042
return con;

pnpm-lock.yaml

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)