Skip to content

Commit 2398e99

Browse files
committed
return rowCount on insert
1 parent c0f5518 commit 2398e99

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ Cursor.prototype._sendRows = function () {
8989
})
9090
}
9191

92-
Cursor.prototype.handleCommandComplete = function () {
92+
Cursor.prototype.handleCommandComplete = function (msg) {
93+
this._result.addCommandComplete(msg)
9394
this.connection.sync()
9495
}
9596

test/index.js

+14
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,18 @@ describe('cursor', function () {
160160
done()
161161
})
162162
})
163+
164+
it('returns rowCount on insert', function (done) {
165+
var pgCursor = this.pgCursor
166+
this.client.query('CREATE TEMPORARY TABLE pg_cursor_test (foo VARCHAR(1), bar VARCHAR(1))')
167+
.then(function () {
168+
var cursor = pgCursor('insert into pg_cursor_test values($1, $2)', ['a', 'b'])
169+
cursor.read(1, function (err, rows, result) {
170+
assert.ifError(err)
171+
assert.equal(rows.length, 0)
172+
assert.equal(result.rowCount, 1)
173+
done()
174+
})
175+
}).catch(done)
176+
})
163177
})

0 commit comments

Comments
 (0)