Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-695

throw error on non-existing relation target column

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.0-BETA2
    • Fix Version/s: 2.0-BETA4
    • Component/s: DQL
    • Security Level: All
    • Labels:
      None
    • Environment:
      any

      Description

      I had a problem with invalid SQL generated from DQL using JOIN the DQL query was as simple as:

      SELECT k, kt FROM Kmz k JOIN k.kmzType kt

      the final SQL missed the joined column name:

      SELECT k0_.ID_KMZ AS ID_KMZ0, k0_.ID_KMZ_TYPE AS ID_KMZ_TYPE1, k0_.IDENTIFICATOR_HW AS IDENTIFICATOR_HW2, k0_.TIME_INSERT AS TIME_INSERT3, k1_.ID_KMZ_TYPE AS ID_KMZ_TYPE4, k1_.SHORTNAME AS SHORTNAME5, k1_.DESCRIPTION AS DESCRIPTION6, k0_.id_KMZ_TYPE AS id_KMZ_TYPE7 FROM KMZ k0_ INNER JOIN KMZ_TYPE k1_ ON k0_.id_KMZ_TYPE = k1_.

      After some time of xdebugging I found that the names in JoinColumn clause in Kmz class annotation were not UPPERCASE as in KmzType - I just got a notice in SQL walker (line 728).

      if ($relation->isOwningSide)

      { $quotedTargetColumn = $targetClass->getQuotedColumnName($targetClass->fieldNames[$targetColumn], $this->_platform); // <-- PHP Notice: Undefined index: id_KMZ_TYPE in .../libs/Doctrine/ORM/Query/SqlWalker.php:728 $sql .= $sourceTableAlias . '.' . $sourceColumn . ' = ' . $targetTableAlias . '.' . $quotedTargetColumn; }

      else

      { $quotedTargetColumn = $sourceClass->getQuotedColumnName($sourceClass->fieldNames[$targetColumn], $this->_platform); $sql .= $sourceTableAlias . '.' . $quotedTargetColumn . ' = ' . $targetTableAlias . '.' . $sourceColumn; }

      I think there might be a check and error thrown in case of missing targetColumn.

        Activity

        Hide
        Guilherme Blanco added a comment -

        This is not related to DQL.

        We have a validate-mapping CLI command that can verify this for you.
        The problem you have is a bug in your mapping definition, nothing related to Doctrine core.

        If we add exceptions to all situations, DQL could not perform well. =\

        Marking as won't fix.

        Show
        Guilherme Blanco added a comment - This is not related to DQL. We have a validate-mapping CLI command that can verify this for you. The problem you have is a bug in your mapping definition, nothing related to Doctrine core. If we add exceptions to all situations, DQL could not perform well. =\ Marking as won't fix.

          People

          • Assignee:
            Roman S. Borschel
            Reporter:
            Martin Ivičič
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: