Skip to content

Commit

Permalink
chore: revert
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicGBauer committed Jan 21, 2025
1 parent 4737b27 commit 4d42566
Show file tree
Hide file tree
Showing 4 changed files with 653 additions and 1,692 deletions.
12 changes: 7 additions & 5 deletions packages/powersync-op-sqlite/src/db/OPSqliteAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
}

protected async init() {
const { lockTimeoutMs, journalMode, journalSizeLimit, synchronous, encryptionKey } = this.options.sqliteOptions;
const { lockTimeoutMs, journalMode, journalSizeLimit, synchronous } = this.options.sqliteOptions!;
const dbFilename = this.options.name;

this.writeConnection = await this.openConnection(dbFilename);
Expand Down Expand Up @@ -99,7 +99,7 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement

protected async openConnection(filenameOverride?: string): Promise<OPSQLiteConnection> {
const dbFilename = filenameOverride ?? this.options.name;
const DB: DB = this.openDatabase(dbFilename, this.options.sqliteOptions.encryptionKey);
const DB: DB = this.openDatabase(dbFilename, this.options.sqliteOptions?.encryptionKey ?? undefined);

//Load extensions for all connections
this.loadAdditionalExtensions(DB);
Expand Down Expand Up @@ -139,7 +139,7 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
}

private loadAdditionalExtensions(DB: DB) {
if (this.options.sqliteOptions.extensions.length > 0) {
if (this.options.sqliteOptions?.extensions && this.options.sqliteOptions.extensions.length > 0) {
for (const extension of this.options.sqliteOptions.extensions) {
DB.loadExtension(extension.path, extension.entryPoint);
}
Expand Down Expand Up @@ -292,8 +292,10 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
await this.initialized;
await this.writeConnection!.refreshSchema();

for (let readConnection of this.readConnections) {
await readConnection.connection.refreshSchema();
if(this.readConnections) {
for (let readConnection of this.readConnections) {
await readConnection.connection.refreshSchema();
}
}
}
}
2 changes: 1 addition & 1 deletion packages/powersync-op-sqlite/src/db/SqliteOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface SqliteOptions {
* Encryption key for the database.
* If set, the database will be encrypted using SQLCipher.
*/
encryptionKey?: string;
encryptionKey?: string | null;

/**
* Load extensions using the path and entryPoint.
Expand Down
1 change: 1 addition & 0 deletions packages/powersync-op-sqlite/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"noEmit": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true,
"strict": true,
"esModuleInterop": true
},
"references": [
Expand Down
Loading

0 comments on commit 4d42566

Please sign in to comment.