-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Bug Report
| Q | A |
|---|---|
| Version | 4.2.2 |
| Previous Version if the bug is a regression | 3.x |
| Database | MariaDB 10.11 |
Summary
Hi, now when comments were removed, Comparator cannot differentiate my custom Tinyint type from Boolean.
class TinyIntType extends Type
{
public const string NAME = 'tinyint';
public function getName(): string
{
return self::NAME;
}
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
return 'TINYINT'.(!empty($column['unsigned']) ? ' UNSIGNED' : '');
}
public function convertToPHPValue($value, AbstractPlatform $platform): ?int
{
return $value === null ? null : (int) $value;
}
public function getBindingType(): ParameterType
{
return ParameterType::INTEGER;
}
}Current behavior
When generating a diff, or running schema update command, this condition https://github.com/doctrine/dbal/blob/4.2.2/src/Platforms/AbstractPlatform.php#L2259 fails because it is comparing TINYINT(1) NOT NULL with TINYINT UNSIGNED NOT NULL, even though database value is TINYINT UNSIGNED and it has default (3) size, not 1.
Type declaration is read from type of "old" column https://github.com/doctrine/dbal/blob/4.2.2/src/Platforms/AbstractPlatform.php#L1424 which was detected as Doctrine\DBAL\Types\BooleanType, probably because old columns for comparing have data only from database, and since comments like (DC2Type:tinyint) are no longer supported, it guesses that tynyint means boolean.
Expected behavior
I would expect that we could have multiple types defined to same database types, what I think it's possible if the strings were the same.. but AbstractMySQLPlatform does not respects any column arguments, it just returns TINYINT(1) https://github.com/doctrine/dbal/blob/4.2.2/src/Platforms/AbstractMySQLPlatform.php#L195
How to reproduce
I'm not able to provide whole code, because I don't know exactly how is old schema created, and probably this is intended behavior, I'm just curious how can I avoid this diff mismatch, but if it's something not intended, I'll try to reproduce minimal example when I find more free time, the problem will be constructing of existing database schema from live MariaDB data.