2010-10-24 05:21:11 +08:00
|
|
|
var helper = require(__dirname + '/test-helper');
|
2014-04-17 01:01:57 +08:00
|
|
|
//http://developer.postgresql.org/pgdocs/postgres/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY
|
2010-10-24 05:21:11 +08:00
|
|
|
|
2010-10-24 11:07:00 +08:00
|
|
|
test('flushing once', function() {
|
|
|
|
helper.connect(function(con) {
|
|
|
|
con.parse({
|
|
|
|
text: 'select * from ids'
|
|
|
|
});
|
2010-10-26 10:43:55 +08:00
|
|
|
|
2010-10-24 05:21:11 +08:00
|
|
|
con.bind();
|
2010-10-24 11:07:00 +08:00
|
|
|
con.execute();
|
2010-10-24 05:21:11 +08:00
|
|
|
con.flush();
|
2010-10-26 10:43:55 +08:00
|
|
|
|
2010-11-01 03:43:10 +08:00
|
|
|
assert.emits(con, 'parseComplete');
|
|
|
|
assert.emits(con, 'bindComplete');
|
|
|
|
assert.emits(con, 'dataRow');
|
|
|
|
assert.emits(con, 'commandComplete', function(){
|
2010-10-24 11:07:00 +08:00
|
|
|
con.sync();
|
|
|
|
});
|
2010-11-01 03:43:10 +08:00
|
|
|
assert.emits(con, 'readyForQuery', function(){
|
2010-10-24 11:07:00 +08:00
|
|
|
con.end();
|
|
|
|
});
|
2010-10-26 10:43:55 +08:00
|
|
|
|
2010-10-24 05:21:11 +08:00
|
|
|
});
|
2010-10-24 11:07:00 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
test("sending many flushes", function() {
|
|
|
|
helper.connect(function(con) {
|
|
|
|
|
2010-11-01 03:43:10 +08:00
|
|
|
assert.emits(con, 'parseComplete', function(){
|
2010-10-24 11:07:00 +08:00
|
|
|
con.bind();
|
|
|
|
con.flush();
|
|
|
|
});
|
2010-10-24 05:21:11 +08:00
|
|
|
|
2010-11-01 03:43:10 +08:00
|
|
|
assert.emits(con, 'bindComplete', function(){
|
2010-10-24 11:07:00 +08:00
|
|
|
con.execute();
|
|
|
|
con.flush();
|
|
|
|
});
|
2010-10-24 09:26:24 +08:00
|
|
|
|
2010-11-01 03:43:10 +08:00
|
|
|
assert.emits(con, 'dataRow', function(msg){
|
2010-10-26 10:43:55 +08:00
|
|
|
assert.equal(msg.fields[0], 1);
|
2010-11-01 03:43:10 +08:00
|
|
|
assert.emits(con, 'dataRow', function(msg){
|
2010-10-26 10:43:55 +08:00
|
|
|
assert.equal(msg.fields[0], 2);
|
2010-11-01 03:43:10 +08:00
|
|
|
assert.emits(con, 'commandComplete', function(){
|
2010-10-26 10:43:55 +08:00
|
|
|
con.sync();
|
|
|
|
});
|
2010-11-01 03:43:10 +08:00
|
|
|
assert.emits(con, 'readyForQuery', function(){
|
2010-10-26 10:43:55 +08:00
|
|
|
con.end();
|
|
|
|
});
|
|
|
|
});
|
2010-10-24 11:07:00 +08:00
|
|
|
});
|
2010-10-24 05:21:11 +08:00
|
|
|
|
2010-10-26 10:43:55 +08:00
|
|
|
con.parse({
|
|
|
|
text: "select * from ids order by id"
|
2010-10-24 11:07:00 +08:00
|
|
|
});
|
2010-10-24 05:21:11 +08:00
|
|
|
|
2010-10-26 10:43:55 +08:00
|
|
|
con.flush();
|
|
|
|
|
2010-10-24 11:07:00 +08:00
|
|
|
});
|
|
|
|
});
|