mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Do not callback with final empty array until readyForQuery is received
Closes https://github.com/brianc/node-pg-query-stream/issues/3
This commit is contained in:
parent
b1b39bbd4f
commit
1a9fd7ff76
13
index.js
13
index.js
@ -50,14 +50,19 @@ Cursor.prototype.handleDataRow = function(msg) {
|
||||
Cursor.prototype._sendRows = function() {
|
||||
this.state = 'idle'
|
||||
setImmediate(function() {
|
||||
this._cb(null, this._rows)
|
||||
var cb = this._cb
|
||||
//remove callback before calling it
|
||||
//because likely a new one will be added
|
||||
//within the call to this callback
|
||||
this._cb = null
|
||||
if(cb) {
|
||||
cb(null, this._rows)
|
||||
}
|
||||
this._rows = []
|
||||
}.bind(this))
|
||||
}
|
||||
|
||||
Cursor.prototype.handleCommandComplete = function() {
|
||||
this._sendRows()
|
||||
this.state = 'done'
|
||||
this.connection.sync()
|
||||
}
|
||||
|
||||
@ -66,6 +71,8 @@ Cursor.prototype.handlePortalSuspended = function() {
|
||||
}
|
||||
|
||||
Cursor.prototype.handleReadyForQuery = function() {
|
||||
this._sendRows()
|
||||
this.state = 'done'
|
||||
}
|
||||
|
||||
Cursor.prototype.handleError = function(msg) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user