diff --git a/.changeset/five-colts-whisper.md b/.changeset/five-colts-whisper.md new file mode 100644 index 00000000..25d493e9 --- /dev/null +++ b/.changeset/five-colts-whisper.md @@ -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. diff --git a/packages/powersync-op-sqlite/src/db/OPSqliteAdapter.ts b/packages/powersync-op-sqlite/src/db/OPSqliteAdapter.ts index 8d885b91..60d4a4ee 100644 --- a/packages/powersync-op-sqlite/src/db/OPSqliteAdapter.ts +++ b/packages/powersync-op-sqlite/src/db/OPSqliteAdapter.ts @@ -112,30 +112,21 @@ export class OPSQLiteDBAdapter extends BaseObserver 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[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) {