-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
SchemaManager::createSchema wrongly quotes default values on MariaDB(?) #4671
Comments
This must be related to how MariaDB represents the default value during schema introspection. See "MariaDB 10.2.7 information changes schema for default values" in #2825. In theory, this case should be handled by dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php Lines 230 to 241 in 628e846
|
@morozov maybe I'm reading the code wrong, but shouldn't the snippet you quoted only replace |
It's the create table default_value(
id int not null,
metadata_exported datetime default '0001-01-01 00:00:00' null
) collate=utf8_unicode_ci; |
I've debugged this some more today and noticed that |
I don't know what exactly your code does and why it disables the default event handler but it sounds right. |
@morozov well, the thing is if you want to use the callback to set some info for the column, you have to call dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php Lines 811 to 821 in 628e846
It would be nice if |
That's indeed a clumsy extension API. If you need to do some customization of the column definitions before they get created, it might be easier to register a custom platform and just override Passing the column to the event handler would likely solve your problem but I don't think it's worth an API break. If you feel you want to participate in improving the API, please file another issue and describe your problem there. |
One idea might be to have |
I don't really like the idea of events here. The caller of an event handler doesn't usually expect anything to be returned. Using events to implement certain API is a bit weird. It would make more sense to define an interface (e.g.
Please file a case if you believe it's important. |
alright, I've submitted #4676 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug Report
Summary
I have a field in the database that looks like this in the mysqldump:
I read the database structure like this:
If I dump the field, it looks like this:
(notice the double quotes for the
_default
value)When I build the schema with
SchemaTool::getSchemaFromMetadata
, I get the default without double quotes. so when I feed both of them toDoctrine\DBAL\Schema\Comparator
, I get a difference in each date field in the entire database looking like this:Current behaviour
DBAL thinks that
"0001-01-01 00:00:00"
is different from"'0001-01-01 00:00:00'"
and runs a bunch of pointless updates every time I run comparatorHow to reproduce
I can try to come up with some way to reproduce this, but I noticed it only happens on some machines. So far my theory is that the problem exists on MariaDB but not on MySQL, but I'm not a 100% sure
Expected behaviour
createSchema
should not produce double quotes when reading the default values form the databaseThe text was updated successfully, but these errors were encountered: