@@ -531,7 +531,7 @@ t('Connection ended timeout', async() => {
531
531
532
532
t ( 'Connection ended error' , async ( ) => {
533
533
const sql = postgres ( options )
534
- sql . end ( )
534
+ await sql . end ( )
535
535
return [ 'CONNECTION_ENDED' , ( await sql `` . catch ( x => x . code ) ) ]
536
536
} )
537
537
@@ -611,6 +611,46 @@ t('Transform nested json in arrays', async() => {
611
611
return [ 'aBcD' , ( await sql `select '[{"a_b":1},{"c_d":2}]'::jsonb as x` ) [ 0 ] . x . map ( Object . keys ) . join ( '' ) ]
612
612
} )
613
613
614
+ t ( 'Transform deeply nested json object in arrays' , async ( ) => {
615
+ const sql = postgres ( {
616
+ ...options ,
617
+ transform : postgres . camel
618
+ } )
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 ( '_' ) ]
632
+ } )
633
+
634
+ t ( 'Transform deeply nested json array in arrays' , async ( ) => {
635
+ const sql = postgres ( {
636
+ ...options ,
637
+ transform : postgres . camel
638
+ } )
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 ( '_' ) ]
652
+ } )
653
+
614
654
t ( 'Bypass transform for json primitive' , async ( ) => {
615
655
const sql = postgres ( {
616
656
...options ,
0 commit comments