-
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
Enum fields can't be an id field. #10132
Comments
This is the expected behavior at the monent, should work with toString implemented |
There is no way to implement toString for an enum. |
I did not know / forgot this, hmmm |
Why isnt identifier flattener used in this case? Check #9629 this feature should have been already implemented and I am using enum IDs in my project without issue. Please provide test which shows how its broken. |
I am also facing this problem. In my case enum field is a part of the composite primary key. Latest working version is 2.13.1. |
@flight643 please provide broken test case |
I am experiencing the same problem on 2.13.4. While our actual implementation is a bit more complex I have been able to abstract it to a failing test case. PHPunit gives the following information:
L75 of the test case. I was able to resolve this with a patch that closely resembles the one proposed in #10158 for |
I was looking into the code, trying to come up with a fix, but I noticed something weird. SubComplexChild in your example has just one associationMapping, specifically complex_type. All the other mappings are ignored in UoW, i.e. there is no complex_number nor complexChild_point. It makes me wonder, is this even a valid syntax: #[ManyToOne(
targetEntity: ComplexChild::class,
inversedBy: 'subComplexChildren',
)]
#[JoinColumn(
name: 'complex_type',
referencedColumnName: 'complex_type',
)]
#[JoinColumn(
name: 'complex_number',
referencedColumnName: 'complex_number',
)]
#[JoinColumn(
name: 'complexChild_point',
referencedColumnName: 'point',
)]
protected ComplexChild $complexChild; ? EDIT: Ok, this syntax was actually OK, but the code is using your PHPDoc syntax and with phpdoc, if you have multiple join columns, you need to wrap them with |
My apologies, we strictly use the attributes in our codebase and I could not be bothered to make my test case to work with that, so I simply copied them into their annotation form not accounting for the need of an Thanks in advance for your time taking a look at this and trying to fix it! |
The title of this issue should be "Enum IDs cannot be part of association mapping" |
Bug Report
Summary
Id Field with enumType is not working.
Current behavior
I have a entity called "display" with a primary key over multiple columns:
[id] int feedback_id (relation to feedback)
[id] string with enumType identity_type
string identity_id
There also is a parent entity called "feedback" with the following columns:
[id] int id
collection displays (relation to display)
When I query for a entry from feedback with a join to displays, this call failes when done a second time, with:
Object of class App\Entity\IdentityType could not be converted to string
in vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:286
It is caused by this code:
not expecting $data[$fieldName]) to be an enum.
Expected behavior
Support for enum fields as index.
The text was updated successfully, but these errors were encountered: