File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -142,7 +142,7 @@ function Postgres(a, b) {
142142 ? 'rollback'
143143 : 'rollback to ' + savepoint
144144 )
145- . then ( ( ) => reject ( err ) )
145+ . then ( ( ) => reject ( err ) , reject )
146146 } )
147147 . then ( begin && ( ( ) => {
148148 connections . push ( connection )
Original file line number Diff line number Diff line change @@ -750,6 +750,25 @@ t('little bobby tables', async() => {
750750 ]
751751} )
752752
753+ t ( 'Connection errors are caught using begin()' , {
754+ timeout : 20000
755+ } , async ( ) => {
756+ let error
757+ try {
758+ const sql = postgres ( { host : 'wat' } )
759+
760+ await sql . begin ( async ( sql ) => {
761+ await sql `insert into test (label, value) values (${ 1 } , ${ 2 } )`
762+ } )
763+
764+ await sql . end ( )
765+ } catch ( err ) {
766+ error = err
767+ }
768+
769+ return [ 'ENOTFOUND' , error . code ]
770+ } )
771+
753772t ( 'dynamic column name' , async ( ) => {
754773 return [ '!not_valid' , Object . keys ( ( await sql `select 1 as ${ sql ( '!not_valid' ) } ` ) [ 0 ] ) [ 0 ] ]
755774} )
You can’t perform that action at this time.
0 commit comments