Verify the executeMany() iterations value is a positive integer

This commit is contained in:
Christopher Jones 2018-08-22 13:26:42 +10:00
parent eb23809825
commit 79ad097ce8
2 changed files with 17 additions and 10 deletions

View File

@ -196,8 +196,12 @@ function executeMany(sql, bindsOrNumIters, a3, a4) {
nodbUtil.assert(arguments.length > 2 && arguments.length < 5, 'NJS-009');
nodbUtil.assert(typeof sql === 'string', 'NJS-006', 1);
if (typeof bindsOrNumIters !== 'number')
if (typeof bindsOrNumIters === 'number') {
nodbUtil.assert(Number.isInteger(bindsOrNumIters) && bindsOrNumIters > 0,
'NJS-005', 2);
} else {
nodbUtil.assert(Array.isArray(bindsOrNumIters), 'NJS-006', 2);
}
switch (arguments.length) {
case 3:

View File

@ -650,12 +650,12 @@ describe('163. executeMany.js', function() {
], done);
}); // 164.14
it.skip('164.15 Negative - set numIterations to be negative value', function(done) {
it('164.15 Negative - set numIterations to be negative value', function(done) {
async.series([
function(cb) {
var sql = `
declare
t_Id number;
t_Id number;
begin
select nvl(count(*), 0) + 1 into t_Id
from nodb_tab_xmany;
@ -666,14 +666,17 @@ describe('163. executeMany.js', function() {
var numIterations = -8;
conn.executeMany(
sql,
numIterations,
function(err) {
should.not.exist(err);
cb();
}
should.throws(
function() {
conn.executeMany(
sql,
numIterations,
function() { }
);
},
/NJS-005: invalid value for parameter 2/
);
cb();
},
function(cb) {
dotruncate(cb);