Report default floats with float type for MySQL
| 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.
Thank you for the PR. Please always add a test that reproduces the issue you're attempting to solve.
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.
What you're saying is that I should be handling this in doctrine/migrations instead of dbal, right?
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).
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.
I will of course write tests
Please start with an integration test.
Turns out the test was already there, but the test case was not. I added it here.
Thank you for your patience.
Apparently, your new test fails on SQL Server.
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.