Why getting decimal in string instead of number in MySQL 8

W 4.9.1.
NodeJS
MySQL 8.0.22

Hi! For some time I’ve worked with MariaDB 10.1, but recently I’ve switched to MySQL 8.

I’ve noticed one strange difference: now I’m getting decimal in string instead of number.
For example, cost: "0.50" instead of cost: 0.5.

This is a bug or this is about settings in my DB?

In your database connection settings is the Prepare Statements option set to true or false?

It depends on the database client. MariaDB and MySQL should be compatible for most use cases and both use the same client, probably the column type is a bit different between the two.

I checked with node mysql client and it says on GitHub that it converts Decimal type to String and not Number.

mysqljs/mysql: A pure node.js JavaScript Client implementing the MySQL protocol. (github.com)

DECIMAL (may exceed float precision)
1 Like

Yes, hosting support have comfirmed that Prepare Statements enabled.

Ok, now I understand, thanks! I will keep this in mind.