Querying abstract class in the middle of a hierarchy returns NULL instead of objects #5879

Closed
opened 2026-01-22 15:21:05 +01:00 by admin · 5 comments
Owner

Originally created by @BenMorel on GitHub (Feb 12, 2018).

Originally assigned to: @lcobucci on GitHub.

I have the following entity hierarchy:

  • (A)
    • B
    • (C)
      • D
      • E

Abstract classes are in parentheses.

When querying entities of class A, B, D or E, everything works fine.
When querying entities of class C however, Doctrine 2.6.0 returns null instead of the entity object.

I created a test case here:
https://github.com/BenMorel/doctrine-abstract-entity-bug

The script creates 3 concrete entities of classes B, D and E, then queries every class of the hierarchy.
Doctrine 2.5.14 returns the correct result:

Bug\A:
    Bug\E
    Bug\D
    Bug\B
Bug\B:
    Bug\B
Bug\C:
    Bug\E
    Bug\D
Bug\D:
    Bug\D
Bug\E:
    Bug\E

Doctrine 2.6.0, however, fails here:

Bug\A:
    Bug\E
    Bug\D
    Bug\B
Bug\B:
    Bug\B
Bug\C:
    NULL          <!>
    NULL          <!>
Bug\D:
    Bug\D
Bug\E:
    Bug\E

As you can see, querying entities of class Bug\C returns NULL and NULL, instead of Bug\D and Bug\E as expected.

Originally created by @BenMorel on GitHub (Feb 12, 2018). Originally assigned to: @lcobucci on GitHub. I have the following entity hierarchy: - (A) - **B** - (C) - **D** - **E** Abstract classes are in parentheses. When querying entities of class `A`, `B`, `D` or `E`, everything works fine. When querying entities of class `C` however, Doctrine `2.6.0` returns `null` instead of the entity object. I created a test case here: https://github.com/BenMorel/doctrine-abstract-entity-bug The script creates 3 concrete entities of classes `B`, `D` and `E`, then queries every class of the hierarchy. Doctrine `2.5.14` returns the correct result: ``` Bug\A: Bug\E Bug\D Bug\B Bug\B: Bug\B Bug\C: Bug\E Bug\D Bug\D: Bug\D Bug\E: Bug\E ``` Doctrine `2.6.0`, however, fails here: ``` Bug\A: Bug\E Bug\D Bug\B Bug\B: Bug\B Bug\C: NULL <!> NULL <!> Bug\D: Bug\D Bug\E: Bug\E ``` As you can see, querying entities of class `Bug\C` returns `NULL` and `NULL`, instead of `Bug\D` and `Bug\E` as expected.
admin added the BugRegression labels 2026-01-22 15:21:05 +01:00
admin closed this issue 2026-01-22 15:21:05 +01:00
Author
Owner

@BenMorel commented on GitHub (Feb 12, 2018):

Might be related to #6988, #6937, #7050.

@BenMorel commented on GitHub (Feb 12, 2018): Might be related to #6988, #6937, #7050.
Author
Owner

@IljaN commented on GitHub (Feb 17, 2018):

Also seeing same issue with inheritance type joined

@IljaN commented on GitHub (Feb 17, 2018): Also seeing same issue with inheritance type joined
Author
Owner

@lcobucci commented on GitHub (Feb 18, 2018):

@BenMorel can you please check if #6988 fixes it?

@lcobucci commented on GitHub (Feb 18, 2018): @BenMorel can you please check if #6988 fixes it?
Author
Owner

@BenMorel commented on GitHub (Feb 19, 2018):

@lcobucci It works with #6988 ! 👍

@BenMorel commented on GitHub (Feb 19, 2018): @lcobucci It works with #6988 ! 👍
Author
Owner

@Ocramius commented on GitHub (Feb 19, 2018):

Handled in #6988

@Ocramius commented on GitHub (Feb 19, 2018): Handled in #6988
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5879