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

Open
opened 2026-01-22 15:52:01 +01:00 by admin · 4 comments
Owner

Originally created by @whataboutpereira on GitHub (Jan 18, 2025).

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
Originally created by @whataboutpereira on GitHub (Jan 18, 2025). 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 ```
admin added the New Feature label 2026-01-22 15:52:01 +01:00
Author
Owner

@derrabus commented on GitHub (Jan 21, 2025):

We indeed don't support extracting the enum cases in discriminator columns yet, but I don't see why we shouldn't. Do you want to work on this feature?

@derrabus commented on GitHub (Jan 21, 2025): We indeed don't support extracting the enum cases in discriminator columns yet, but I don't see why we shouldn't. Do you want to work on this feature?
Author
Owner

@whataboutpereira commented on GitHub (Jan 23, 2025):

We indeed don't support extracting the enum cases in discriminator columns yet, but I don't see why we shouldn't. Do you want to work on this feature?

It turned out easier to get working than I expected. I'm not sure how to go about testing it though.

@whataboutpereira commented on GitHub (Jan 23, 2025): > We indeed don't support extracting the enum cases in discriminator columns yet, but I don't see why we shouldn't. Do you want to work on this feature? It turned out easier to get working than I expected. I'm not sure how to go about testing it though.
Author
Owner

@derrabus commented on GitHub (Jan 23, 2025):

You can have a look at our existing functional test suite. You would basically create an entity model that reproduces your problem and write code that persists and fetches data using that model.

@derrabus commented on GitHub (Jan 23, 2025): You can have a look at our existing functional test suite. You would basically create an entity model that reproduces your problem and write code that persists and fetches data using that model.
Author
Owner

@whataboutpereira commented on GitHub (Jan 24, 2025):

Added tests now as well.

@whataboutpereira commented on GitHub (Jan 24, 2025): Added tests now as well.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7462