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
Decimal Type having precision loss when retrieving value from database #1675
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
@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:
npm install tedious-decimal
and add the following params to connection options
Activity
adityashFT commentedon Jan 9, 2025
Is there any update??
KAMAELUA commentedon Jan 15, 2025
@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
adityashFT commentedon Jan 21, 2025
@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
adityashFT commentedon Jan 21, 2025
The problem is that I'm using sequelize. and this is not an ideal way to fix the issue.
KAMAELUA commentedon Jan 22, 2025
@adityashFT I am using it with sequelize-typescript and it looks like you can use it the same way with sequelize: