diff --git a/index.js b/index.js index 8d8a06ab..1984e468 100644 --- a/index.js +++ b/index.js @@ -94,7 +94,8 @@ Cursor.prototype._sendRows = function () { }) } -Cursor.prototype.handleCommandComplete = function () { +Cursor.prototype.handleCommandComplete = function (msg) { + this._result.addCommandComplete(msg) this.connection.sync() } diff --git a/test/index.js b/test/index.js index a5b3636f..31a676e9 100644 --- a/test/index.js +++ b/test/index.js @@ -160,4 +160,18 @@ describe('cursor', function () { done() }) }) + + it('returns rowCount on insert', function (done) { + var pgCursor = this.pgCursor + this.client.query('CREATE TEMPORARY TABLE pg_cursor_test (foo VARCHAR(1), bar VARCHAR(1))') + .then(function () { + var cursor = pgCursor('insert into pg_cursor_test values($1, $2)', ['a', 'b']) + cursor.read(1, function (err, rows, result) { + assert.ifError(err) + assert.equal(rows.length, 0) + assert.equal(result.rowCount, 1) + done() + }) + }).catch(done) + }) })