-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BackedEnum primary key fails to convert for association using proxy classes #10788
Comments
@Gwemox Allow me to tag you in this issue as you were the author of the initial pull requests. |
@wmouwen Do you have the stack trace? |
@Gwemox I've created a repository with minimal code which triggers the error. Important to the case is the use of a proxy class. Stack trace is included in the README in the repository. |
@wmouwen you can convert your backed enum to string with a doctrine custom type : https://www.doctrine-project.org/projects/doctrine-orm/en/2.15/cookbook/custom-mapping-types.html @greg0ire @sips-richard We should think about the desired solution for 2.6 or 3.0 ? Currently StringType does nothing. public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
return $value;
} $value is a backed enum. |
Well if it's a bug, for 2.15 |
We reverted because of this issue #10745 We could modify the StringType to make a |
After having fiddled with custom types for backed enumerations, I would argue having dedicated types isn't the way to go. You would have to differ between the (kinds of) string and integers that there are default mappings for: EnumStringType, EnumIntegerType, optionally EnumSmallintType, etc. |
Bug Report
Summary
For a while BackedEnums were allowed as primary keys, where Doctrine would happily convert them to their scalar value. There has been some back and forth about this in previous issues/PRs where the functionality was repaired and broken again.
#10334
#10471
#10508
Most recent events:
#10745
#10758
Current behavior
Setting a BackedEnum as primary key on an entity, using that entity in an association and trying to save it with a proxy class, will throw an error as the BackedEnum is no longer converted to a scalar value.
How to reproduce
See https://github.com/wmouwen/doctrine-orm-10788 for a minimal setup throwing the error.
Code snippet copy 👇
Expected behavior
The BackedEnum is converted and the save succeeds, as it did in version
2.15.2
.-edit- Added the stack trace, made the code snippet collapse, added reference to repository with minimal setup.
The text was updated successfully, but these errors were encountered: