@@ -26,7 +26,7 @@ import {
26
26
SqliteDriverConnection ,
27
27
SqliteDriverConnectionPool ,
28
28
SqliteDriverStatement ,
29
- SqliteRowObject
29
+ SqliteObjectRow
30
30
} from '@sqlite-js/driver' ;
31
31
32
32
export class ConnectionPoolImpl
@@ -54,7 +54,7 @@ export class ConnectionPoolImpl
54
54
throw new Error ( 'Method not implemented.' ) ;
55
55
}
56
56
57
- prepare < T extends SqliteRowObject > (
57
+ prepare < T extends SqliteObjectRow > (
58
58
sql : string ,
59
59
args ?: SqliteArguments
60
60
) : PreparedQuery < T > {
@@ -103,7 +103,7 @@ export class ConnectionPoolImpl
103
103
return tx ;
104
104
}
105
105
106
- async * stream < T extends SqliteRowObject > (
106
+ async * stream < T extends SqliteObjectRow > (
107
107
query : string ,
108
108
args ?: SqliteArguments ,
109
109
options ?: ( StreamOptions & ReserveConnectionOptions ) | undefined
@@ -116,7 +116,7 @@ export class ConnectionPoolImpl
116
116
}
117
117
}
118
118
119
- async select < T extends SqliteRowObject > (
119
+ async select < T extends SqliteObjectRow > (
120
120
query : string ,
121
121
args ?: SqliteArguments | undefined ,
122
122
options ?: ( QueryOptions & ReserveConnectionOptions ) | undefined
@@ -129,7 +129,7 @@ export class ConnectionPoolImpl
129
129
}
130
130
}
131
131
132
- async get < T extends SqliteRowObject > (
132
+ async get < T extends SqliteObjectRow > (
133
133
query : string ,
134
134
args ?: SqliteArguments | undefined ,
135
135
options ?: ( QueryOptions & ReserveConnectionOptions ) | undefined
@@ -142,7 +142,7 @@ export class ConnectionPoolImpl
142
142
}
143
143
}
144
144
145
- async getOptional < T extends SqliteRowObject > (
145
+ async getOptional < T extends SqliteObjectRow > (
146
146
query : string ,
147
147
args ?: SqliteArguments | undefined ,
148
148
options ?: ( QueryOptions & ReserveConnectionOptions ) | undefined
@@ -202,7 +202,7 @@ export class ReservedConnectionImpl implements ReservedSqliteConnection {
202
202
}
203
203
}
204
204
205
- prepare < T extends SqliteRowObject > (
205
+ prepare < T extends SqliteObjectRow > (
206
206
sql : string ,
207
207
args ?: SqliteArguments ,
208
208
options ?: QueryOptions
@@ -252,31 +252,31 @@ export class ReservedConnectionImpl implements ReservedSqliteConnection {
252
252
return this . connection . run ( query , args ) ;
253
253
}
254
254
255
- stream < T extends SqliteRowObject > (
255
+ stream < T extends SqliteObjectRow > (
256
256
query : string ,
257
257
args : SqliteArguments | undefined ,
258
258
options ?: StreamOptions | undefined
259
259
) : AsyncGenerator < T [ ] , any , unknown > {
260
260
return this . connection . stream ( query , args , options ) ;
261
261
}
262
262
263
- select < T extends SqliteRowObject > (
263
+ select < T extends SqliteObjectRow > (
264
264
query : string ,
265
265
args ?: SqliteArguments | undefined ,
266
266
options ?: QueryOptions | undefined
267
267
) : Promise < T [ ] > {
268
268
return this . connection . select ( query , args , options ) ;
269
269
}
270
270
271
- get < T extends SqliteRowObject > (
271
+ get < T extends SqliteObjectRow > (
272
272
query : string ,
273
273
args ?: SqliteArguments ,
274
274
options ?: QueryOptions
275
275
) : Promise < T > {
276
276
return this . connection . get ( query , args , options ) ;
277
277
}
278
278
279
- getOptional < T extends SqliteRowObject > (
279
+ getOptional < T extends SqliteObjectRow > (
280
280
query : string ,
281
281
args ?: SqliteArguments ,
282
282
options ?: QueryOptions
@@ -295,11 +295,13 @@ export class ConnectionImpl implements SqliteConnection {
295
295
296
296
private init ( ) {
297
297
this . _beginExclusive ??= this . prepare ( 'BEGIN EXCLUSIVE' , undefined , {
298
- persist : true
298
+ autoFinalize : true
299
+ } ) ;
300
+ this . _begin ??= this . prepare ( 'BEGIN' , undefined , { autoFinalize : true } ) ;
301
+ this . commit ??= this . prepare ( 'COMMIT' , undefined , { autoFinalize : true } ) ;
302
+ this . rollback ??= this . prepare ( 'ROLLBACK' , undefined , {
303
+ autoFinalize : true
299
304
} ) ;
300
- this . _begin ??= this . prepare ( 'BEGIN' , undefined , { persist : true } ) ;
301
- this . commit ??= this . prepare ( 'COMMIT' , undefined , { persist : true } ) ;
302
- this . rollback ??= this . prepare ( 'ROLLBACK' , undefined , { persist : true } ) ;
303
305
}
304
306
305
307
async begin ( options ?: TransactionOptions ) : Promise < SqliteBeginTransaction > {
@@ -362,7 +364,7 @@ export class ConnectionImpl implements SqliteConnection {
362
364
this . rollback ?. dispose ( ) ;
363
365
}
364
366
365
- prepare < T extends SqliteRowObject > (
367
+ prepare < T extends SqliteObjectRow > (
366
368
sql : string ,
367
369
args ?: SqliteArguments ,
368
370
options ?: PrepareOptions
@@ -392,7 +394,7 @@ export class ConnectionImpl implements SqliteConnection {
392
394
return await statement . run ( ) ;
393
395
}
394
396
395
- async * stream < T extends SqliteRowObject > (
397
+ async * stream < T extends SqliteObjectRow > (
396
398
query : string | PreparedQuery < T > ,
397
399
args : SqliteArguments | undefined ,
398
400
options ?: StreamOptions | undefined
@@ -416,7 +418,7 @@ export class ConnectionImpl implements SqliteConnection {
416
418
}
417
419
}
418
420
419
- async select < T extends SqliteRowObject > (
421
+ async select < T extends SqliteObjectRow > (
420
422
query : string ,
421
423
args ?: SqliteArguments ,
422
424
options ?: ( QueryOptions & ReserveConnectionOptions ) | undefined
@@ -432,7 +434,7 @@ export class ConnectionImpl implements SqliteConnection {
432
434
return rows as T [ ] ;
433
435
}
434
436
435
- async get < T extends SqliteRowObject > (
437
+ async get < T extends SqliteObjectRow > (
436
438
query : string ,
437
439
args ?: SqliteArguments ,
438
440
options ?: ( QueryOptions & ReserveConnectionOptions ) | undefined
@@ -444,7 +446,7 @@ export class ConnectionImpl implements SqliteConnection {
444
446
return row ;
445
447
}
446
448
447
- async getOptional < T extends SqliteRowObject > (
449
+ async getOptional < T extends SqliteObjectRow > (
448
450
query : string ,
449
451
args ?: SqliteArguments ,
450
452
options ?: ( QueryOptions & ReserveConnectionOptions ) | undefined
@@ -467,7 +469,7 @@ export class TransactionImpl implements SqliteTransaction {
467
469
await this . con . rollback ! . select ( ) ;
468
470
}
469
471
470
- prepare < T extends SqliteRowObject > (
472
+ prepare < T extends SqliteObjectRow > (
471
473
sql : string ,
472
474
args ?: SqliteArguments ,
473
475
options ?: QueryOptions
@@ -486,31 +488,31 @@ export class TransactionImpl implements SqliteTransaction {
486
488
return this . con . run ( query , args ) ;
487
489
}
488
490
489
- stream < T extends SqliteRowObject > (
491
+ stream < T extends SqliteObjectRow > (
490
492
query : string ,
491
493
args : SqliteArguments ,
492
494
options ?: StreamOptions | undefined
493
495
) : AsyncGenerator < T [ ] , any , unknown > {
494
496
return this . con . stream ( query , args , options ) ;
495
497
}
496
498
497
- select < T extends SqliteRowObject > (
499
+ select < T extends SqliteObjectRow > (
498
500
query : string ,
499
501
args ?: SqliteArguments ,
500
502
options ?: QueryOptions | undefined
501
503
) : Promise < T [ ] > {
502
504
return this . con . select ( query , args , options ) ;
503
505
}
504
506
505
- get < T extends SqliteRowObject > (
507
+ get < T extends SqliteObjectRow > (
506
508
query : string ,
507
509
args ?: SqliteArguments ,
508
510
options ?: QueryOptions | undefined
509
511
) : Promise < T > {
510
512
return this . con . get ( query , args , options ) ;
511
513
}
512
514
513
- getOptional < T extends SqliteRowObject > (
515
+ getOptional < T extends SqliteObjectRow > (
514
516
query : string ,
515
517
args ?: SqliteArguments ,
516
518
options ?: QueryOptions | undefined
@@ -556,7 +558,7 @@ class BeginTransactionImpl
556
558
}
557
559
}
558
560
559
- async select < T extends SqliteRowObject > (
561
+ async select < T extends SqliteObjectRow > (
560
562
query : string ,
561
563
args ?: SqliteArguments ,
562
564
options ?: ( QueryOptions & ReserveConnectionOptions ) | undefined
@@ -590,7 +592,7 @@ class BeginTransactionImpl
590
592
}
591
593
}
592
594
593
- class ConnectionPoolPreparedQueryImpl < T extends SqliteRowObject >
595
+ class ConnectionPoolPreparedQueryImpl < T extends SqliteObjectRow >
594
596
implements PreparedQuery < T >
595
597
{
596
598
[ Symbol . dispose ] : ( ) => void = undefined as any ;
@@ -668,7 +670,7 @@ class ConnectionPoolPreparedQueryImpl<T extends SqliteRowObject>
668
670
}
669
671
}
670
672
671
- class ConnectionPreparedQueryImpl < T extends SqliteRowObject >
673
+ class ConnectionPreparedQueryImpl < T extends SqliteObjectRow >
672
674
implements PreparedQuery < T >
673
675
{
674
676
[ Symbol . dispose ] : ( ) => void = undefined as any ;
0 commit comments