From 2398e992a8e6e8e437f74637b8a38f74cad0291e Mon Sep 17 00:00:00 2001 From: jakob Date: Mon, 1 Jan 2018 18:43:18 +0000 Subject: [PATCH] return rowCount on insert --- index.js | 3 ++- test/index.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 2c33a230..f76c7d92 100644 --- a/index.js +++ b/index.js @@ -89,7 +89,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) + }) })