File tree 6 files changed +36
-21
lines changed
6 files changed +36
-21
lines changed Original file line number Diff line number Diff line change @@ -207,7 +207,7 @@ function Postgres(a, b) {
207
207
}
208
208
209
209
async function scope ( c , fn , name ) {
210
- const sql = Sql ( handler , true )
210
+ const sql = Sql ( handler )
211
211
sql . savepoint = savepoint
212
212
let uncaughtError
213
213
name && await sql `savepoint ${ sql ( name ) } `
Original file line number Diff line number Diff line change @@ -237,19 +237,24 @@ t('Transaction requests are executed implicitly', async() => {
237
237
const sql = postgres ( { debug : true , idle_timeout : 1 , fetch_types : false } )
238
238
return [
239
239
'testing' ,
240
- ( await sql . begin ( async sql => {
241
- sql `select set_config('postgres_js.test', 'testing', true)`
242
- return await sql `select current_setting('postgres_js.test') as x`
243
- } ) ) [ 0 ] . x
240
+ ( await sql . begin ( sql => [
241
+ sql `select set_config('postgres_js.test', 'testing', true)` ,
242
+ sql `select current_setting('postgres_js.test') as x`
243
+ ] ) ) [ 1 ] [ 0 ] . x
244
244
]
245
245
} )
246
246
247
247
t ( 'Uncaught transaction request errors bubbles to transaction' , async ( ) => [
248
248
'42703' ,
249
- ( await sql . begin ( sql => (
249
+ ( await sql . begin ( sql => [
250
250
sql `select wat` ,
251
251
sql `select current_setting('postgres_js.test') as x, ${ 1 } as a`
252
- ) ) . catch ( e => e . code ) )
252
+ ] ) . catch ( e => e . code ) )
253
+ ] )
254
+
255
+ t ( 'Fragments in transactions' , async ( ) => [
256
+ true ,
257
+ ( await sql . begin ( sql => sql `select true as x where ${ sql `1=1` } ` ) ) [ 0 ] . x
253
258
] )
254
259
255
260
t ( 'Transaction rejects with rethrown error' , async ( ) => [
Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ function Postgres(a, b) {
208
208
}
209
209
210
210
async function scope ( c , fn , name ) {
211
- const sql = Sql ( handler , true )
211
+ const sql = Sql ( handler )
212
212
sql . savepoint = savepoint
213
213
let uncaughtError
214
214
name && await sql `savepoint ${ sql ( name ) } `
Original file line number Diff line number Diff line change @@ -239,19 +239,24 @@ t('Transaction requests are executed implicitly', async() => {
239
239
const sql = postgres ( { debug : true , idle_timeout : 1 , fetch_types : false } )
240
240
return [
241
241
'testing' ,
242
- ( await sql . begin ( async sql => {
243
- sql `select set_config('postgres_js.test', 'testing', true)`
244
- return await sql `select current_setting('postgres_js.test') as x`
245
- } ) ) [ 0 ] . x
242
+ ( await sql . begin ( sql => [
243
+ sql `select set_config('postgres_js.test', 'testing', true)` ,
244
+ sql `select current_setting('postgres_js.test') as x`
245
+ ] ) ) [ 1 ] [ 0 ] . x
246
246
]
247
247
} )
248
248
249
249
t ( 'Uncaught transaction request errors bubbles to transaction' , async ( ) => [
250
250
'42703' ,
251
- ( await sql . begin ( sql => (
251
+ ( await sql . begin ( sql => [
252
252
sql `select wat` ,
253
253
sql `select current_setting('postgres_js.test') as x, ${ 1 } as a`
254
- ) ) . catch ( e => e . code ) )
254
+ ] ) . catch ( e => e . code ) )
255
+ ] )
256
+
257
+ t ( 'Fragments in transactions' , async ( ) => [
258
+ true ,
259
+ ( await sql . begin ( sql => sql `select true as x where ${ sql `1=1` } ` ) ) [ 0 ] . x
255
260
] )
256
261
257
262
t ( 'Transaction rejects with rethrown error' , async ( ) => [
Original file line number Diff line number Diff line change @@ -207,7 +207,7 @@ function Postgres(a, b) {
207
207
}
208
208
209
209
async function scope ( c , fn , name ) {
210
- const sql = Sql ( handler , true )
210
+ const sql = Sql ( handler )
211
211
sql . savepoint = savepoint
212
212
let uncaughtError
213
213
name && await sql `savepoint ${ sql ( name ) } `
Original file line number Diff line number Diff line change @@ -237,19 +237,24 @@ t('Transaction requests are executed implicitly', async() => {
237
237
const sql = postgres ( { debug : true , idle_timeout : 1 , fetch_types : false } )
238
238
return [
239
239
'testing' ,
240
- ( await sql . begin ( async sql => {
241
- sql `select set_config('postgres_js.test', 'testing', true)`
242
- return await sql `select current_setting('postgres_js.test') as x`
243
- } ) ) [ 0 ] . x
240
+ ( await sql . begin ( sql => [
241
+ sql `select set_config('postgres_js.test', 'testing', true)` ,
242
+ sql `select current_setting('postgres_js.test') as x`
243
+ ] ) ) [ 1 ] [ 0 ] . x
244
244
]
245
245
} )
246
246
247
247
t ( 'Uncaught transaction request errors bubbles to transaction' , async ( ) => [
248
248
'42703' ,
249
- ( await sql . begin ( sql => (
249
+ ( await sql . begin ( sql => [
250
250
sql `select wat` ,
251
251
sql `select current_setting('postgres_js.test') as x, ${ 1 } as a`
252
- ) ) . catch ( e => e . code ) )
252
+ ] ) . catch ( e => e . code ) )
253
+ ] )
254
+
255
+ t ( 'Fragments in transactions' , async ( ) => [
256
+ true ,
257
+ ( await sql . begin ( sql => sql `select true as x where ${ sql `1=1` } ` ) ) [ 0 ] . x
253
258
] )
254
259
255
260
t ( 'Transaction rejects with rethrown error' , async ( ) => [
You can’t perform that action at this time.
0 commit comments