-
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
Allow enum discriminator columns #10288
Allow enum discriminator columns #10288
Conversation
1471a77
to
0ef8084
Compare
@greg0ire please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kudos on the great commit message, it makes it really easier to understand what's happening here.
Any way you could test the scenarios Codecov is pointing at?
I'm a bit hesitant to treat this as a bugfix. Let's target 2.14, please. |
af1350b
to
c1c089a
Compare
@derrabus I have rebased to 2.14.x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking the merge until #10288 (comment) is resolved.
b9cb653
to
8fb653e
Compare
@derrabus I have implemented what you asked for.
I have added tests to please review |
210a27a
to
ef0ff51
Compare
This commit adds enumType option to DiscriminatorColumn as well as support for custom DBAL types which use PHP enums for PHP values. Previously, the enumType option was completely missing, but also even using custom types that used PHP enums would end up in exception because ObjectHydrator would try to convert enums to string using (string) explicit conversion. Apart from hydrators, ClassMetadataBuilder was extended to support specifying enumType. Documentation was updated.
b2211c6
to
497ee16
Compare
I am happy with the PR now, I think it covers everything:
|
Thanks @michnovka ! |
please merge into 3.x so that I can do the cleanup. thanks! |
In all hydrators, discriminator columns are for all purposes converted to string using explicit (string) conversion. This is not allowed with PHP enums. Therefore, I added code which checks whether the variable is a BackedEnum instance and if so, instead its ->value is used (which can be cast to string without issues as its a scalar)
The test builds upon #6141 which allowed objects to be discriminator column values. This fix further extends the use-case to allow PHP enums also.