Merge pull request #35 from jakobrun/master

return rowCount on insert
This commit is contained in:
Brian C 2019-01-08 08:52:20 -06:00 committed by GitHub
commit 67b880a4bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -94,7 +94,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)
})
})