Skip to content

Loading…

DDC-695: throw error on non-existing relation target column #5206

Closed
doctrinebot opened this Issue · 2 comments

1 participant

@doctrinebot

Jira issue originally created by user cicovec:

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.

@doctrinebot

Comment created by @guilhermeblanco:

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.

@doctrinebot

Issue was closed with resolution "Won't Fix"

@doctrinebot doctrinebot added this to the 2.0-BETA4 milestone
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.