Description
Bug Report
Q | A |
---|---|
BC Break | no |
Version | 3.1.3 |
Summary
We have a custom "money_value" type, to set decimal with predefined values for precision + scale like numeric(10,4)
. This works on first migration, but changes (e.g. to 11,4) are not recognized.
The type class looks like this:
class MoneyValueType extends ApplicationDoctrineType
{
public const NAME = 'money_value';
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
$column['precision'] = 11;
$column['scale'] = 4;
return $platform->getDecimalTypeDeclarationSQL($column);
}
/**
* {@inheritdoc}
*/
public function getName()
{
return self::NAME;
}
}
This should do it, SQL declaration returns numeric(11,4)
... But DBAL has a trap in Comparator.php:
dbal/src/Schema/Comparator.php
Lines 482 to 490 in 96b0053
The documentation does not require to extend specific Type classes (https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#custom-mapping-types).
If precision
and scale
are irrelevant for non-decimal types, they should not have default values at all and the magic "10" should be set in DecimalType
.
There is a similar problem with fixed
as well.