File tree Expand file tree Collapse file tree 7 files changed +5
-42
lines changed
dialect-sqlite-worker/src
dialect-wasqlite-worker/src Expand file tree Collapse file tree 7 files changed +5
-42
lines changed Original file line number Diff line number Diff line change @@ -37,19 +37,9 @@ export class BunWorkerDriver implements Driver {
37
37
} )
38
38
this . connection = new BunWorkerConnection ( this . worker , this . mitt )
39
39
40
- this . config ?. usePRAGMA && await this . optimzePragma ( this . connection )
41
-
42
40
await this . config ?. onCreateConnection ?.( this . connection )
43
41
}
44
42
45
- private async optimzePragma ( conn : DatabaseConnection ) : Promise < void > {
46
- await conn . executeQuery ( CompiledQuery . raw ( 'PRAGMA cache_size = 4096;' ) )
47
- await conn . executeQuery ( CompiledQuery . raw ( 'PRAGMA journal_mode = WAL;' ) )
48
- await conn . executeQuery ( CompiledQuery . raw ( 'PRAGMA temp_store = MEMORY;' ) )
49
- await conn . executeQuery ( CompiledQuery . raw ( `PRAGMA page_size = ${ 32 * 1024 } ;` ) )
50
- await conn . executeQuery ( CompiledQuery . raw ( 'PRAGMA synchronous = NORMAL;' ) )
51
- }
52
-
53
43
async acquireConnection ( ) : Promise < DatabaseConnection > {
54
44
// SQLite only has one single connection. We use a mutex here to wait
55
45
// until the single connection has been released.
Original file line number Diff line number Diff line change @@ -11,10 +11,6 @@ export type BunWorkerDialectConfig = {
11
11
*/
12
12
url ?: string
13
13
onCreateConnection ?: ( connection : DatabaseConnection ) => Promisable < void >
14
- /**
15
- * use built-in pragmas
16
- */
17
- usePRAGMA ?: boolean
18
14
/**
19
15
* use bun:sqlite's built-in statment cache
20
16
* @see https://bun.sh/docs/api/sqlite#query
Original file line number Diff line number Diff line change @@ -30,7 +30,11 @@ describe('test', () => {
30
30
int8 : new Uint8Array ( [ 1 , 2 , 3 ] ) ,
31
31
} )
32
32
. execute ( )
33
- const { age, name, int8 } = await db . selectFrom ( 'test' ) . selectAll ( ) . limit ( 1 ) . executeTakeFirstOrThrow ( )
33
+ const { age, name, int8 } = await db
34
+ . selectFrom ( 'test' )
35
+ . selectAll ( )
36
+ . limit ( 1 )
37
+ . executeTakeFirstOrThrow ( )
34
38
expect ( age ) . toStrictEqual ( 18 )
35
39
expect ( name ) . toStrictEqual ( 'test' )
36
40
expect ( int8 ) . toStrictEqual ( Uint8Array . from ( [ 1 , 2 , 3 ] ) )
Original file line number Diff line number Diff line change @@ -30,18 +30,9 @@ export class SqliteWorkerDriver implements Driver {
30
30
} )
31
31
this . connection = new SqliteWorkerConnection ( this . worker , this . emit )
32
32
33
- this . config . usePRAGMA && await this . optimzePragma ( this . connection )
34
-
35
33
await onCreateConnection ?.( this . connection )
36
34
}
37
35
38
- private async optimzePragma ( conn : DatabaseConnection ) : Promise < void > {
39
- await conn . executeQuery ( CompiledQuery . raw ( 'PRAGMA cache_size = 4096;' ) )
40
- await conn . executeQuery ( CompiledQuery . raw ( 'PRAGMA journal_mode = WAL;' ) )
41
- await conn . executeQuery ( CompiledQuery . raw ( 'PRAGMA temp_store = MEMORY;' ) )
42
- await conn . executeQuery ( CompiledQuery . raw ( `PRAGMA page_size = ${ 32 * 1024 } ;` ) )
43
- }
44
-
45
36
async acquireConnection ( ) : Promise < DatabaseConnection > {
46
37
// SQLite only has one single connection. We use a mutex here to wait
47
38
// until the single connection has been released.
Original file line number Diff line number Diff line change @@ -14,10 +14,6 @@ export type SqliteWorkerDialectConfig = {
14
14
*/
15
15
option ?: Options
16
16
onCreateConnection ?: ( connection : DatabaseConnection ) => Promisable < void >
17
- /**
18
- * use built-in pragmas
19
- */
20
- usePRAGMA ?: boolean
21
17
}
22
18
23
19
export class SqliteWorkerDialect implements Dialect {
Original file line number Diff line number Diff line change @@ -35,19 +35,9 @@ export class WaSqliteWorkerDriver implements Driver {
35
35
} )
36
36
this . connection = new WaSqliteWorkerConnection ( this . worker , this . mitt )
37
37
38
- this . config . usePRAGMA && await this . optimzePragma ( this . connection )
39
-
40
38
await this . config . onCreateConnection ?.( this . connection )
41
39
}
42
40
43
- private async optimzePragma ( conn : DatabaseConnection ) : Promise < void > {
44
- await conn . executeQuery ( CompiledQuery . raw ( 'PRAGMA cache_size = 4096;' ) )
45
- await conn . executeQuery ( CompiledQuery . raw ( 'PRAGMA journal_mode = WAL;' ) )
46
- await conn . executeQuery ( CompiledQuery . raw ( 'PRAGMA temp_store = MEMORY;' ) )
47
- await conn . executeQuery ( CompiledQuery . raw ( `PRAGMA page_size = ${ 32 * 1024 } ;` ) )
48
- await conn . executeQuery ( CompiledQuery . raw ( 'PRAGMA synchronous = NORMAL;' ) )
49
- }
50
-
51
41
async acquireConnection ( ) : Promise < DatabaseConnection > {
52
42
// SQLite only has one single connection. We use a mutex here to wait
53
43
// until the single connection has been released.
Original file line number Diff line number Diff line change @@ -23,10 +23,6 @@ export interface WaSqliteWorkerDialectConfig {
23
23
*/
24
24
worker ?: Worker
25
25
onCreateConnection ?: ( connection : DatabaseConnection ) => Promise < void >
26
- /**
27
- * use built-in pragmas
28
- */
29
- usePRAGMA ?: boolean
30
26
}
31
27
export class WaSqliteWorkerDialect implements Dialect {
32
28
readonly #config: WaSqliteWorkerDialectConfig
You can’t perform that action at this time.
0 commit comments