Skip to content

Commit 3f5df0a

Browse files
committed
make tests pass on pg@8.4.9
1 parent 01f3f3d commit 3f5df0a

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

lib/result.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var Result = function() {
88
this.rows = [];
99
};
1010

11-
var matchRegexp = /([A-Za-z]+) (\d+ )?(\d+)?/;
11+
var matchRegexp = /([A-Za-z]+) ?(\d+ )?(\d+)?/;
1212

1313
//adds a command complete message
1414
Result.prototype.addCommandComplete = function(msg) {

test/integration/client/query-error-handling-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test('error during query execution', function() {
2121
var killIdleQuery = "SELECT " + pidColName + ", (SELECT pg_terminate_backend(" + pidColName + ")) AS killed FROM pg_stat_activity WHERE " + queryColName + " = $1";
2222
client2.query(killIdleQuery, [sleepQuery], assert.calls(function(err, res) {
2323
assert.ifError(err);
24-
assert.equal(res.rowCount, 1);
24+
assert.equal(res.rows.length, 1);
2525
client2.end();
2626
assert.emits(client2, 'end');
2727
}));

test/integration/client/result-metadata-tests.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,31 @@ test('should return insert metadata', function() {
55
pg.connect(helper.config, assert.calls(function(err, client, done) {
66
assert.isNull(err);
77

8-
client.query("CREATE TEMP TABLE zugzug(name varchar(10))", assert.calls(function(err, result) {
9-
assert.isNull(err);
10-
assert.equal(result.oid, null);
11-
assert.equal(result.command, 'CREATE');
8+
helper.versionGTE(client, '9.0.0', assert.success(function(hasRowCount) {
9+
client.query("CREATE TEMP TABLE zugzug(name varchar(10))", assert.calls(function(err, result) {
10+
assert.isNull(err);
11+
assert.equal(result.oid, null);
12+
assert.equal(result.command, 'CREATE');
1213

13-
var q = client.query("INSERT INTO zugzug(name) VALUES('more work?')", assert.calls(function(err, result) {
14-
assert.equal(result.command, "INSERT");
15-
assert.equal(result.rowCount, 1);
16-
17-
client.query('SELECT * FROM zugzug', assert.calls(function(err, result) {
18-
assert.isNull(err);
14+
var q = client.query("INSERT INTO zugzug(name) VALUES('more work?')", assert.calls(function(err, result) {
15+
assert.equal(result.command, "INSERT");
1916
assert.equal(result.rowCount, 1);
20-
assert.equal(result.command, 'SELECT');
21-
process.nextTick(pg.end.bind(pg));
17+
18+
client.query('SELECT * FROM zugzug', assert.calls(function(err, result) {
19+
assert.isNull(err);
20+
if(hasRowCount) assert.equal(result.rowCount, 1);
21+
assert.equal(result.command, 'SELECT');
22+
process.nextTick(pg.end.bind(pg));
23+
}));
2224
}));
23-
}));
2425

25-
assert.emits(q, 'end', function(result) {
26-
assert.equal(result.command, "INSERT");
27-
assert.equal(result.rowCount, 1);
28-
done();
29-
});
26+
assert.emits(q, 'end', function(result) {
27+
assert.equal(result.command, "INSERT");
28+
if(hasRowCount) assert.equal(result.rowCount, 1);
29+
done();
30+
});
3031

32+
}));
3133
}));
3234
}));
3335
});

0 commit comments

Comments
 (0)