mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Fix query error emit on native bindings
This commit is contained in:
parent
6d64abc0e2
commit
bd74d48791
@ -27,6 +27,7 @@ var NativeQuery = function(config, values, callback) {
|
||||
|
||||
this._result = new Result(config.rowMode);
|
||||
this._addedFields = false;
|
||||
this._hadError = false;
|
||||
//normalize values
|
||||
if(this.values) {
|
||||
for(var i = 0, len = this.values.length; i < len; i++) {
|
||||
@ -55,6 +56,7 @@ NativeQuery.prototype.handleError = function(error) {
|
||||
error = this._canceledDueToError;
|
||||
this._canceledDueToError = false;
|
||||
}
|
||||
this._hadError = true;
|
||||
if(this.callback) {
|
||||
var cb = this.callback;
|
||||
//remove callback to prevent double call on readyForQuery
|
||||
@ -66,6 +68,7 @@ NativeQuery.prototype.handleError = function(error) {
|
||||
};
|
||||
|
||||
NativeQuery.prototype.handleReadyForQuery = function(meta) {
|
||||
if(this._hadError) return;
|
||||
if (this._canceledDueToError) {
|
||||
return this.handleError(this._canceledDueToError);
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ test('error during query execution', function() {
|
||||
//because it was killed and received an error
|
||||
//https://github.com/brianc/node-postgres/issues/547
|
||||
query1.on('end', function() {
|
||||
assert.fail('Client with an error should not emit "end" event')
|
||||
assert.fail('Query with an error should not emit "end" event')
|
||||
})
|
||||
var client2 = new Client(helper.args);
|
||||
client2.connect(assert.success(function() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user