diff --git a/lib/index.js b/lib/index.js index 54b56056..0f950dd4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -105,7 +105,7 @@ var Query = function() { sys.inherits(Query, EventEmitter); Query.prototype.toBuffer = function() { - var textBuffer = new Buffer(this.text,'utf8'); + var textBuffer = new Buffer(this.text+'\0','utf8'); var len = textBuffer.length + 4; var fullBuffer = new Buffer(len + 1); fullBuffer[0] = 0x51; diff --git a/test/api-tests.js b/test/api-tests.js index 1238098d..f6f564fb 100644 --- a/test/api-tests.js +++ b/test/api-tests.js @@ -3,10 +3,14 @@ require(__dirname+"/test-helper"); //little helper to make a //fresh client to the test DB var makeClient = function() { - return new Client({ + var client = new Client({ user: 'brian', database: 'pgjstest' }); + client.on('Error', function(msg) { + console.log(msg); + }); + return client; }; var client1 = makeClient(); @@ -27,12 +31,13 @@ var client3 = makeClient(); client3.connect(); client3.on('ReadyForQuery', function() { console.log('client3 ready for query'); - var query = client3.query('create temporary table bang (id integer)'); - query.on('end', function() { - client3.disconnect(); - }); }); +var query = client3.query('create temporary table bang (id integer)'); +query.on('end', function() { + client3.disconnect(); +}); + // client.query('create temporary table bang (id integer)'); // client.query('insert into bang(id) VALUES(1)');