@@ -351,6 +351,11 @@ t('Connect using uri', async() =>
351
351
} ) ]
352
352
)
353
353
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
+
354
359
t ( 'Fail with proper error on no host' , async ( ) =>
355
360
[ 'ECONNREFUSED' , ( await new Promise ( ( resolve , reject ) => {
356
361
const sql = postgres ( 'postgres://localhost:33333/' + options . db , {
@@ -540,7 +545,7 @@ t('Connection end does not cancel query', async() => {
540
545
541
546
const promise = sql `select 1 as x` . execute ( )
542
547
543
- sql . end ( )
548
+ await sql . end ( )
544
549
545
550
return [ 1 , ( await promise ) [ 0 ] . x ]
546
551
} )
@@ -616,39 +621,37 @@ t('Transform deeply nested json object in arrays', async() => {
616
621
...options ,
617
622
transform : postgres . camel
618
623
} )
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
+ ]
632
636
} )
633
637
634
638
t ( 'Transform deeply nested json array in arrays' , async ( ) => {
635
639
const sql = postgres ( {
636
640
...options ,
637
641
transform : postgres . camel
638
642
} )
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
+ ]
652
655
} )
653
656
654
657
t ( 'Bypass transform for json primitive' , async ( ) => {
@@ -1630,7 +1633,7 @@ t('connect_timeout error message includes host:port', { timeout: 20 }, async() =
1630
1633
err = e . message
1631
1634
} )
1632
1635
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 ]
1634
1637
} )
1635
1638
1636
1639
t ( 'requests works after single connect_timeout' , async ( ) => {
0 commit comments