不要怂,就是干,撸起袖子干!

Commit c32ac014 by bparan Committed by Sushant

fix(mssql): save number bigger than 2147483647 as bigint (#11252)

1 parent d2f33830
......@@ -19,8 +19,12 @@ class Query extends AbstractQuery {
paramType.type = TYPES.NVarChar;
if (typeof value === 'number') {
if (Number.isInteger(value)) {
if (value >= -2147483648 && value <= 2147483647) {
paramType.type = TYPES.Int;
} else {
paramType.type = TYPES.BigInt;
}
} else {
paramType.type = TYPES.Numeric;
//Default to a reasonable numeric precision/scale pending more sophisticated logic
paramType.typeOptions = { precision: 30, scale: 15 };
......
......@@ -108,4 +108,28 @@ if (dialect.match(/^mssql/)) {
});
});
});
it('saves value bigger than 2147483647, #11245', function() {
const BigIntTable = this.sequelize.define('BigIntTable', {
business_id: {
type: Sequelize.BIGINT,
allowNull: false
}
}, {
freezeTableName: true
});
const bigIntValue = 2147483648;
return BigIntTable.sync({ force: true })
.then(() => {
return BigIntTable.create({
business_id: bigIntValue
});
})
.then(() => BigIntTable.findOne())
.then(record => {
expect(Number(record.business_id)).to.equals(bigIntValue);
});
});
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!