Skip to content

Commit

Permalink
fix: don’t reassign callback, don’t call if it’s not a function
Browse files Browse the repository at this point in the history
Signed-off-by: Roger Wakeman <[email protected]>
  • Loading branch information
rgrwkmn committed Jan 21, 2019
1 parent 986b190 commit 8160337
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ var Base = Class.extend({

columnNameArray = valueArray;
valueArray = callback;
callback = arguments[3] ? arguments[3] : throw;
}
else {

Expand All @@ -363,7 +362,12 @@ var Base = Class.extend({
}

if (columnNameArray.length !== valueArray.length) {
return callback(new Error('The number of columns does not match the number of values.'));
var error = new Error('The number of columns does not match the number of values.');
if (typeof callback === 'function') {
return callback(error);
} else {
throw error;
}
}

var sql = util.format('INSERT INTO %s ', this.escapeDDL(tableName));
Expand Down

0 comments on commit 8160337

Please sign in to comment.