[PR #5896] Pull default mapping values from concrete types #9775

Closed
opened 2026-01-22 16:05:22 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/5896

State: closed
Merged: No


This PR requires the https://github.com/doctrine/dbal/pull/2421 PR to be merged first.

It solves the problem where the comparator sees columns as changed when a custom type overrides parameters like length internally when returning the SQL statement to create/update the column.

This feature allows to supply those override values via a specific function, so the values are known to the schema tool and the comparator can compare the actual values. As an example, the following custom type always triggered the comparator to see a column as changed, even though it wasn't:

class LocaleType extends StringType
{
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
    {
        return $platform->getVarcharTypeDeclarationSQL([
            'length' => '5',
            'fixed' => true,
        ]);
    }
}

In comparison, with the new method for types introduced, one can write an equal type which will work with the comparator:

class LocaleType extends StringType
{
    public function getDefaultMappingValues()
    {
        return [
            'length' => '5',
            'fixed' => true,
        ];
    }
}
**Original Pull Request:** https://github.com/doctrine/orm/pull/5896 **State:** closed **Merged:** No --- This PR requires the https://github.com/doctrine/dbal/pull/2421 PR to be merged first. It solves the problem where the comparator sees columns as changed when a custom type overrides parameters like length internally when returning the SQL statement to create/update the column. This feature allows to supply those override values via a specific function, so the values are known to the schema tool and the comparator can compare the actual values. As an example, the following custom type always triggered the comparator to see a column as changed, even though it wasn't: ``` php class LocaleType extends StringType { public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { return $platform->getVarcharTypeDeclarationSQL([ 'length' => '5', 'fixed' => true, ]); } } ``` In comparison, with the new method for types introduced, one can write an equal type which will work with the comparator: ``` php class LocaleType extends StringType { public function getDefaultMappingValues() { return [ 'length' => '5', 'fixed' => true, ]; } } ```
admin added the pull-request label 2026-01-22 16:05:22 +01:00
admin closed this issue 2026-01-22 16:05:22 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#9775