@@ -351,6 +351,11 @@ t('Connect using uri', async() =>
351351 } ) ]
352352)
353353
354+ t ( 'Options from uri with special characters in user and pass' , async ( ) => {
355+ const opt = postgres ( { user : 'öla' , pass : 'pass^word' } ) . options
356+ return [ [ opt . user , opt . pass ] . toString ( ) , 'öla,pass^word' ]
357+ } )
358+
354359t ( 'Fail with proper error on no host' , async ( ) =>
355360 [ 'ECONNREFUSED' , ( await new Promise ( ( resolve , reject ) => {
356361 const sql = postgres ( 'postgres://localhost:33333/' + options . db , {
@@ -540,7 +545,7 @@ t('Connection end does not cancel query', async() => {
540545
541546 const promise = sql `select 1 as x` . execute ( )
542547
543- sql . end ( )
548+ await sql . end ( )
544549
545550 return [ 1 , ( await promise ) [ 0 ] . x ]
546551} )
@@ -616,39 +621,37 @@ t('Transform deeply nested json object in arrays', async() => {
616621 ...options ,
617622 transform : postgres . camel
618623 } )
619- return [ 'childObj_deeplyNestedObj_grandchildObj' , ( await sql `select '[{"nested_obj": {"child_obj": 2, "deeply_nested_obj": {"grandchild_obj": 3}}}]'::jsonb as x` ) [ 0 ] . x
620- . map ( ( x ) => {
621- let result ;
622- for ( const key in x ) {
623- const result1 = Object . keys ( x [ key ] ) ;
624- const result2 = Object . keys ( x [ key ] . deeplyNestedObj ) ;
625-
626- result = [ ...result1 , ...result2 ] ;
627- }
628-
629- return result ;
630- } ) [ 0 ]
631- . join ( '_' ) ]
624+ return [
625+ 'childObj_deeplyNestedObj_grandchildObj' ,
626+ ( await sql `
627+ select '[{"nested_obj": {"child_obj": 2, "deeply_nested_obj": {"grandchild_obj": 3}}}]'::jsonb as x
628+ ` ) [ 0 ] . x . map ( x => {
629+ let result
630+ for ( const key in x )
631+ result = [ ...Object . keys ( x [ key ] ) , ...Object . keys ( x [ key ] . deeplyNestedObj ) ]
632+ return result
633+ } ) [ 0 ]
634+ . join ( '_' )
635+ ]
632636} )
633637
634638t ( 'Transform deeply nested json array in arrays' , async ( ) => {
635639 const sql = postgres ( {
636640 ...options ,
637641 transform : postgres . camel
638642 } )
639- return [ 'childArray_deeplyNestedArray_grandchildArray' , ( await sql `select '[{"nested_array": [{"child_array": 2, "deeply_nested_array": [{"grandchild_array":3}]}]}]'::jsonb AS x` ) [ 0 ] . x
640- . map ( ( x ) => {
641- let result ;
642- for ( const key in x ) {
643- const result1 = Object . keys ( x [ key ] [ 0 ] ) ;
644- const result2 = Object . keys ( x [ key ] [ 0 ] . deeplyNestedArray [ 0 ] ) ;
645-
646- result = [ ...result1 , ...result2 ] ;
647- }
648-
649- return result ;
650- } ) [ 0 ]
651- . join ( '_' ) ]
643+ return [
644+ 'childArray_deeplyNestedArray_grandchildArray' ,
645+ ( await sql `
646+ select '[{"nested_array": [{"child_array": 2, "deeply_nested_array": [{"grandchild_array":3}]}]}]'::jsonb AS x
647+ ` ) [ 0 ] . x . map ( ( x ) => {
648+ let result
649+ for ( const key in x )
650+ result = [ ...Object . keys ( x [ key ] [ 0 ] ) , ...Object . keys ( x [ key ] [ 0 ] . deeplyNestedArray [ 0 ] ) ]
651+ return result
652+ } ) [ 0 ]
653+ . join ( '_' )
654+ ]
652655} )
653656
654657t ( 'Bypass transform for json primitive' , async ( ) => {
@@ -1630,7 +1633,7 @@ t('connect_timeout error message includes host:port', { timeout: 20 }, async() =
16301633 err = e . message
16311634 } )
16321635 server . close ( )
1633- return [ [ " write CONNECT_TIMEOUT 127.0.0.1:" , port ] . join ( "" ) , err ]
1636+ return [ [ ' write CONNECT_TIMEOUT 127.0.0.1:' , port ] . join ( '' ) , err ]
16341637} )
16351638
16361639t ( 'requests works after single connect_timeout' , async ( ) => {
0 commit comments