krowinski / php-mysql-replication

Pure PHP Implementation of MySQL replication protocol. This allow you to receive event like insert, update, delete with their data and raw SQL queries.
MIT License
323 stars 98 forks source link

Decoding of DECIMALS adds non significant trailing zeroes #81

Open dominiquegerber opened 3 years ago

dominiquegerber commented 3 years ago

Please provide the following details.

Steps required to reproduce the problem (take from the unit tests)

CREATE TABLE test (test DECIMAL(20,10)); INSERT INTO test VALUES(-42000.123456);

Expected Result.

'-42000.123456'

Actual Result.

'-42000.1234560000'

Why this is a problem

Mathematically speaking, both results are valid. However decimals are represented using strings in the lib (bcmath). Hence, when tested for equality, '-42000.123456' is not the same as '-42000.1234560000'. Greater/Lower comparison do work, but not strict equality. The unit tests enforce the presence of these trailing zeroes, which to me should not be.

I can do a pull request to fix this if you agree with me that this is an issue. Not a big one, but still :)