mirror of
https://github.com/brianc/node-postgres.git
synced 2026-02-01 16:47:23 +00:00
modified callback nesting to ensure test is called after all setup is complete
This commit is contained in:
parent
3edb02aa67
commit
a5fba7515e
@ -2,6 +2,9 @@ var helper = require(__dirname + '/test-helper');
|
|||||||
http://developer.postgresql.org/pgdocs/postgres/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY
|
http://developer.postgresql.org/pgdocs/postgres/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY
|
||||||
|
|
||||||
helper.connect(function(con) {
|
helper.connect(function(con) {
|
||||||
|
con.on('message', function(msg) {
|
||||||
|
console.log(msg.name);
|
||||||
|
});
|
||||||
|
|
||||||
con.parse({
|
con.parse({
|
||||||
text: 'select * from ids'
|
text: 'select * from ids'
|
||||||
@ -9,26 +12,24 @@ helper.connect(function(con) {
|
|||||||
con.flush();
|
con.flush();
|
||||||
|
|
||||||
con.once('parseComplete', function() {
|
con.once('parseComplete', function() {
|
||||||
console.log('parseComplete');
|
|
||||||
con.bind();
|
con.bind();
|
||||||
con.flush();
|
con.flush();
|
||||||
});
|
});
|
||||||
|
|
||||||
con.once('bindComplete', function() {
|
con.once('bindComplete', function() {
|
||||||
console.log('bindComplete');
|
|
||||||
con.execute();
|
con.execute();
|
||||||
con.flush();
|
con.flush();
|
||||||
});
|
});
|
||||||
|
|
||||||
con.on('dataRow', function(msg) {
|
con.once('dataRow', function(msg) {
|
||||||
sys.debug("got row from pepared query");
|
console.log("row: " + sys.inspect(msg));
|
||||||
});
|
});
|
||||||
|
|
||||||
con.on('commandComplete', function() {
|
con.once('commandComplete', function() {
|
||||||
con.sync();
|
con.sync();
|
||||||
});
|
});
|
||||||
|
|
||||||
con.on('readyForQuery', function() {
|
con.once('readyForQuery', function() {
|
||||||
con.end();
|
con.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -22,14 +22,13 @@ var connect = function(callback) {
|
|||||||
authConnect(function(con) {
|
authConnect(function(con) {
|
||||||
con.once('readyForQuery', function() {
|
con.once('readyForQuery', function() {
|
||||||
con.query('create temp table ids(id integer)');
|
con.query('create temp table ids(id integer)');
|
||||||
|
con.once('readyForQuery', function() {
|
||||||
|
con.query('insert into ids(id) values(1); insert into ids(id) values(2);');
|
||||||
|
con.once('readyForQuery', function() {
|
||||||
|
callback(con);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
con.once('readyForQuery', function() {
|
|
||||||
con.query('insert into ids(id) values(1); insert into ids(id) values(2);');
|
|
||||||
});
|
|
||||||
con.once('readyForQuery', function() {
|
|
||||||
callback(con);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user