mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-1166: Undefined index when using INSTANCE OF operator and inheritance #1464
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 @doctrinebot on GitHub (May 23, 2011).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user comfortablynumb:
Hi,
Having a class tree like this:
. Element
. Activity (JOINED)
. ActivityMail (SINGLE)
. ActivityPhoneCall (SINGLE)
. ActivityXXX (SINGLE)
. OtherEntity
Doing a query similar to:
"SELECT element FROM Model\Element element WHERE element INSTANCE OF Model\ActivityMail"
I receive:
PHP Notice: Undefined index: Model\ActivityMail in /var/www/gestion/vendor/doctrine/lib/Doctrine/ORM/Query/SqlWalker.php on line 1683
But no error. And it doesn't return instances of ActivityMail. Even if I do:
"SELECT element FROM Model\Element element WHERE element INSTANCE OF Model\Activity"
It doesn't throw the notice, but it doesn't return any results either.
Thanks in advance.
@doctrinebot commented on GitHub (May 23, 2011):
Comment created by comfortablynumb:
I realized that what I thought it was a SINGLE inheritance, it's really a JOINED inheritance. And I had two inheritance mapping configurations in both, Element and Activity entities. So I had:
. Element (JOINED)
. Activity (JOINED - I had annotations for this too. THAT was the problem)
. Email
. Fax
. OtherEntity
Having only mapped inheritance on Element entity works like a charm. I tried to use SINGLE inheritance on Activity first sometime ago, and then I realized that it doesn't work. So I changed it to JOINED and it worked. But I didn't realized that I didn't need to map again the JOINED inheritance for the Activity's children.
Looking at this issue, is there a chance to add an exception when a user, like me, tries to map an inheritance tree twice, or when he/she tries to map two different types of inheritance in the same class tree? it could avoid this types of issues.
@doctrinebot commented on GitHub (May 23, 2011):
Issue was closed with resolution "Invalid"