mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
fix tests on older versions of postgres
This commit is contained in:
parent
f55a0cd1b4
commit
f5f5320b15
@ -13,10 +13,12 @@ pg.connect(helper.config, assert.success(function(client, done) {
|
||||
client2.id = 2;
|
||||
var pidColName = 'procpid'
|
||||
helper.versionGTE(client2, '9.2.0', assert.success(function(isGreater) {
|
||||
if(isGreater) {
|
||||
pidColName = 'pid';
|
||||
var killIdleQuery = 'SELECT pid, (SELECT pg_terminate_backend(pid)) AS killed FROM pg_stat_activity WHERE state = $1';
|
||||
var params = ['idle'];
|
||||
if(!isGreater) {
|
||||
killIdleQuery = 'SELECT procpid, (SELECT pg_terminate_backend(procpid)) AS killed FROM pg_stat_activity WHERE current_query LIKE $1';
|
||||
params = ['%IDLE%']
|
||||
}
|
||||
var killIdleQuery = 'SELECT ' + pidColName + ', (SELECT pg_terminate_backend(' + pidColName + ')) AS killed FROM pg_stat_activity WHERE state = $1';
|
||||
done2();
|
||||
//subscribe to the pg error event
|
||||
assert.emits(pg, 'error', function(error, brokenClient) {
|
||||
@ -25,7 +27,7 @@ pg.connect(helper.config, assert.success(function(client, done) {
|
||||
assert.equal(client.id, brokenClient.id);
|
||||
});
|
||||
//kill the connection from client
|
||||
client2.query(killIdleQuery, ['idle'], assert.success(function(res) {
|
||||
client2.query(killIdleQuery, params, assert.success(function(res) {
|
||||
//check to make sure client connection actually was killed
|
||||
assert.lengthIs(res.rows, 1);
|
||||
pg.end();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user