Skip to content

Commit ad75c7c

Browse files
authoredNov 24, 2020
Merge pull request #166 from IanMcCurdy/bug258990
Fix missed error in ExecuteTask.run that could cause unexpected excep…
2 parents 39de76f + f7c5209 commit ad75c7c

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed
 

‎lib/protocol/ExecuteTask.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ ExecuteTask.prototype.run = function run(next) {
7171
return finalize();
7272
}
7373
self.sendExecute(function receive(err, reply) {
74-
self.pushReply(reply);
7574
if (err) {
7675
return finalize(err);
7776
}
77+
self.pushReply(reply);
7878
if (!self.writer.finished && reply.writeLobReply) {
7979
self.writer.update(reply.writeLobReply);
8080
}

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
],
77
"name": "hdb",
88
"description": "SAP HANA Database Client for Node",
9-
"version": "0.18.1",
9+
"version": "0.18.2",
1010
"repository": {
1111
"type": "git",
1212
"url": "git://github.com/SAP/node-hdb.git"

‎test/lib.ExecuteTask.js

+29-2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,30 @@ describe('Lib', function () {
7777
}).run(next);
7878
});
7979

80+
it('should raise an error correctly', function (next) {
81+
var task = createExecuteTask({
82+
parameters: {
83+
types: [TypeCode.INT],
84+
values: [
85+
[1],
86+
[2],
87+
[3]
88+
]
89+
},
90+
replies: [{
91+
type: MessageType.EXECUTE,
92+
args: [null, {
93+
rowsAffected: [1, 1, 1]
94+
}]
95+
}]
96+
}, function done(err) {
97+
err.should.be.an.instanceOf(Error);
98+
},
99+
false);
100+
task.writer._types = undefined;
101+
task.run(next);
102+
});
103+
80104
it('should run a batch task with INT type', function (next) {
81105
createExecuteTask({
82106
parameters: {
@@ -323,7 +347,7 @@ describe('Lib', function () {
323347
});
324348
});
325349

326-
function createExecuteTask(options, cb) {
350+
function createExecuteTask(options, cb, checkReplies) {
327351
options = util.extend({
328352
parameters: {
329353
types: [TypeCode.INT],
@@ -339,8 +363,11 @@ function createExecuteTask(options, cb) {
339363
var connection = new Connection(options.availableSize, options.replies);
340364
options.availableSize = undefined;
341365
options.replies = undefined;
366+
if (checkReplies === undefined) checkReplies = true;
342367
return ExecuteTask.create(connection, options, function () {
343-
connection.replies.should.have.length(0);
368+
if (checkReplies) {
369+
connection.replies.should.have.length(0);
370+
}
344371
cb.apply(null, arguments);
345372
});
346373
}

0 commit comments

Comments
 (0)
Please sign in to comment.