2011-01-19 14:35:32 +08:00
|
|
|
var helper = require(__dirname + "/test-helper");
|
|
|
|
var pg = helper.pg;
|
|
|
|
|
2011-05-20 08:19:58 +08:00
|
|
|
test('should return insert metadata', function() {
|
2013-03-08 05:57:00 +08:00
|
|
|
pg.connect(helper.config, assert.calls(function(err, client, done) {
|
2011-01-19 14:35:32 +08:00
|
|
|
assert.isNull(err);
|
2012-12-11 13:25:26 +08:00
|
|
|
|
2013-04-17 23:29:21 +08:00
|
|
|
helper.versionGTE(client, '9.0.0', assert.success(function(hasRowCount) {
|
|
|
|
client.query("CREATE TEMP TABLE zugzug(name varchar(10))", assert.calls(function(err, result) {
|
|
|
|
assert.isNull(err);
|
|
|
|
assert.equal(result.oid, null);
|
|
|
|
assert.equal(result.command, 'CREATE');
|
2012-12-11 13:25:26 +08:00
|
|
|
|
2013-04-17 23:29:21 +08:00
|
|
|
var q = client.query("INSERT INTO zugzug(name) VALUES('more work?')", assert.calls(function(err, result) {
|
|
|
|
assert.equal(result.command, "INSERT");
|
2012-05-31 12:38:03 +08:00
|
|
|
assert.equal(result.rowCount, 1);
|
2013-04-17 23:29:21 +08:00
|
|
|
|
|
|
|
client.query('SELECT * FROM zugzug', assert.calls(function(err, result) {
|
|
|
|
assert.isNull(err);
|
|
|
|
if(hasRowCount) assert.equal(result.rowCount, 1);
|
|
|
|
assert.equal(result.command, 'SELECT');
|
|
|
|
process.nextTick(pg.end.bind(pg));
|
|
|
|
}));
|
2012-12-11 13:25:26 +08:00
|
|
|
}));
|
|
|
|
|
2013-04-17 23:29:21 +08:00
|
|
|
assert.emits(q, 'end', function(result) {
|
|
|
|
assert.equal(result.command, "INSERT");
|
|
|
|
if(hasRowCount) assert.equal(result.rowCount, 1);
|
|
|
|
done();
|
|
|
|
});
|
2012-12-11 13:25:26 +08:00
|
|
|
|
2013-04-17 23:29:21 +08:00
|
|
|
}));
|
2012-12-11 13:25:26 +08:00
|
|
|
}));
|
|
|
|
}));
|
|
|
|
});
|