[PR #8329] Fix SQL alias generation regression for simple inheritance #10921

Open
opened 2026-01-22 16:09:07 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/8329

State: closed
Merged: Yes


As asked by @ostrolucky in the #8229 issue - I'm created a PR trying to fix a edge case of what I think may be a regression in the effort of supporting Joined table inheritance with AttributeOverride.

Context:

  • Entity1 extends Entity0 through ResolveTargetEntities mecanism
  • Entity1 has all its fieldsMapping marked as inherited=true
  • Entity1 inheritanceType is ClassMetadata::INHERITANCE_TYPE_NONE
  • Some code calls $entityManager->getRepository($entity1)->findOneBy()
  • The SQL generated in the where part of the query has a bad alias because it uses Entity0 as classname for getSQLTableAlias call in BasicEntityPersister::getSelectConditionStatementSQL method
  • The query crash

Proposal:
Excluding INHERITANCE_TYPE_NONE entities to use inherited classname as parameter for getSQLTableAlias generation in BasicEntityPersister::getSelectConditionStatementSQL

As said in original comment, I'm really not sure of what I'm doing, I'm new to doctrine 2

Referenced Issue comments: https://github.com/doctrine/orm/issues/8229#issuecomment-722942180

**Original Pull Request:** https://github.com/doctrine/orm/pull/8329 **State:** closed **Merged:** Yes --- As asked by @ostrolucky in the #8229 issue - I'm created a PR trying to fix a edge case of what I think may be a regression in the effort of supporting Joined table inheritance with AttributeOverride. Context: - Entity1 extends Entity0 through ResolveTargetEntities mecanism - Entity1 has all its fieldsMapping marked as inherited=true - Entity1 inheritanceType is ClassMetadata::INHERITANCE_TYPE_NONE - Some code calls $entityManager->getRepository($entity1)->findOneBy() - The SQL generated in the where part of the query has a bad alias because it uses Entity0 as classname for getSQLTableAlias call in BasicEntityPersister::getSelectConditionStatementSQL method - The query crash Proposal: Excluding INHERITANCE_TYPE_NONE entities to use inherited classname as parameter for getSQLTableAlias generation in BasicEntityPersister::getSelectConditionStatementSQL As said in original comment, I'm really not sure of what I'm doing, I'm new to doctrine 2 Referenced Issue comments: https://github.com/doctrine/orm/issues/8229#issuecomment-722942180
admin added the pull-request label 2026-01-22 16:09:07 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#10921