Out of bounds error on negative numeric/decimal input parameter #147

Closed
kenleese opened this Issue Apr 16, 2014 · 1 comment

Comments

Projects
None yet
2 participants

Using SQL Server 2014 Express:

CREATE TABLE test_db.t11s.Test
(
[id] INT NOT NULL,
latitude NUMERIC(8,5),
longitude NUMERIC(8,5),
PRIMARY KEY NONCLUSTERED ([id] ASC)
);

Using node.js 10.23, tedious 0.2.2:

var Connection = require('tedious').Connection,
Request = require('tedious').Request,
TYPES = require('tedious').TYPES;

var connection = new Connection({
server: 'localhost',
userName: 'sa',
password: 'xxxx',
database: 'test_db'
});

connection.on('connect', function (err) {
var request = new Request("INSERT INTO t11s.Test VALUES (@p0,@p1,@p2);",
function (err) {
if (err) {
console.log(err);
}
});

request.addParameter('p0', TYPES.Int, 118583);
request.addParameter('p1', TYPES.Numeric, 36.13636);
request.addParameter('p2', TYPES.Numeric, -115.16225);

connection.execSql(request);
});

buffer.js:784
throw TypeError('value is out of bounds');
^
TypeError: value is out of bounds
at TypeError ()
at checkInt (buffer.js:784:11)
at Buffer.writeUInt32LE (buffer.js:841:5)
at WritableTrackingBuffer.writeUInt32LE (D:\Trippo\tedious\node_modules\tedious\lib\tracking-buffer\writable-tracking-buffer.js:92:17)
at WritableTrackingBuffer.writeUInt64LE (D:\Trippo\tedious\node_modules\tedious\lib\tracking-buffer\writable-tracking-buffer.js:119:17)
at Object.TYPE.writeParameterData (D:\Trippo\tedious\node_modules\tedious\lib\data-type.js:336:25)
at new RpcRequestPayload (D:\Trippo\tedious\node_modules\tedious\lib\rpcrequest-payload.js:66:22)
at Connection.execSql (D:\Trippo\tedious\node_modules\tedious\lib\connection.js:712:56)
at Connection. (D:\Trippo\tedious\index.js:25:14)
at Connection.EventEmitter.emit (events.js:92:17)

Collaborator

patriksimek commented Apr 16, 2014

Thanks for report, fixed in 0.2.3.

@kenleese kenleese changed the title from Parameterized INSERT throws TypeError('value is out of bounds') to Out of bounds error on negative numeric/decimal input parameter Apr 16, 2014

@patriksimek patriksimek referenced this issue in patriksimek/node-mssql Apr 16, 2014

Closed

throw TypeError('value is out of bounds'); #31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment