added null terminator (c-string) to query

This commit is contained in:
brianc 2010-10-10 18:20:24 -05:00
parent f9b5c7b03e
commit e69b6faa82
2 changed files with 11 additions and 6 deletions

View File

@ -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;

View File

@ -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)');