Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoding of DECIMALS adds non significant trailing zeroes #81

Open
dominiquegerber opened this issue Mar 4, 2021 · 0 comments
Open
Assignees

Comments

@dominiquegerber
Copy link
Contributor

dominiquegerber commented Mar 4, 2021

Please provide the following details.

  • Operating System: Linux
  • PHP Version: 7.4
  • php-mysql-replication Version: 7.0
  • mysql version 10.3.22-MariaDB-1:10.3.22+maria~bionic-log

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 :)

@krowinski krowinski reopened this Mar 9, 2021
@krowinski krowinski self-assigned this Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants