You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When MySQL column has default values, the PDO returns a quoted value like 'some default value',
and this becomes an issue when comparing db and entity, the migration file will escape the quotes too:
$this->addSql('ALTER TABLE dt_coupon_gas CHANGE id id INT UNSIGNED AUTO_INCREMENT NOT NULL, CHANGE name name VARCHAR(255) DEFAULT \'\'hello\'\' NOT NULL COLLATE utf8mb4_unicode_ci');
and the \'hello\' then results into exception.
How to reproduce
Create an entity with a column which is varchar and has default string value
run migrations:diff
run migrations:migrate
Change the entity column, e.g. remove the default value
run migrations:diff
run migrations:migrate
Expected behavior
This might be MySQL's issue, but it becomes troublesome. I'm expecting that the default value read from MySQL database could be specially handled, single quotes stripped
if (preg_match('#^\'(.*)\'$#', $default $match)) $default = $match[1];
The text was updated successfully, but these errors were encountered:
@Yelfive there was a recent effort to improve handling default values in #2850 but it wasn't finished and got eventually reverted. Please feel free to submit a patch.
Bug Report
Summary
Current behavior
When MySQL column has default values, the PDO returns a quoted value like
'some default value'
,and this becomes an issue when comparing db and entity, the migration file will escape the quotes too:
and the
\'hello\'
then results into exception.How to reproduce
migrations:diff
migrations:migrate
migrations:diff
migrations:migrate
Expected behavior
This might be MySQL's issue, but it becomes troublesome. I'm expecting that the default value read from MySQL database could be specially handled, single quotes stripped
The text was updated successfully, but these errors were encountered: