return rowCount on insert

This commit is contained in:
jakob 2018-01-01 18:43:18 +00:00
parent c0f5518341
commit 2398e992a8
2 changed files with 16 additions and 1 deletions

View File

@ -89,7 +89,8 @@ Cursor.prototype._sendRows = function () {
})
}
Cursor.prototype.handleCommandComplete = function () {
Cursor.prototype.handleCommandComplete = function (msg) {
this._result.addCommandComplete(msg)
this.connection.sync()
}

View File

@ -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)
})
})