Skip to content

MySQL80Platform requires the values of a ENUM column to be specified when using enum DiscriminatorColumn #11794

@whataboutpereira

Description

@whataboutpereira

Using enum in DiscriminatorColumn:

enum CommentType: string
{
    case One = 'one';
    case Two = 'two';
    case Three = 'three';
}
#[ORM\DiscriminatorColumn(name: 'Type', type: Types::ENUM, enumType: CommentType::class)]
#[ORM\DiscriminatorMap([
    'one' => CommentOne::class,
    'two' => CommentTwo::class,
    'three' => CommentThree::class,
])]

When generating a migration, this yields:

Doctrine\DBAL\Platforms\MySQL80Platform requires the values of a ENUM column to be specified.

I see AbstractMySQLPlatform.php->getEnumDeclarationSQL() receives these (first one has values populated, second one has no values, but enumType is specified, that the first one doesn't have):

Array
(
    [name] => Type
    [type] => Doctrine\DBAL\Types\EnumType Object
        (
        )

    [default] =>
    [notnull] => 1
    [length] => 0
    [precision] =>
    [scale] => 0
    [fixed] =>
    [unsigned] =>
    [autoincrement] =>
    [comment] =>
    [values] => Array
        (
            [0] => one
            [1] => two
            [2] => three
        )

    [version] =>
)
Array
(
    [name] => Type
    [type] => Doctrine\DBAL\Types\EnumType Object
        (
        )

    [default] =>
    [notnull] => 1
    [length] => 255
    [precision] =>
    [scale] => 0
    [fixed] =>
    [unsigned] =>
    [autoincrement] =>
    [comment] =>
    [values] => Array
        (
        )

    [enumType] => App\Enum\CommentType
    [version] =>
)
doctrine/dbal                       4.2.2
doctrine/migrations                 3.8.2
doctrine/orm                        3.3.1

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions