Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/bulk-load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,13 @@ class RowTransform extends Transform {
this.push(textPointerAndTimestampBuffer);
}

this.push(c.type.generateParameterLength(parameter, this.mainOptions));
for (const chunk of c.type.generateParameterData(parameter, this.mainOptions)) {
this.push(chunk);
try {
this.push(c.type.generateParameterLength(parameter, this.mainOptions));
for (const chunk of c.type.generateParameterData(parameter, this.mainOptions)) {
this.push(chunk);
}
} catch (error: any) {
return callback(error);
}
}

Expand Down
24 changes: 24 additions & 0 deletions test/integration/bulk-load-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1563,4 +1563,28 @@ describe('BulkLoad', function() {
}
});
});

it('should not throw in _transform function', (done) => {
const bulkLoad = connection.newBulkLoad(
'#tmpTestTable',
(err, rowCount) => {
assert.instanceOf(err, RangeError);
assert.strictEqual(/** @type {RangeError} */(err).message, 'The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received 3_.40_282_346_638_528_86e_+42');
assert.strictEqual(rowCount, 0);
done();
});

bulkLoad.addColumn('value', TYPES.Decimal, { precision: 7, scale: 4, nullable: true });

const request = new Request(bulkLoad.getTableCreationSql(), (err) => {
if (err) {
return done(err);
}

connection.execBulkLoad(bulkLoad, [[-3.4028234663852886e+38]]);
});

connection.execSqlBatch(request);

});
});