mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Enum field mapping validation #7240
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?
Originally created by @yceruto on GitHub (Nov 2, 2023).
The recently properties types validation implemented in https://github.com/doctrine/orm/pull/10946 is not working properly for enum mappings:
16028e4fd3/lib/Doctrine/ORM/Tools/SchemaValidator.php (L384-L387)where
$propertyTypeis a BackedEnum class and$metadataFieldTypeisstringorint.Possible solution
I'd add another check (just below that block) to validate the enum mapping, something like this worked for me:
It checks the property type against the
enumTypeinstead, but also checks if the BackedEnum variant (string or int) matches the metadata field type.Does it make sense to you?
Affected versions:
2.17.x+@derrabus commented on GitHub (Nov 2, 2023):
Can you provide a reproducer or a failing test for your issue? If you've already found a solution (as you apparently did), don't hesitate to open a PR with your fix and a test that fails without your fix.
@yceruto commented on GitHub (Nov 3, 2023):
Here we go https://github.com/doctrine/orm/pull/11039
@W0rma commented on GitHub (Nov 16, 2023):
I stumbled over this issue when using
doctrine/orm:2.17.Seems like
2.17was released before this issue has been fixed.@delolmo commented on GitHub (Nov 16, 2023):
Having the same problem here when updating to
2.17. When trying to validate the mappings, all enumTypes started failing. They didn't on previous versions.@stlrnz commented on GitHub (Nov 16, 2023):
I can confirm this issue.