mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
[PR #9410] Allow DiscriminatorColumn with length=0 #11592
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/doctrine/orm/pull/9410
State: closed
Merged: Yes
This patch allows to set
lengthto a Zero-Value on a@ORM\DiscriminatorColumn:Right now a value <1 will be replaced by the default value (255) of a ternary operation in
\Doctrine\ORM\Mapping\Driver\AnnotationDriver::loadMetadataForClass.This seems to be an accidental results from the weak type comparison.
On a
@ORM\Columna length of Zero will be parsed as is and not changed to 255.Background:
I'm mapping MySQL enums to strings as described here: https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/cookbook/mysql-enums.html#solution-1-mapping-to-varchars
Since the 3.2 release with the new Platform-aware schema comparison (
https://www.doctrine-project.org/2021/11/26/dbal-3.2.0.html) I get a lot of diffs in our enum fields.
The schema diff will report different values for the
length-property as the MySQl Platform yields lenght = 0 for the mysql native ENUM type.To fix the diff the length has to be specified as 0:
This works for all columns and the enum fields won't generate diffs anymore.
The same lenght=0 change is required if the DiscriminatorColumn uses a native Enum type like so:
Right now this is not possible as
length=0on aDiscriminatorColumnwill becomelength=255and thus a diff will be reported from the schema comparison.