-
-
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
What to use when Doctrine\DBAL\Types\Type::requiresSQLCommentHint() was removed in DBAL 4 #6257
Comments
That also breaks the Solution 2 for the MySQL enums |
In version 3 it has deprication
But NOT using it on custom types equals to SchemaTool freak outs. For example lets create such simple custom type without
This is result for
Now imagine whole database having like 50 references to table So question is: how we should resolve this situation? |
@jifer what you're experiencing sounds like a DBAL bug. Can you please try to reproduce it as a DBAL test case, using the DBAL schema comparison API? Note that |
@greg0ire Thank you for your reply. I feel like this issue is not new at all and consequences of removing this method were known. Going into some details. Referenced github topic in deprecation message is more than confusing as there is no mention how to deal with it and whats the replacement for it. In DBAL 3: // \Doctrine\DBAL\Platforms\AbstractPlatform::columnsEqual
public function columnsEqual(Column $column1, Column $column2): bool
{
// [..]
// false - declarations are same.
if (
$this->getColumnDeclarationSQL('', $column1Array)
!== $this->getColumnDeclarationSQL('', $column2Array)
) {
return false;
}
// false - platform (postgresql) does not support that.
if ($this->supportsInlineColumnComments()) {
return true;
}
// false -- comment are equal (null & null)
if ($column1->getComment() !== $column2->getComment()) {
return false;
}
// false - types differ
// $column1 is recognized as \Doctrine\DBAL\Types\StringType [without comment with type info on column reverse mapping can only guess base mapping types ]
// $column2 is recognized as \App\CustomType because it is taken from ORM definition.
// So even if column declaration equals and comment equals this indicates that column should be updated.
return $column1->getType() === $column2->getType();
} In 4.0+ Type comparison was removed. public function columnsEqual(Column $column1, Column $column2): bool
{
$column1Array = $this->columnToArray($column1);
$column2Array = $this->columnToArray($column2);
// ignore explicit columnDefinition since it's not set on the Column generated by the SchemaManager
unset($column1Array['columnDefinition']);
unset($column2Array['columnDefinition']);
if (
$this->getColumnDeclarationSQL('', $column1Array)
!== $this->getColumnDeclarationSQL('', $column2Array)
) {
return false;
}
// If the platform supports inline comments, all comparison is already done above
if ($this->supportsInlineColumnComments()) {
return true;
}
return $column1->getComment() === $column2->getComment();
} It doesn't feel like bug but rather miscommunication or lack of proper information that we should just ignore that |
Can you try using the setting implemented in doctrine/DoctrineBundle#1714 ? |
@greg0ire Good you mentioned this. I already did and this does not affect result (if excluding comment removal from columns) because dbal assumes there is no comment on both sides: // false -- comment are equal (null & null)
if ($column1->getComment() !== $column2->getComment()) {
return false;
} and gos straight to So everything would work as intended (probably) if we add this temporary flag in return $this->disableTypeComments || $column1->getType() === $column2->getType(); Ignore type checking (like in DBAL 4.0) if |
What do you mean, it's not supported? I literally pointed you to the MR that implements it, didn't I? 🤔
You just said they were equal. Are you in fact referring to Anyway, I think your idea might not work: what if the type differ not because of the comment? Like the basic type int, and the basic type string? |
My apologies. You probably are also right about type comparison. But if so, how 4.0 recognize type changes if method if (
$this->getColumnDeclarationSQL('', $column1Array)
!== $this->getColumnDeclarationSQL('', $column2Array)
) {
return false;
} If SQL declaration is exactly the same nothing should be changed in schema, right? Here again whole method form 4.0: public function columnsEqual(Column $column1, Column $column2): bool
{
$column1Array = $this->columnToArray($column1);
$column2Array = $this->columnToArray($column2);
// ignore explicit columnDefinition since it's not set on the Column generated by the SchemaManager
unset($column1Array['columnDefinition']);
unset($column2Array['columnDefinition']);
if (
$this->getColumnDeclarationSQL('', $column1Array)
!== $this->getColumnDeclarationSQL('', $column2Array)
) {
return false;
}
// If the platform supports inline comments, all comparison is already done above
if ($this->supportsInlineColumnComments()) {
return true;
}
return $column1->getComment() === $column2->getComment();
//
// There is no $column1->getType() === $column2->getType() check in 4.0 which is present in dbal 3.0
//
} Still, rookie like me can miss something ;) |
🤔 I think you're the one who's right now. Please send a PR with |
Holy... I completely forgot about that! With regards. |
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. |
Support Question
In DBAL 4 the
requiresSQLCommentHint()
function was removed. How do I let Doctrine know that any special DB column is of that specific custom type?The text was updated successfully, but these errors were encountered: