Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/five-colts-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@powersync/op-sqlite': patch
---

Fixed an issue where the default `op-sqlite` database location determination logic was being overridden. The `dbLocation` is now only applied when explicitly provided, resolving issues with features like iOS App Groups.
31 changes: 11 additions & 20 deletions packages/powersync-op-sqlite/src/db/OPSqliteAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,30 +112,21 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
});
}

private getDbLocation(dbLocation?: string): string {
if (Platform.OS === 'ios') {
return dbLocation ?? IOS_LIBRARY_PATH;
} else {
return dbLocation ?? ANDROID_DATABASE_PATH;
private openDatabase(dbFilename: string, encryptionKey?: string): DB {
const openOptions: Parameters<typeof open>[0] = {
name: dbFilename
};

if (this.options.dbLocation) {
openOptions.location = this.options.dbLocation;
}
}

private openDatabase(dbFilename: string, encryptionKey?: string): DB {
//This is needed because an undefined/null dbLocation will cause the open function to fail
const location = this.getDbLocation(this.options.dbLocation);
//Simarlily if the encryption key is undefined/null when using SQLCipher it will cause the open function to fail
// If the encryption key is undefined/null when using SQLCipher it will cause the open function to fail
if (encryptionKey) {
return open({
name: dbFilename,
location: location,
encryptionKey: encryptionKey
});
} else {
return open({
name: dbFilename,
location: location
});
openOptions.encryptionKey = encryptionKey;
}

return open(openOptions);
}

private loadAdditionalExtensions(DB: DB) {
Expand Down