diff --git a/lib/index.js b/lib/index.js index bb79832..839c84a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -3,7 +3,7 @@ var sys = require('sys'); var net = require('net'); var NUL = '\0'; -var chars = Buffer('RSKZQCT','utf8'); +var chars = Buffer('RSKZQCTD','utf8'); var UTF8 = { R: chars[0], S: chars[1], @@ -11,7 +11,8 @@ var UTF8 = { Z: chars[3], Q: chars[4], C: chars[5], - T: chars[6] + T: chars[6], + D: chars[7] }; @@ -128,6 +129,8 @@ p.parseMessage = function() { return this.parseC(); case UTF8.T: return this.parseT(); + case UTF8.D: + return this.parseD(); default: throw new Error("Unsupported message ID: " + Buffer([messageID]).toString('utf8') + " (" + messageID.toString(16) + ")"); } @@ -210,6 +213,11 @@ p.parseField = function() { return row; }; +p.parseD = function() { + var msg = this.parseStart('DataRow'); + msg.fieldCount = this.readInt16(); +}; + p.readInt32 = function() { var buffer = this.buffer; return ((buffer[this.offset++] << 24) + diff --git a/test/parser-tests.js b/test/parser-tests.js index 65b4f3b..d04f0ff 100644 --- a/test/parser-tests.js +++ b/test/parser-tests.js @@ -178,14 +178,15 @@ test('Parser on single messages', function() { }); -// test('parses raw data row buffers', function() { -// var emptyRow = new BufferList() -// .addInt16(0) -// .join(true, 'D'); -// test('parses empty data row', function() { -// var result = PARSE(emptyRow)[0]; -// }); -// }); + test('parses raw data row buffers', function() { + var emptyRow = new BufferList() + .addInt16(0) + .join(true, 'D'); + test('parses empty data row', function() { + var result = PARSE(emptyRow)[0]; + assert.equal(result.columnCount, 0); + }); + }); test('parsing empty buffer returns false', function() {