2.13.2 breaks *array* of enums #7045

Closed
opened 2026-01-22 15:43:39 +01:00 by admin · 3 comments
Owner

Originally created by @ThomasLandauer on GitHub (Sep 24, 2022).

Bug Report

Q A
BC Break yes
Version 2.13.2

Summary

When having an array of enums like this:

#[ORM\Column(type: Types::SIMPLE_ARRAY, length: 255, nullable: true, enumType: Color::class)]
private array $colors = [];

I'm getting this error:

"Green,Red,Blue" is not a valid backing value for enum "App\Enum\Color"

I'm guessing that https://github.com/doctrine/orm/pull/10041 broke it, since @michnovka was referring to a string column:

#[Column(type: Types::STRING, nullable: false, enumType: OrderStatus::class, options: ['charset' => 'utf8', 'collation' => 'utf8_unicode_ci'])]
private OrderStatus $orderStatus;

Workaround

For anybody else observing this, a workaround for now is to add this to your composer.json to continue using 2.13.1:

"conflict": {
    "doctrine/orm": "2.13.2"
},

Next Step

Well, I think it's about time to properly document arrays of enums at https://www.doctrine-project.org/projects/doctrine-orm/en/2.13/reference/basic-mapping.html - I'll come up with a PR after getting some feedback here.

Originally created by @ThomasLandauer on GitHub (Sep 24, 2022). ### Bug Report | Q | A |------------ | ------ | BC Break | yes | Version | 2.13.2 #### Summary When having an *array* of enums like this: ```php #[ORM\Column(type: Types::SIMPLE_ARRAY, length: 255, nullable: true, enumType: Color::class)] private array $colors = []; ``` I'm getting this error: > "Green,Red,Blue" is not a valid backing value for enum "App\Enum\Color" I'm guessing that https://github.com/doctrine/orm/pull/10041 broke it, since @michnovka was referring to a *string* column: ```php #[Column(type: Types::STRING, nullable: false, enumType: OrderStatus::class, options: ['charset' => 'utf8', 'collation' => 'utf8_unicode_ci'])] private OrderStatus $orderStatus; ``` #### Workaround For anybody else observing this, a workaround for now is to add this to your `composer.json` to continue using 2.13.1: ```json "conflict": { "doctrine/orm": "2.13.2" }, ``` #### Next Step Well, I think it's about time to properly document arrays of enums at https://www.doctrine-project.org/projects/doctrine-orm/en/2.13/reference/basic-mapping.html - I'll come up with a PR after getting some feedback here.
admin closed this issue 2026-01-22 15:43:40 +01:00
Author
Owner

@greg0ire commented on GitHub (Sep 24, 2022):

Can you provide a test case for this? Also, please note that the code has already changed since 2.13.2: #10058

@greg0ire commented on GitHub (Sep 24, 2022): Can you provide a test case for this? Also, please note that the code has already changed since 2.13.2: #10058
Author
Owner

@michnovka commented on GitHub (Sep 24, 2022):

@ThomasLandauer I believe that https://github.com/doctrine/orm/pull/10058 fixes this issue, but please do provide a test case, we should push it for CI sake

@michnovka commented on GitHub (Sep 24, 2022): @ThomasLandauer I believe that https://github.com/doctrine/orm/pull/10058 fixes this issue, but please do provide a test case, we should push it for CI sake
Author
Owner

@ThomasLandauer commented on GitHub (Oct 7, 2022):

There you go - my first attempt for a test here ;-) https://github.com/doctrine/orm/pull/10111
Please take a look, I probably need some help there.

Anyway, the issue itself does indeed look fixed in v2.13.3, so I'm closing here.

@ThomasLandauer commented on GitHub (Oct 7, 2022): There you go - my first attempt for a test here ;-) https://github.com/doctrine/orm/pull/10111 Please take a look, I probably need some help there. Anyway, the issue itself does indeed look fixed in v2.13.3, so I'm closing here.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7045