File tree 1 file changed +10
-4
lines changed
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -33,11 +33,17 @@ describe('pool size of 1', () => {
33
33
34
34
it ( 'can only send 1 query at a time' , co . wrap ( function * ( ) {
35
35
const pool = new Pool ( { max : 1 } )
36
- const queries = _ . times ( 20 , ( i ) => {
37
- return pool . query ( 'SELECT COUNT(*) as counts FROM pg_stat_activity' )
38
- } )
36
+
37
+ // the query text column name changed in PostgreSQL 9.2
38
+ const versionResult = yield pool . query ( 'SHOW server_version_num' )
39
+ const version = parseInt ( versionResult . rows [ 0 ] . server_version_num , 10 )
40
+ const queryColumn = version < 90200 ? 'current_query' : 'query'
41
+
42
+ const queryText = 'SELECT COUNT(*) as counts FROM pg_stat_activity WHERE ' + queryColumn + ' = $1'
43
+ const queries = _ . times ( 20 , ( ) =>
44
+ pool . query ( queryText , [ queryText ] ) )
39
45
const results = yield Promise . all ( queries )
40
- const counts = results . map ( res => parseInt ( res . rows [ 0 ] . counts ) , 10 )
46
+ const counts = results . map ( res => parseInt ( res . rows [ 0 ] . counts , 10 ) )
41
47
expect ( counts ) . to . eql ( _ . times ( 20 , i => 1 ) )
42
48
return yield pool . end ( )
43
49
} ) )
You can’t perform that action at this time.
0 commit comments