Bug #103124 Unexpected rounding value for updating Decimal field
Submitted: 26 Mar 2021 12:03 Modified: 8 Jul 2021 5:12
Reporter: Kevin Lau Email Updates:
Status: Closed Impact on me:
None 
Category:Connector for Node.js Severity:S1 (Critical)
Version:8.0.23 OS:Any
Assigned to: Rui Quelhas CPU Architecture:Any

[26 Mar 2021 12:03] Kevin Lau
Description:
As per discussion
https://forums.mysql.com/read.php?44,695524,695600#msg-695600

Incorrect updating behavior such as:

Try updating negative values -56556.56, resulting in -56556.60
Try updating positive values 56556.56, resulting in 56556.60

How to repeat:
create table (
'ID' INT AUTO_INCREMENT,
`Total_Profit` DECIMAL(16,2) NULL);

Expected behavior
Mysql statement
update table set Total_Profit = '-56565656.56' where ID = '1';
Result will become -56565656.56 on the table.

Unexpected behavior in Nodejs connector

table.update()
.where(
`...`
)
.set(Total_Profit, -56565656.56)

The result will become -56565700.00 on the Mysql database
[26 Mar 2021 12:15] MySQL Verification Team
Hello Kevin Lau,

Thank you for the report and feedback.
Verifying based on the comment from Rui at https://forums.mysql.com/read.php?44,695524,695600#msg-695600

regards,
Umesh
[8 Jul 2021 5:12] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/Node.js 8.0.26 release, and here's the proposed changelog entry from the documentation team:

Now ensure that all floating point numbers are represented either by
JavaScript numbers or by X DevAPI expression literals that are encoded as
an X Protocol V_DOUBLE type; this to help avoid precision loss.

Thank you for the bug report.