You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BigInt as Parameter works, but does this look right? #490
CREATE TABLE dbo.BigIntInNodeTest (
Id BIGINT NOT NULL,
IsAtMax BIT NOT NULL,
CONSTRAINT PK_BigIntInNodeTest_Id PRIMARY KEY(Id));
GO
Then, use this script:
var Connection = require('tedious').Connection;
var Request = require('tedious').Request;
var TYPES = require('tedious').TYPES;
var config = require('./sqlConfig');
var connection = new Connection(config);
var commandBigInt = new Request('dbo.InsertBigInt', function onRequest() {
connection.close();
});
@beautifulcoder Got around to checking this out. This is essentially a JavaScript Numeric range limitation. You lose precision outside the range -(253 - 1) and (253 - 1). Using VarChar for values outside this range is the right behavior.
Activity
tvrprasad commentedon Jan 10, 2017
Can you please put together a complete script? I can take a look. Thanks.
beautifulcoder commentedon Jan 10, 2017
You bet.
Create a basic table with a BitInt.
CREATE DATABASE FunWithBigIntInNode;
GO
USE FunWithBigIntInNode;
GO
CREATE TABLE dbo.BigIntInNodeTest (
Id BIGINT NOT NULL,
IsAtMax BIT NOT NULL,
CONSTRAINT PK_BigIntInNodeTest_Id PRIMARY KEY(Id));
GO
Then, use this script:
var Connection = require('tedious').Connection;
var Request = require('tedious').Request;
var TYPES = require('tedious').TYPES;
var config = require('./sqlConfig');
var connection = new Connection(config);
var commandBigInt = new Request('dbo.InsertBigInt', function onRequest() {
connection.close();
});
commandBigInt.addParameter('Id', TYPES.BigInt, '9223372036854775807');
commandBigInt.addParameter('IsAtMax', TYPES.Bit, true);
connection.on('connect', function onConnect() {
connection.callProcedure(commandBigInt);
});
sqlConfig is a JSON key / value pair file, as such:
{
"userName": "",
"password": "",
"server": "",
"options": {
"database": "FunWithBigIntInNode",
"encrypt": true
}
}
tvrprasad commentedon Feb 15, 2017
@beautifulcoder Got around to checking this out. This is essentially a JavaScript Numeric range limitation. You lose precision outside the range -(253 - 1) and (253 - 1). Using VarChar for values outside this range is the right behavior.
I sent a PR to validate range on BigInt - #504.
tvrprasad commentedon Feb 21, 2017
@beautifulcoder This change is now merged. Happy coding :-)