dbal icon indicating copy to clipboard operation
dbal copied to clipboard

Versionable datetimetype column diff issue

Open rmikalkenas opened this issue 3 years ago • 1 comments

Bug Report

Q A
Version 3.3.2

Summary

Platform: MySQL Version: 8.0

Entity with versionable field:

/**
 * @ORM\Version()
 * @ORM\Column(type="datetime")
 */
private \DateTime $version;

generates the same migration over and over again even after executing it (https://github.com/rmikalkenas/migration-issue/blob/version-issue/migrations/Version20220302083650.php)

An issue comes from changes that adds Comparator with provided database platform as dependency. When comparing columns this peace of code https://github.com/doctrine/dbal/blob/baf6efed70e46f4d979e5dd42f804007e75f12fb/src/Schema/Comparator.php#L291 returns [] on versionable datetimetype column. But due to set $this->platform later check $this->columnsEqual($column, $toColumn) results to false and marks column as having changes. Because one of Column instances does not have version platform option which is necessary for getting correct mysql datetime column type declaration: https://github.com/doctrine/dbal/blob/baf6efed70e46f4d979e5dd42f804007e75f12fb/src/Platforms/AbstractMySQLPlatform.php#L249

How to reproduce

https://github.com/rmikalkenas/migration-issue/tree/version-issue version-issue branch

Expected behaviour

No migration should be generated for versionable datetime type column

rmikalkenas avatar Mar 02 '22 09:03 rmikalkenas

Any update on this? Pointers or suggestions for potentially providing a fix?

alcohol avatar Dec 07 '23 08:12 alcohol