Closed
Description
When doing a simple select-query on a column with a large decimal (e.g. 1234567891011.1213141), everything above 17 digits is cut (most likely the javascript limit here).
The only solution that I see is to return the content as a string instead of a number. - That way the user can decide for themselves if they wish to use some js-library for big numbers.
Here is some code to reproduce:
const config = require("../utils/config-loader").config; // just db-credentials
const mssql = require("mssql/msnodesqlv8");
async function run() {
await mssql.connect(config.mssqlConnectionString);
const sqlQuery = `
CREATE TABLE [dbo].[TestLargeDecimal] (
id VARCHAR(12) NOT NULL,
testfield DECIMAL(21,7) NOT NULL,
PRIMARY KEY (id)
);`;
await mssql.query(sqlQuery);
await mssql.query(`INSERT INTO [dbo].[TestLargeDecimal] (id, testfield) VALUES (1, 1234567891011.1213141);`);
const result = await mssql.query(`SELECT * FROM [dbo].[TestLargeDecimal]`);
console.log(result);
// --> testfield is missing the last 3 digits and only returns "1234567891011.1213"
// --> the database contains the correct value
// --> it doesn't actually matter where the decimal-point is, it's probably simply the javascript max-number-length
// optional cleanup
// await mssql.query(`DROP TABLE [dbo].[TestLargeDecimal];`);
await mssql.close();
}
run();
If it is in the C-Code, I can probably not help much here, if it's in the Javascript, you can point me to the right direction and I can possibly find a bugfix.
Metadata
Metadata
Assignees
Labels
No labels