MySQL80Platform requires the values of a ENUM column to be specified when using enum DiscriminatorColumn
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
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?
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.
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.
Added tests now as well.