Skip to content

Commit 56c3b59

Browse files
committed
Make connection type required
1 parent 911ac41 commit 56c3b59

9 files changed

Lines changed: 19 additions & 20 deletions

File tree

packages/adapter-sql-js/src/SQLJSAdapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ class SqlJsLockContext extends LockContext {
173173
super();
174174
}
175175

176-
get connectionType() {
177-
return undefined;
176+
get connectionType(): 'readWrite' {
177+
return 'readWrite';
178178
}
179179

180180
async executeRaw(query: string, params?: any[]): Promise<RawQueryResult> {

packages/capacitor/src/adapter/CapacitorSQLiteAdapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ export class CapacitorSQLiteAdapter extends DBAdapter {
248248
};
249249

250250
class CapacitorLockContext extends LockContext {
251-
get connectionType() {
252-
return undefined;
251+
get connectionType(): 'readWrite' {
252+
return 'readWrite';
253253
}
254254

255255
getAll<T>(sql: string, parameters?: any[]): Promise<T[]> {

packages/common/src/db/DBAdapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ export abstract class LockContext implements SqlExecutor, DBGetUtils {
9090
/**
9191
* How the connection has been opened.
9292
*
93-
* `writer` indicates that the lock context is capable of writing to the database.
93+
* `readWrite` indicates that the lock context is capable of writing to the database.
9494
* `queryOnly` indicates that the lock context has been opened in a readwrite mode, but a `PRAGMA query_only = TRUE`
9595
* disabled writes.
9696
* `readOnly` indicates that the lock context has been opened by passing `SQLITE_OPEN_READONLY` to `sqlite3_open_v2`.
9797
*/
98-
abstract get connectionType(): 'writer' | 'queryOnly' | 'readOnly' | undefined;
98+
abstract get connectionType(): 'readWrite' | 'queryOnly' | 'readOnly';
9999

100100
abstract executeRaw<T>(query: string, params?: any[] | undefined): Promise<RawQueryResult>;
101101

packages/node/src/db/RemoteConnection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class RemoteConnection extends LockContext {
3131
}
3232

3333
public get connectionType() {
34-
return this.readonly ? 'readOnly' : 'writer';
34+
return this.readonly ? 'readOnly' : 'readWrite';
3535
}
3636

3737
/**

packages/powersync-op-sqlite/src/db/OPSQLiteConnection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class OPSQLiteConnection extends LockContext {
4242
}
4343

4444
get connectionType() {
45-
return this.options.readonly ? 'queryOnly' : 'writer';
45+
return this.options.readonly ? 'queryOnly' : 'readWrite';
4646
}
4747

4848
addTableUpdate(update: OPSQLiteUpdateNotification) {

packages/react-native/src/db/adapters/react-native-quick-sqlite/RNQSDBAdapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ class QuickSqliteContext extends LockContext {
6666
super();
6767
}
6868

69-
get connectionType() {
70-
return undefined;
69+
get connectionType(): 'readWrite' {
70+
return 'readWrite';
7171
}
7272

7373
async execute<T>(query: string, params?: any[]): Promise<QueryResult<T>> {

packages/tauri/guest-js/pool.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class RustDatabaseAdapter extends DBAdapter {
5353
const handle = (connection as any).CreatedHandle as number;
5454

5555
try {
56-
return await fn(new RustLockContext(handle));
56+
return await fn(new RustLockContext(handle, write ? 'readWrite' : 'readOnly'));
5757
} finally {
5858
await await powersyncCommand({ CloseHandle: handle });
5959
}
@@ -65,14 +65,13 @@ export class RustDatabaseAdapter extends DBAdapter {
6565
}
6666

6767
class RustLockContext extends LockContext {
68-
constructor(readonly handle: number) {
68+
constructor(
69+
readonly handle: number,
70+
readonly connectionType: 'readWrite' | 'readOnly'
71+
) {
6972
super();
7073
}
7174

72-
get connectionType(): undefined {
73-
return undefined;
74-
}
75-
7675
private async executeInner(query: string, params: any[]) {
7776
const result = await powersyncCommand({
7877
ExecuteSql: {

packages/web/src/db/adapters/SSRDBAdapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ export class SSRDBAdapter extends DBAdapter {
3838
}
3939

4040
class StubLockContext extends LockContext {
41-
get connectionType() {
42-
return undefined;
41+
get connectionType(): 'readWrite' {
42+
return 'readWrite';
4343
}
4444

4545
async executeRaw(): Promise<RawQueryResult> {

packages/web/src/db/adapters/wa-sqlite/DatabaseClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ class ClientLockContext extends LockContext {
194194
this.#token = token;
195195
}
196196

197-
get connectionType() {
198-
return undefined;
197+
get connectionType(): 'readWrite' {
198+
return 'readWrite';
199199
}
200200

201201
/**

0 commit comments

Comments
 (0)