Skip to content

Commit

Permalink
fix: kysely closing db on execute (#155)
Browse files Browse the repository at this point in the history
Co-authored-by: DominicGBauer <[email protected]>
  • Loading branch information
DominicGBauer and DominicGBauer authored May 6, 2024
1 parent 49299b6 commit 3e92a9c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-cheetahs-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@powersync/kysely-driver": minor
---

Made `destroy` and `releaseConnection` no-op functions. If you relied on `destroy` you will need to use `disconnectAndClear` on the PowerSync DB directly.
4 changes: 1 addition & 3 deletions packages/kysely-driver/src/sqlite/sqlite-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ export class PowerSyncConnection implements DatabaseConnection {
this.releaseTransaction();
}

async releaseConnection(): Promise<void> {
this.#db.close();
}
async releaseConnection(): Promise<void> {}

private releaseTransaction() {
if (!this.#completeTransaction) {
Expand Down
7 changes: 4 additions & 3 deletions packages/kysely-driver/src/sqlite/sqlite-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export class PowerSyncDriver implements Driver {
await connection.releaseConnection();
}

async destroy(): Promise<void> {
this.#db.disconnectAndClear();
}
/**
This will do nothing. Instead use PowerSync `disconnectAndClear` function.
*/
async destroy(): Promise<void> {}
}
2 changes: 1 addition & 1 deletion packages/kysely-driver/tests/sqlite/db.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('CRUD operations', () => {
});

afterEach(async () => {
await db.destroy();
await powerSyncDb.disconnectAndClear();
});

it('should insert a user and select that user', async () => {
Expand Down

0 comments on commit 3e92a9c

Please sign in to comment.