Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1454

SQL error when requesting state for unknown joined inheritance entity with natural identifier

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.2
    • Fix Version/s: 2.1.3
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      Ubuntu 11.10, PHP 5.3.6, MySQL 5.1.58

      Description

      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.

        Activity

        Hide
        Aigars Gedroics added a comment -

        Test case.

        Show
        Aigars Gedroics added a comment - Test case.
        Hide
        Aigars Gedroics added a comment -

        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 +1197,7 @@ class BasicEntityPersister
                     $conditionSql .= $conditionSql ? ' AND ' : '';
         
                     if (isset($this->_class->columnNames[$field])) {
        -                if (isset($this->_class->fieldMappings[$field]['inherited'])) {
        +                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) . '.';
        
        Show
        Aigars Gedroics added a comment - 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 +1197,7 @@ class BasicEntityPersister $conditionSql .= $conditionSql ? ' AND ' : ''; if (isset($ this ->_class->columnNames[$field])) { - if (isset($ this ->_class->fieldMappings[$field]['inherited'])) { + 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) . '.';
        Hide
        Benjamin Eberlei added a comment -

        Fixed

        Show
        Benjamin Eberlei added a comment - Fixed

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Aigars Gedroics
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: