Skip to content

Invalid discriminator maps should be detected during schema/mapping validation #6558

@jeroenvrooij

Description

@jeroenvrooij

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.

doctrine2

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions