Get string not a number by SUM() in node sequelize

in #mysql3 years ago (edited)

image.png

Recently we're building the analytics functions. In one SQL query of analytics functions, we found that the SUM() result is a string not a number. That causes the final total number is a string connecting result, not a number sum result.

Search this situation on the Google. There is an issue in Sequelize project page.

https://github.com/sequelize/sequelize/issues/8713.

The reason is that SUM() result's type is NEWDECIMAL that is coming across as Javascript String.

To set a SUM() result as DECIMAL is reasonable. Because the SUM() result may be float type. If SUM() result is a number, there would be floating point issue.

So using DECIMAL as a String type data is necessary.

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.033
BTC 64029.44
ETH 3157.04
USDT 1.00
SBD 4.02