-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decimal Type having precision loss when retrieving value from database #1675
Comments
Is there any update?? |
@adityashFT they have this issue since 2014 (#163). The easiest way is to fork this repo and fix that problem by yourself (as I do). You can try to use my fork if you want:
and add the following params to connection options
|
@KAMAELUA , Yea its true.. and many library depend on the driver code. Hope that the team takes quick action to fix this long running issue |
The problem is that I'm using sequelize. and this is not an ideal way to fix the issue. |
@adityashFT I am using it with sequelize-typescript and it looks like you can use it the same way with sequelize: import {Sequelize} from "sequelize-typescript";
import * as tedious from "tedious-decimal";
const dialectModule = tedious;
const sequelize = new Sequelize({
dialect: 'mssql',
dialectModule,
dialectOptions: {
options: {
returnDecimalAndNumericAsString: true,
decimalStringTrimTrailingZero: true,
},
}
}); |
Software versions
Additional Libraries Used and Versions
Sequelize: 6.37.5
Problem description
In our Database Table, we have a column of type Decimal(38,20). When saving the value 500, the record in the table is correct, however the data that is returned by is 499.99999999999994
When investigating, I have come across this Issue (#678), which was raised 7 years ago. However, there seems to be no progress in addressing the issue, our team relays in the column being of type decimal, but the value returned by tedious is incorrect, which are causing issues in the program.
Requesting a quick fix on this issue or a temporary workaround to fix the decimal precision issue. One way is to change the column type to varchar, which is not a solution we prefer.
Expected behavior
Value returned should be exactly 500
Actual behavior
Value returned should be exactly 499.99999999999994
Any other details that can be helpful
According to my analysis
tedious/src/value-parser.ts
Line 442 in ebb023e
The text was updated successfully, but these errors were encountered: