-
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
Invalid discriminator maps should be detected during schema/mapping validation #6558
Comments
Closing as The issue is that the schema validation tools didn't discover a duplicate inheritance definition, but that's for a separate issue to fix. |
Could you please go in to a bit more detail? Because at the moment I do not understand if I made a mistake in the inheritance mapping or that multilevel discrimination is not even supported in the first place. |
You basically need to define the inheritance mapping only at the very top of the inheritance. |
Yeah I get that. But like I said, that is also not a valid mapping. We tried that as well. Please check this PR with the updated test case which hopefully clears things up :). #6578 |
@jeroenvrooij re-opening then, thanks for clarifying with a new test case 👍 |
As discussed in #6578 (comment), this issue is a schema validator problem: some discriminator values are missing in the discriminator map. |
HI, i have a same problem with multiple inheritance, but i had different discriminator column names. It's ok? or i must have same discriminator column name? Our structure is same as image, but i in Image is discriminator column name "PersonType" and in Employee is discriminator column name is "EmployeeType", if i call findAll() on Person, i get only Managers and Employes and doctrine not resolve Epmployees inheritance. |
Hi @Ocramius I've got related problem to this.
I've got discriminators specified in Item class. If I use
if I use
As you see on attached SQL dumps in second example doctrine didn't join items_media table at all which cause all properties from Media Entity that should be in Image Entity are null or empty string. |
Given the following structure of entities, which are discriminated over two levels, fetching a Developer using the repository from the root entity (Person) results in exceptions.
The issue is that an Employee object is being instantiated, which fails since that class is abstract. So it seems that Doctrine is not following the tree until the leaf nodes. Fetching the Developer using the repository from it's direct parent (so the Employee) works fine.
This may, or may not, give some insights as well:
Persisting a Developer works ok, except that the order of insert queries executed are wrong (in my opinion). The Person is inserted first, followed by the Developer and the Employee is inserted last. (So: root -> leaf -> 2nd layer). This forces us to not have foreign keys on the id columns of the Employee, Staff and Developer.
Note:
I will submit some test cases which test the two scenarios of fetching using the different repositories.
Edit:
PR with the test case: #6559
The text was updated successfully, but these errors were encountered: