Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/protocol/ExecuteTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ ExecuteTask.prototype.run = function run(next) {
return finalize();
}
self.sendExecute(function receive(err, reply) {
self.pushReply(reply);
if (err) {
return finalize(err);
}
self.pushReply(reply);
if (!self.writer.finished && reply.writeLobReply) {
self.writer.update(reply.writeLobReply);
}
Expand Down
29 changes: 14 additions & 15 deletions lib/protocol/Result.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,42 +76,41 @@ Result.prototype.getLobColumnNames = function getLobColumnNames() {
};

Result.prototype.handle = function handle(err, reply, cb) {
if (err) {
return cb(err);
}
var reply = reply || {};

switch (reply.functionCode) {
case FunctionCode.SELECT:
case FunctionCode.SELECT_FOR_UPDATE:
this.handleQuery(cb, this.createResultSets(reply.resultSets));
this.handleQuery(cb, err, this.createResultSets(reply.resultSets));
return;
case FunctionCode.INSERT:
case FunctionCode.UPDATE:
case FunctionCode.DELETE:
this.handleModify(cb, reply.rowsAffected);
this.handleModify(cb, err, reply.rowsAffected);
return;
case FunctionCode.NIL:
case FunctionCode.DDL:
case FunctionCode.CONNECT:
cb(null);
cb(err);
return;
case FunctionCode.DB_PROCEDURE_CALL:
case FunctionCode.DB_PROCEDURE_CALL_WITH_RESULT:
this.handleDBCall(cb,
err,
this.createOutputParameters(reply.outputParameters),
this.createResultSets(reply.resultSets));
return;
default:
err = new Error('Invalid or unsupported FunctionCode');
err = err || new Error('Invalid or unsupported FunctionCode');
cb(err);
}
};

Result.prototype.handleModify = function handleModify(cb, rowsAffected) {
cb(null, rowsAffected);
Result.prototype.handleModify = function handleModify(cb, err, rowsAffected) {
cb(err, rowsAffected);
};

Result.prototype.handleQuery = function handleQuery(cb, resultSets) {
Result.prototype.handleQuery = function handleQuery(cb, err, resultSets) {
function done(err, results) {
if (err) {
return cb(err);
Expand All @@ -121,13 +120,13 @@ Result.prototype.handleQuery = function handleQuery(cb, resultSets) {
return cb.apply(null, args);
}

if (!this.autoFetch) {
return done(null, resultSets);
if (!this.autoFetch || err) {
return done(err, resultSets);
}
fetchAll(resultSets, done);
};

Result.prototype.handleDBCall = function handleDBCall(cb, params, resultSets) {
Result.prototype.handleDBCall = function handleDBCall(cb, err, params, resultSets) {
params = params || {};

function done(err, results) {
Expand All @@ -139,8 +138,8 @@ Result.prototype.handleDBCall = function handleDBCall(cb, params, resultSets) {
return cb.apply(null, args);
}

if (!this.autoFetch) {
return done(null, resultSets);
if (!this.autoFetch || err) {
return done(err, resultSets);
}

function fetchResults(err) {
Expand Down
12 changes: 6 additions & 6 deletions test/lib.Result.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ describe('Lib', function () {
params.should.equal(_params);
rs.should.equal(resultSet);
done();
}, _params, [resultSet]);
}, null, _params, [resultSet]);
});

it('should handle a db procedure call with lob instance',
Expand All @@ -215,7 +215,7 @@ describe('Lib', function () {
params.Z.should.equal(_buffer);
rows.should.eql(_rows);
done();
}, _params, [resultSet]);
}, null, _params, [resultSet]);
});

it('should handle a db procedure call with lob buffer',
Expand All @@ -242,7 +242,7 @@ describe('Lib', function () {
params.Z.should.equal(_buffer);
rows.should.eql(_rows);
done();
}, _params, [resultSet]);
}, null, _params, [resultSet]);
});


Expand All @@ -268,7 +268,7 @@ describe('Lib', function () {
function (err) {
err.should.equal(_err);
done();
}, _params, [resultSet]);
}, null, _params, [resultSet]);
});

it('should handle a db procedure call with error',
Expand All @@ -281,7 +281,7 @@ describe('Lib', function () {
result.handleDBCall(function (err) {
err.should.equal(_err);
done();
}, {}, [resultSet]);
}, null, {}, [resultSet]);
});


Expand All @@ -295,7 +295,7 @@ describe('Lib', function () {
result.handleQuery(function (err) {
err.should.equal(_err);
done();
}, [resultSet]);
}, null, [resultSet]);
});
});
});