question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sequelize sum function always rounding to 4 decimal point

See original GitHub issue

Issue Description

like the title. I’m using DataTypes.DECIMAL(36, 18), as the dataType

What was unclear/insufficient/not covered in the documentation

I could find any documentation why sum function always rounding to 4 decimal point.

If possible: Provide some suggestion on how we can enhance the docs

Additional context

Add any other context or screenshots about the issue here.

Issue Template Checklist

Is this issue dialect-specific?

  • I don’t know.

Would you be willing to resolve this issue by submitting a Pull Request?

  • No, I don’t have the time and I wouldn’t even know how to start.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
Ms1709commented, May 31, 2020

You can use like this [sequelize.fn(‘ROUND’, sequelize.fn(‘SUM’, sequelize.col(‘col’)),2), ‘col’] col: is table column name 2: after decimal how much precision you need

0reactions
WikiRikcommented, Nov 22, 2021

Allowing Sequelize to see the dataType of the column and using that in the SUM would be great and sounds like a valid feature request to me. I think it would be nice if you could make a new feature request for that here

Since it’s currently documented that the default fallback is a float and that there is a valid workaround I will close this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sequelize sum function always rounding to 4 decimal point
I'm using sequelize v5 and I found that my sum function always return with 4 decimal point, even with manual query (using mysql...
Read more >
Avoid rounding off decimal data, when using SUM function
4 Answers ... The SUM function don't round the result. The data type float is an approximate one and calculation can result in...
Read more >
Sequelize Aggregate Functions (MIN, MAX, SUM, COUNT, etc ...
In this tutorial, I'm going to give some examples of how to use aggregate functions with Sequelize.js. Database Models and Assocations. For this ......
Read more >
Datatypes - Manual | Sequelize
GEOMETRY('POINT', 4326) // Spatial column with geometry type and SRID. PostgreSQL (with PostGIS) or MySQL only. The BLOB datatype allows you to insert...
Read more >
Data Types - Sequelize
Below is a series of support table describing which SQL Type is used for each Sequelize DataType. info. Most of our DataTypes also...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found