mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Undefined alias for Embeddable in 2.7.1 #6403
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vicdelfant on GitHub (Feb 19, 2020).
Bug Report
Summary
2.7.1seems to (partially) break support for embedded properties, resulting in a "column not found" exception. Reverting to2.7.0without any other code changes fixes this. The cause seems to be the use of an undefined alias for fetching the embeddable's properties.Current behavior
The
a1_alias is introduced without being defined, generating the following SQL:This results in the following exception:
How to reproduce
Upgrade to
2.7.1and use the following entity and embeddable. The entity and embeddable are trimmed for readability but you get the gist:Entity
Embedded
Expected behavior
The existing
o0_alias is re-used, resulting in the following SQL:@Exalyon commented on GitHub (Feb 19, 2020):
Hi, I have the same problem.
After some investigation, I found out that the mapping now adds an inherited key to the fieldMapping for the Embeddable who have a superclass. This result in the following code to think
the superclass is an entity which have a table whereas it is incorrect.
This code is found in the SqlWalker at the line 1397.
@beberlei commented on GitHub (Feb 22, 2020):
I believe #8006 is at fault, its the only thing that is related to embeddables in 2.7.1
Looping in @malarzm
@malarzm commented on GitHub (Feb 23, 2020):
I've tried to create a failing test case (#8036) but it's not failing 👀 @vicdelfant @Exalyon could you please take a look and tell me what I'm doing wrong in the test?
@malarzm commented on GitHub (Feb 23, 2020):
All right, got it failing with repository's
findBy👍 Indeed #8006 is the culprit as the test is passing again once I revert my patch@vicdelfant commented on GitHub (Feb 23, 2020):
You beat me to it @malarzm :) Thanks for looking into this!
@malarzm commented on GitHub (Feb 23, 2020):
One thing I've found out is that if
AbstractYearSequenceValuewould be mapped as a@ORM\MappedSuperclassthen error wouldn't be raised and everything would work as it should. Also this would be correct mapping from ORM's perspective I believe. But then I've mapped myself abstract classes as entities so I guess there are reasons for such mappings :) I'll be looking into how we can fix this without reverting #8006@jaroslavlibal commented on GitHub (Feb 24, 2020):
It also breaks the proxies generation process for me and I end up with the ReflectionException in RuntimeReflectionService.php at line 75 -
Property XXX does not exist.Reverting the #8006 locally fixed the issue for me.
@malarzm commented on GitHub (Feb 24, 2020):
@jaroslavlibal with "proxy generation process" you mean casual proxy generation with provided command? Do you also have embeddables that inherit from other embeddables?
@jaroslavlibal commented on GitHub (Feb 24, 2020):
@malarzm Yes, exactly -
orm:generate-proxiescommand. And yes, we have embeddables that inherit from other embeddables (value objects).A
Clubentity with theClubOfficial $chairmanembeddable property.The
ClubOfficialembeddable extends theContactPersonembeddable.The
ContactPersonembeddable has theAddress $addressproperty, which is also an embeddable.@malarzm commented on GitHub (Feb 24, 2020):
@jaroslavlibal would you mind testing if #8036 fixes your issue as well? I couldn't come up with an easy-enough test for your case but I my patch should bring back status quo. Although having embeddable which contains another embeddable sounds weird and unsupported as according to docs embeddables can contain only columns 🤔
@jaroslavlibal commented on GitHub (Feb 25, 2020):
@malarzm Unfortunately I have to inform that it haven't resolved my issue. I have probably overlooked (years ago) the information that embeddables can contain only columns; however the information itself was not entirely true as embeddables containing embeddables worked well until the current version 😟
We considered embeddables as value objects, which can contain another value objects (and columns).
The problem does not occur with embeddables which contains another embeddables, when no inheritance is used (eg.
BillingInformationembeddable which containsAddress $addressembeddable property mentioned above).@beberlei commented on GitHub (Feb 25, 2020):
@jaroslavlibal i am not sure about embeddables can't contain embeddables, I believe it was added at some point, so that is why its working for you. We should be able to fix it, or revert, so no worries :)
@beberlei commented on GitHub (Mar 1, 2020):
@jaroslavlibal i have reproduced your problem on top of @malarzm PR.
@beberlei commented on GitHub (Mar 1, 2020):
@jaroslavlibal there was already a workaround about nested and inheritence in the code that broke the right fix in #8006. I disabled that workaround in a new commit to the #8036 PR. Can you verify that fixes your problem?
@jaroslavlibal commented on GitHub (Mar 2, 2020):
@beberlei Yes, pulling
gh-8031-extending-embeddable 5f5b3a5fixes my problem. Thanks for your effort!@beberlei commented on GitHub (Mar 15, 2020):
Fixed in #8036