1
- const { t, not, ot } = require ( './test.js' )
1
+ /* eslint no-console: 0 */
2
+
3
+ const { t, not, ot } = require ( './test.js' ) // eslint-disable-line
2
4
const cp = require ( 'child_process' )
3
5
const path = require ( 'path' )
4
6
@@ -218,7 +220,7 @@ t('Parallel transactions', async() => {
218
220
await sql `create table test (a int)`
219
221
return [ '11' , ( await Promise . all ( [
220
222
sql . begin ( sql => sql `select 1` ) ,
221
- sql . begin ( sql => sql `select 1` ) ,
223
+ sql . begin ( sql => sql `select 1` )
222
224
] ) ) . map ( x => x . count ) . join ( '' ) ]
223
225
} , ( ) => sql `drop table test` )
224
226
@@ -244,7 +246,7 @@ t('Transaction waits', async() => {
244
246
245
247
return [ '11' , ( await Promise . all ( [
246
248
sql . begin ( sql => sql `select 1` ) ,
247
- sql . begin ( sql => sql `select 1` ) ,
249
+ sql . begin ( sql => sql `select 1` )
248
250
] ) ) . map ( x => x . count ) . join ( '' ) ]
249
251
} , ( ) => sql `drop table test` )
250
252
@@ -260,7 +262,7 @@ t('Throw syntax error', async() =>
260
262
261
263
t ( 'Connect using uri' , async ( ) =>
262
264
[ true , await new Promise ( ( resolve , reject ) => {
263
- const sql = postgres ( 'postgres://' + login . user + ':' + ( login . pass || '' ) + '@localhost:5432/' + options . db , {
265
+ const sql = postgres ( 'postgres://' + login . user + ':' + ( login . pass || '' ) + '@localhost:5432/' + options . db , {
264
266
timeout : 0.1
265
267
} )
266
268
sql `select 1` . then ( ( ) => resolve ( true ) , reject )
@@ -515,7 +517,7 @@ t('double listen', async() => {
515
517
) . then ( ( ) => count ++ )
516
518
517
519
// for coverage
518
- sql . listen ( 'weee' , ( ) => { } ) . then ( sql . end )
520
+ sql . listen ( 'weee' , ( ) => { /* noop */ } ) . then ( sql . end )
519
521
520
522
return [ 2 , count ]
521
523
} )
@@ -571,7 +573,7 @@ t('await sql() throws not tagged error', async() => {
571
573
let error
572
574
try {
573
575
await sql ( 'select 1' )
574
- } catch ( e ) {
576
+ } catch ( e ) {
575
577
error = e . code
576
578
}
577
579
return [ 'NOT_TAGGED_CALL' , error ]
@@ -580,8 +582,8 @@ t('await sql() throws not tagged error', async() => {
580
582
t ( 'sql().then throws not tagged error' , async ( ) => {
581
583
let error
582
584
try {
583
- sql ( 'select 1' ) . then ( ( ) => { } )
584
- } catch ( e ) {
585
+ sql ( 'select 1' ) . then ( ( ) => { /* noop */ } )
586
+ } catch ( e ) {
585
587
error = e . code
586
588
}
587
589
return [ 'NOT_TAGGED_CALL' , error ]
@@ -591,7 +593,7 @@ t('sql().catch throws not tagged error', async() => {
591
593
let error
592
594
try {
593
595
await sql ( 'select 1' )
594
- } catch ( e ) {
596
+ } catch ( e ) {
595
597
error = e . code
596
598
}
597
599
return [ 'NOT_TAGGED_CALL' , error ]
@@ -600,45 +602,45 @@ t('sql().catch throws not tagged error', async() => {
600
602
t ( 'sql().finally throws not tagged error' , async ( ) => {
601
603
let error
602
604
try {
603
- sql ( 'select 1' ) . finally ( ( ) => { } )
604
- } catch ( e ) {
605
+ sql ( 'select 1' ) . finally ( ( ) => { /* noop */ } )
606
+ } catch ( e ) {
605
607
error = e . code
606
608
}
607
609
return [ 'NOT_TAGGED_CALL' , error ]
608
610
} )
609
611
610
- t ( 'dynamic column name' , async ( ) => {
612
+ t ( 'dynamic column name' , async ( ) => {
611
613
return [ '!not_valid' , Object . keys ( ( await sql `select 1 as ${ sql ( '!not_valid' ) } ` ) [ 0 ] ) [ 0 ] ]
612
614
} )
613
615
614
- t ( 'dynamic select as' , async ( ) => {
616
+ t ( 'dynamic select as' , async ( ) => {
615
617
return [ 2 , ( await sql `select ${ sql ( { a : 1 , b : 2 } ) } ` ) [ 0 ] . b ]
616
618
} )
617
619
618
- t ( 'dynamic select as pluck' , async ( ) => {
620
+ t ( 'dynamic select as pluck' , async ( ) => {
619
621
return [ undefined , ( await sql `select ${ sql ( { a : 1 , b : 2 } , 'a' ) } ` ) [ 0 ] . b ]
620
622
} )
621
623
622
- t ( 'dynamic insert' , async ( ) => {
624
+ t ( 'dynamic insert' , async ( ) => {
623
625
await sql `create table test (a int, b text)`
624
626
const x = { a : 42 , b : 'the answer' }
625
627
626
628
return [ 'the answer' , ( await sql `insert into test ${ sql ( x ) } returning *` ) [ 0 ] . b ]
627
629
} , ( ) => sql `drop table test` )
628
630
629
- t ( 'dynamic insert pluck' , async ( ) => {
631
+ t ( 'dynamic insert pluck' , async ( ) => {
630
632
await sql `create table test (a int, b text)`
631
633
const x = { a : 42 , b : 'the answer' }
632
634
633
635
return [ null , ( await sql `insert into test ${ sql ( x , 'a' ) } returning *` ) [ 0 ] . b ]
634
636
} , ( ) => sql `drop table test` )
635
637
636
- t ( 'array insert' , async ( ) => {
638
+ t ( 'array insert' , async ( ) => {
637
639
await sql `create table test (a int, b int)`
638
- return [ 2 , ( await sql `insert into test (a, b) values (${ [ 1 , 2 ] } ) returning *` ) [ 0 ] . b ]
640
+ return [ 2 , ( await sql `insert into test (a, b) values (${ [ 1 , 2 ] } ) returning *` ) [ 0 ] . b ]
639
641
} , ( ) => sql `drop table test` )
640
642
641
- t ( 'parameters in()' , async ( ) => {
643
+ t ( 'parameters in()' , async ( ) => {
642
644
return [ 2 , ( await sql `
643
645
with rows as (
644
646
select * from (values (1), (2), (3), (4)) as x(a)
@@ -647,34 +649,34 @@ t('parameters in()', async () => {
647
649
` ) . count ]
648
650
} )
649
651
650
- t ( 'dynamic multi row insert' , async ( ) => {
652
+ t ( 'dynamic multi row insert' , async ( ) => {
651
653
await sql `create table test (a int, b text)`
652
654
const x = { a : 42 , b : 'the answer' }
653
655
654
656
return [ 'the answer' , ( await sql `insert into test ${ sql ( [ x , x ] ) } returning *` ) [ 1 ] . b ]
655
657
} , ( ) => sql `drop table test` )
656
658
657
- t ( 'dynamic update' , async ( ) => {
659
+ t ( 'dynamic update' , async ( ) => {
658
660
await sql `create table test (a int, b text)`
659
661
await sql `insert into test (a, b) values (17, 'wrong')`
660
662
661
663
return [ 'the answer' , ( await sql `update test set ${ sql ( { a : 42 , b : 'the answer' } ) } returning *` ) [ 0 ] . b ]
662
664
} , ( ) => sql `drop table test` )
663
665
664
- t ( 'dynamic update pluck' , async ( ) => {
666
+ t ( 'dynamic update pluck' , async ( ) => {
665
667
await sql `create table test (a int, b text)`
666
668
await sql `insert into test (a, b) values (17, 'wrong')`
667
669
668
670
return [ 'wrong' , ( await sql `update test set ${ sql ( { a : 42 , b : 'the answer' } , 'a' ) } returning *` ) [ 0 ] . b ]
669
671
} , ( ) => sql `drop table test` )
670
672
671
- t ( 'dynamic select array' , async ( ) => {
673
+ t ( 'dynamic select array' , async ( ) => {
672
674
await sql `create table test (a int, b text)`
673
675
await sql `insert into test (a, b) values (42, 'yay')`
674
676
return [ 'yay' , ( await sql `select ${ sql ( [ 'a' , 'b' ] ) } from test` ) [ 0 ] . b ]
675
677
} , ( ) => sql `drop table test` )
676
678
677
- t ( 'dynamic select args' , async ( ) => {
679
+ t ( 'dynamic select args' , async ( ) => {
678
680
await sql `create table test (a int, b text)`
679
681
await sql `insert into test (a, b) values (42, 'yay')`
680
682
return [ 'yay' , ( await sql `select ${ sql ( 'a' , 'b' ) } from test` ) [ 0 ] . b ]
@@ -766,13 +768,13 @@ t('Stream works', async() => {
766
768
} )
767
769
768
770
t ( 'Stream returns empty array' , async ( ) => {
769
- return [ 0 , ( await sql `select 1 as x` . stream ( x => { } ) ) . length ]
771
+ return [ 0 , ( await sql `select 1 as x` . stream ( ( ) => { /* noop */ } ) ) . length ]
770
772
} )
771
773
772
774
t ( 'Transform row' , async ( ) => {
773
775
const sql = postgres ( {
774
776
...options ,
775
- transform : { row : x => 1 }
777
+ transform : { row : ( ) => 1 }
776
778
} )
777
779
778
780
return [ 1 , ( await sql `select 'wat'` ) [ 0 ] ]
@@ -782,7 +784,7 @@ t('Transform row stream', async() => {
782
784
let result
783
785
const sql = postgres ( {
784
786
...options ,
785
- transform : { row : x => 1 }
787
+ transform : { row : ( ) => 1 }
786
788
} )
787
789
788
790
await sql `select 1` . stream ( x => result = x )
@@ -793,7 +795,7 @@ t('Transform row stream', async() => {
793
795
t ( 'Transform value' , async ( ) => {
794
796
const sql = postgres ( {
795
797
...options ,
796
- transform : { value : x => 1 }
798
+ transform : { value : ( ) => 1 }
797
799
} )
798
800
799
801
return [ 1 , ( await sql `select 'wat' as x` ) [ 0 ] . x ]
@@ -816,7 +818,7 @@ t('Debug works', async() => {
816
818
let result
817
819
const sql = postgres ( {
818
820
...options ,
819
- debug : ( connection_id , str , args ) => result = str
821
+ debug : ( connection_id , str ) => result = str
820
822
} )
821
823
822
824
await sql `select 1`
0 commit comments