-
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
2.14.2: Entity Inheritance (at least STI) with intermediate abstract class is broken #10625
Comments
Possibly caused by the auto-filling of sub-classes in ClassMetadataInfo in #10411 |
mpdude
added a commit
to mpdude/doctrine2
that referenced
this issue
Apr 25, 2023
#### Current situation The implementation of `\Doctrine\ORM\Mapping\ClassMetadataInfo::_validateAndCompleteOneToOneMapping` will consider a field with a one-to-one association to be the owning side also when it configures `@JoinColumn` settings. #### Suggested change For a one to one association, a field should be the inverse side when it uses the `mappedBy` attribute, and be the owning side otherwise. The `JoinColumn` may be configured on the owning side only. This PR adds a deprecation notice when `@JoinColumn` is used on the side of a one-to-one association where `mappedBy` occurs. In 3.0, this will throw a `MappingException`.
mpdude
added a commit
to mpdude/doctrine2
that referenced
this issue
Apr 25, 2023
#### Current situation The implementation of `\Doctrine\ORM\Mapping\ClassMetadataInfo::_validateAndCompleteOneToOneMapping` will consider a field with a one-to-one association to be the owning side also when it configures `@JoinColumn` settings. #### Suggested change For a one to one association, a field should be the inverse side when it uses the `mappedBy` attribute, and be the owning side otherwise. The `JoinColumn` may be configured on the owning side only. This PR adds a deprecation notice when `@JoinColumn` is used on the side of a one-to-one association where `mappedBy` occurs. In 3.0, this will throw a `MappingException`.
mpdude
added a commit
to mpdude/doctrine2
that referenced
this issue
Apr 25, 2023
#### Current situation The implementation of `\Doctrine\ORM\Mapping\ClassMetadataInfo::_validateAndCompleteOneToOneMapping` will consider a field with a one-to-one association to be the owning side also when it configures `@JoinColumn` settings. #### Suggested change For a one to one association, a field should be the inverse side when it uses the `mappedBy` attribute, and be the owning side otherwise. The `JoinColumn` may be configured on the owning side only. This PR adds a deprecation notice when `@JoinColumn` is used on the side of a one-to-one association where `mappedBy` occurs. In 3.0, this will throw a `MappingException`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BC Break Report
The Single Table Inheritance Entity Inheritance is defined in your documentation with
but will fail on EntityManager::find() with an intermediate abstract entity class:
as the code iterates over all subclasses (abstract and non-abstract) and expects them in the discriminator map.
Summary
Apparently the intermediate abstract class seems to be expected in the discriminator map, even though the documentation states otherwise.
Not quite sure if the
ClassMetadataInfo::subClasses
iteration should directly access the discriminator valuesdiscrValues
inSingleTablePersister::getSelectConditionDiscriminatorValueSQL()
as
subClasses
is documented with having also abstract classeswhere those are not to be expected in the discriminator map.
Previous behavior
It worked ™️
Current behavior
Access violation on runtime, but not on validation.
How to reproduce
Assume the following example of entities:
plus some boilerplate:
composer.json
bootstrap.php
cli-config.php
and test.php
will result in
while
The text was updated successfully, but these errors were encountered: