dbal icon indicating copy to clipboard operation
dbal copied to clipboard

Report default floats with float type for MySQL

Open PaulCombal opened this issue 1 month ago • 6 comments

Q A
Type bug/improvement
Fixed issues https://github.com/doctrine/migrations/issues/1542

Summary

For MySQL databases, the default value is always reported as being a string, which causes doctrine/migrations to be confused sometimes.

It's my first time contributing to Doctrine please be free to request edits.

PaulCombal avatar Dec 04 '25 10:12 PaulCombal

Thank you for the PR. Please always add a test that reproduces the issue you're attempting to solve.

derrabus avatar Dec 04 '25 12:12 derrabus

For MySQL databases, the default value is always reported as being a string, which causes doctrine/migrations to be confused sometimes.

I would attempt to fix that instead. Database drivers represent some numbers as strings for a reason.

Using floats for any kind of logic that involves comparison may just exacerbate the problem. Also, if we want to make such a change, it should be implemented and tested consistently across all supported platforms, not only MySQL.

morozov avatar Dec 05 '25 00:12 morozov

What you're saying is that I should be handling this in doctrine/migrations instead of dbal, right?

PaulCombal avatar Dec 05 '25 04:12 PaulCombal

Not necessarily. The problem may be in the DBAL itself but not in the schema manager but let's say in the comparator.

The best way to facilitate reasoning about the proper fix is to implement a failing scenario in code using the minimum of dependencies (e.g. w/o the ORM).

morozov avatar Dec 05 '25 04:12 morozov

Thanks for the guidance. I moved the logic to AbstractPlatform::columnsEqual. Is this appropriate?

I will of course write tests for the change once a maintainer confirms the code is at the right place.

PaulCombal avatar Dec 05 '25 06:12 PaulCombal

I will of course write tests

Please start with an integration test.

morozov avatar Dec 05 '25 17:12 morozov

Turns out the test was already there, but the test case was not. I added it here.

Thank you for your patience.

PaulCombal avatar Dec 12 '25 06:12 PaulCombal

Apparently, your new test fails on SQL Server.

derrabus avatar Dec 12 '25 08:12 derrabus

Hi again, I implemented @derrabus 's solution instead, moving the logic into Column::toArray . It also fixes the test with mssql. Let me know if there's anything I can do to make this issue move forward.

PaulCombal avatar Dec 15 '25 12:12 PaulCombal