Skip to content

Commit

Permalink
Merge pull request #166 from IanMcCurdy/bug258990
Browse files Browse the repository at this point in the history
Fix missed error in ExecuteTask.run that could cause unexpected excep…
  • Loading branch information
jeffalbion authored Nov 24, 2020
2 parents 39de76f + f7c5209 commit ad75c7c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"name": "hdb",
"description": "SAP HANA Database Client for Node",
"version": "0.18.1",
"version": "0.18.2",
"repository": {
"type": "git",
"url": "git://github.com/SAP/node-hdb.git"
Expand Down
31 changes: 29 additions & 2 deletions test/lib.ExecuteTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@ describe('Lib', function () {
}).run(next);
});

it('should raise an error correctly', function (next) {
var task = createExecuteTask({
parameters: {
types: [TypeCode.INT],
values: [
[1],
[2],
[3]
]
},
replies: [{
type: MessageType.EXECUTE,
args: [null, {
rowsAffected: [1, 1, 1]
}]
}]
}, function done(err) {
err.should.be.an.instanceOf(Error);
},
false);
task.writer._types = undefined;
task.run(next);
});

it('should run a batch task with INT type', function (next) {
createExecuteTask({
parameters: {
Expand Down Expand Up @@ -323,7 +347,7 @@ describe('Lib', function () {
});
});

function createExecuteTask(options, cb) {
function createExecuteTask(options, cb, checkReplies) {
options = util.extend({
parameters: {
types: [TypeCode.INT],
Expand All @@ -339,8 +363,11 @@ function createExecuteTask(options, cb) {
var connection = new Connection(options.availableSize, options.replies);
options.availableSize = undefined;
options.replies = undefined;
if (checkReplies === undefined) checkReplies = true;
return ExecuteTask.create(connection, options, function () {
connection.replies.should.have.length(0);
if (checkReplies) {
connection.replies.should.have.length(0);
}
cb.apply(null, arguments);
});
}
Expand Down

0 comments on commit ad75c7c

Please sign in to comment.