DDC-1454: SQL error when requesting state for unknown joined inheritance entity with natural identifier #1824

Closed
opened 2026-01-22 13:27:13 +01:00 by admin · 5 comments
Owner

Originally created by @doctrinebot on GitHub (Oct 25, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user gedrox:

When having unknown (not cached by UnitOfWork) joined inheritance entity with natural identifier (GENERATOR_TYPE_NONE), method UnitOfWork::getEntityState() fails with SQL error:

Column not found: 1054 Unknown column 't1.file_id' in 'where clause'

Will attach testcase right after creating the issue.

Originally created by @doctrinebot on GitHub (Oct 25, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user gedrox: When having unknown (not cached by UnitOfWork) joined inheritance entity with natural identifier (GENERATOR_TYPE_NONE), method UnitOfWork::getEntityState() fails with SQL error: ``` Column not found: 1054 Unknown column 't1.file_id' in 'where clause' ``` Will attach testcase right after creating the issue.
admin added the Bug label 2026-01-22 13:27:13 +01:00
admin closed this issue 2026-01-22 13:27:13 +01:00
Author
Owner

@doctrinebot commented on GitHub (Oct 25, 2011):

Comment created by gedrox:

Test case.

@doctrinebot commented on GitHub (Oct 25, 2011): Comment created by gedrox: Test case.
Author
Owner

@doctrinebot commented on GitHub (Oct 26, 2011):

Comment created by gedrox:

Possible change diff for file Doctrine/ORM/Persisters/BasicEntityPersister.php from Doctrine ORM 2.1.2.

Idea is to use the main table (not inherited one) if the column is a part of ID. So, I guess, it will be in both tables.

@@ -1197,7 <ins>1197,7 @@ class BasicEntityPersister
             $conditionSql .= $conditionSql ? ' AND ' : '';

             if (isset($this->_class->columnNames[$field])) {
-                if (isset($this->_class->fieldMappings[$field]['inherited'])) {
</ins>                if (isset($this->*class->fieldMappings[$field]['inherited']) && empty($this->*class->fieldMappings[$field]['id'])) {
                     $conditionSql .= $this->*getSQLTableAlias($this->*class->fieldMappings[$field]['inherited']) . '.';
                 } else {
                     $conditionSql .= $this->*getSQLTableAlias($this->*class->name) . '.';
@doctrinebot commented on GitHub (Oct 26, 2011): Comment created by gedrox: Possible change diff for file Doctrine/ORM/Persisters/BasicEntityPersister.php from Doctrine ORM 2.1.2. Idea is to use the main table (not inherited one) if the column is a part of ID. So, I guess, it will be in both tables. ``` @@ -1197,7 <ins>1197,7 @@ class BasicEntityPersister $conditionSql .= $conditionSql ? ' AND ' : ''; if (isset($this->_class->columnNames[$field])) { - if (isset($this->_class->fieldMappings[$field]['inherited'])) { </ins> if (isset($this->*class->fieldMappings[$field]['inherited']) && empty($this->*class->fieldMappings[$field]['id'])) { $conditionSql .= $this->*getSQLTableAlias($this->*class->fieldMappings[$field]['inherited']) . '.'; } else { $conditionSql .= $this->*getSQLTableAlias($this->*class->name) . '.'; ```
Author
Owner

@doctrinebot commented on GitHub (Oct 27, 2011):

Comment created by @beberlei:

Fixed

@doctrinebot commented on GitHub (Oct 27, 2011): Comment created by @beberlei: Fixed
Author
Owner

@doctrinebot commented on GitHub (Oct 27, 2011):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Oct 27, 2011): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/9dce97f7e9423d16194e

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/9dce97f7e9423d16194e - [11090_DDC1454Test.php](https://gist.github.com/9dce97f7e9423d16194e#file-11090_DDC1454Test-php)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1824