@@ -87,16 +87,6 @@ export interface SqlExecutor {
8787 * @public
8888 */
8989export abstract class LockContext implements SqlExecutor , DBGetUtils {
90- /**
91- * How the connection has been opened.
92- *
93- * `readWrite` indicates that the lock context is capable of writing to the database.
94- * `queryOnly` indicates that the lock context has been opened in a readwrite mode, but a `PRAGMA query_only = TRUE`
95- * disabled writes.
96- * `readOnly` indicates that the lock context has been opened by passing `SQLITE_OPEN_READONLY` to `sqlite3_open_v2`.
97- */
98- abstract get connectionType ( ) : 'readWrite' | 'queryOnly' | 'readOnly' ;
99-
10090 abstract executeRaw < T > ( query : string , params ?: any [ ] | undefined ) : Promise < RawQueryResult > ;
10191
10292 async getAll < T > ( sql : string , parameters ?: any [ ] ) : Promise < T [ ] > {
@@ -237,10 +227,6 @@ class TransactionImplementation extends LockContext {
237227 super ( ) ;
238228 }
239229
240- get connectionType ( ) {
241- return this . inner . connectionType ;
242- }
243-
244230 async commit ( ) : Promise < void > {
245231 if ( this . finalized ) {
246232 return ;
@@ -272,16 +258,8 @@ class TransactionImplementation extends LockContext {
272258 static async runWith < T > ( ctx : LockContext , fn : ( tx : Transaction ) => Promise < T > ) : Promise < T > {
273259 let tx = new TransactionImplementation ( ctx ) ;
274260
275- // For write transactions, use BEGIN IMMEDIATE to immediately obtain a write lock on the database (instead of doing
276- // that on the first statement). If we have a genuine read-only connection, we also use BEGIN IMMEDIATE there: In
277- // WAL mode, that ensures we pin the current state of the database (instead of the state at the first statement in
278- // the transaction). But if we have a "fake" read-only connection implemented through `pragma query_only = true`, we
279- // can't use this trick because it would attempt to lock the connection. So there, we use a regular `BEGIN`
280- // statement.
281- const useBeginImmediate = ctx . connectionType != 'queryOnly' ;
282-
283261 try {
284- await ctx . execute ( useBeginImmediate ? 'BEGIN IMMEDIATE' : 'BEGIN ') ;
262+ await ctx . execute ( 'BEGIN IMMEDIATE' ) ;
285263
286264 const result = await fn ( tx ) ;
287265 await tx . commit ( ) ;
0 commit comments