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

Closed
doctrinebot opened this Issue Oct 25, 2011 · 5 comments

2 participants

@doctrinebot

Jira issue originally created by user gedrox:

When having unknown (not cached by UnitOfWork) joined inheritance entity with natural identifier (GENERATORTYPENONE), 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.

@doctrinebot

Comment created by gedrox:

Test case.

@doctrinebot

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

Comment created by @beberlei:

Fixed

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.1.3 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment