Skip to content

Commit 79ad097

Browse files
committed
Verify the executeMany() iterations value is a positive integer
1 parent eb23809 commit 79ad097

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

lib/connection.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,12 @@ function executeMany(sql, bindsOrNumIters, a3, a4) {
196196

197197
nodbUtil.assert(arguments.length > 2 && arguments.length < 5, 'NJS-009');
198198
nodbUtil.assert(typeof sql === 'string', 'NJS-006', 1);
199-
if (typeof bindsOrNumIters !== 'number')
199+
if (typeof bindsOrNumIters === 'number') {
200+
nodbUtil.assert(Number.isInteger(bindsOrNumIters) && bindsOrNumIters > 0,
201+
'NJS-005', 2);
202+
} else {
200203
nodbUtil.assert(Array.isArray(bindsOrNumIters), 'NJS-006', 2);
204+
}
201205

202206
switch (arguments.length) {
203207
case 3:

test/executeMany.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -650,12 +650,12 @@ describe('163. executeMany.js', function() {
650650
], done);
651651
}); // 164.14
652652

653-
it.skip('164.15 Negative - set numIterations to be negative value', function(done) {
653+
it('164.15 Negative - set numIterations to be negative value', function(done) {
654654
async.series([
655655
function(cb) {
656656
var sql = `
657657
declare
658-
t_Id number;
658+
t_Id number;
659659
begin
660660
select nvl(count(*), 0) + 1 into t_Id
661661
from nodb_tab_xmany;
@@ -666,14 +666,17 @@ describe('163. executeMany.js', function() {
666666

667667
var numIterations = -8;
668668

669-
conn.executeMany(
670-
sql,
671-
numIterations,
672-
function(err) {
673-
should.not.exist(err);
674-
cb();
675-
}
669+
should.throws(
670+
function() {
671+
conn.executeMany(
672+
sql,
673+
numIterations,
674+
function() { }
675+
);
676+
},
677+
/NJS-005: invalid value for parameter 2/
676678
);
679+
cb();
677680
},
678681
function(cb) {
679682
dotruncate(cb);

0 commit comments

Comments
 (0)