From 8283fd9b22d8ab480b9e8c8b9d38cacbca223232 Mon Sep 17 00:00:00 2001 From: Stephen Sugden Date: Wed, 21 May 2014 22:44:51 +0200 Subject: [PATCH] add support for queries that don't return a row description --- index.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 5ea42cf1..2d8e088b 100644 --- a/index.js +++ b/index.js @@ -32,14 +32,28 @@ Cursor.prototype.submit = function(connection) { }, true) con.flush() + + con.once('noData', ifNoData) + con.once('rowDescription', function () { + con.removeListener('noData', ifNoData); + }); + + function ifNoData () { + self.state = 'idle' + self._shiftQueue(); + } +} + +Cursor.prototype._shiftQueue = function () { + if(this._queue.length) { + this._getRows.apply(this, this._queue.shift()) + } } Cursor.prototype.handleRowDescription = function(msg) { this._result.addFields(msg.fields) this.state = 'idle' - if(this._queue.length) { - this._getRows.apply(this, this._queue.shift()) - } + this._shiftQueue(); } Cursor.prototype.handleDataRow = function(msg) {