writes simple query

This commit is contained in:
brianc 2010-10-08 23:17:09 -05:00
parent d0a98ce129
commit d20e47f644
2 changed files with 4 additions and 3 deletions

View File

@ -92,8 +92,8 @@ sys.inherits(Query, EventEmitter);
Query.prototype.toBuffer = function() {
var textBuffer = new Buffer(this.text,'utf8');
var len = textBuffer.length;
var fullBuffer = new Buffer(textBuffer.length + 5);
var len = textBuffer.length + 4;
var fullBuffer = new Buffer(len + 1);
fullBuffer[0] = 0x51;
fullBuffer[1] = len >>> 24;
fullBuffer[2] = len >>> 16;

View File

@ -63,7 +63,7 @@ test('query queue', function() {
});
test('calling query queues the query object', function() {
var query = client.query('select * from bang');
var query = client.query('!');
assert.length(client.queryQueue, 1);
});
@ -72,6 +72,7 @@ test('query queue', function() {
var handled = stream.emit('data', buffers.readyForQuery());
assert.ok(handled, "Stream should have had data handled");
assert.length(stream.packets, 1);
assert.equalBuffers(stream.packets[0], [0x51,0,0,0,5,33])
});
});