@@ -30,6 +30,7 @@ const options = {
3030 user : login . user ,
3131 pass : login . pass ,
3232 idle_timeout : 0.2 ,
33+ debug : true ,
3334 max : 1
3435}
3536
@@ -891,6 +892,7 @@ t('numeric is returned as string', async() => [
891892] )
892893
893894t ( 'Async stack trace' , async ( ) => {
895+ const sql = postgres ( { ...options , debug : false } )
894896 return [
895897 parseInt ( new Error ( ) . stack . split ( '\n' ) [ 1 ] . split ( ':' ) [ 1 ] ) + 1 ,
896898 parseInt ( await sql `select.sql` . catch ( x => x . stack . split ( '\n' ) . pop ( ) . split ( ':' ) [ 1 ] ) )
@@ -924,15 +926,31 @@ t('Error contains query parameters', async() => [
924926 ( await sql `selec ${ 1 } ` . catch ( err => err . parameters [ 0 ] . value ) )
925927] )
926928
927- t ( 'Query string is not enumerable' , async ( ) => [
929+ t ( 'Query string is not enumerable' , async ( ) => {
930+ const sql = postgres ( { ...options , debug : false } )
931+ return [
928932 - 1 ,
929933 ( await sql `selec 1` . catch ( err => Object . keys ( err ) . indexOf ( 'query' ) ) )
930- ] )
934+ ]
935+ } )
931936
932- t ( 'Query parameters are not enumerable' , async ( ) => [
933- - 1 ,
934- ( await sql `selec ${ 1 } ` . catch ( err => Object . keys ( err ) . indexOf ( 'parameters' ) ) )
935- ] )
937+ t ( 'Query and parameters are not enumerable if debug is not set' , async ( ) => {
938+ const sql = postgres ( { ...options , debug : false } )
939+
940+ return [
941+ false ,
942+ ( await sql `selec ${ 1 } ` . catch ( err => err . propertyIsEnumerable ( 'parameters' ) || err . propertyIsEnumerable ( 'query' ) ) )
943+ ]
944+ } )
945+
946+ t ( 'Query and parameters are enumerable if debug is set' , async ( ) => {
947+ const sql = postgres ( { ...options , debug : true } )
948+
949+ return [
950+ true ,
951+ ( await sql `selec ${ 1 } ` . catch ( err => err . propertyIsEnumerable ( 'parameters' ) && err . propertyIsEnumerable ( 'query' ) ) )
952+ ]
953+ } )
936954
937955t ( 'connect_timeout throws proper error' , async ( ) => [
938956 'CONNECT_TIMEOUT' ,
0 commit comments