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

Closed
opened 2026-01-22 12:52:47 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Jul 19, 2010).

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.

Originally created by @doctrinebot on GitHub (Jul 19, 2010). 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.
admin added the Improvement label 2026-01-22 12:52:47 +01:00
admin closed this issue 2026-01-22 12:52:47 +01:00
Author
Owner

@doctrinebot commented on GitHub (Aug 12, 2010):

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 commented on GitHub (Aug 12, 2010): 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.
Author
Owner

@doctrinebot commented on GitHub (Aug 12, 2010):

Issue was closed with resolution "Won't Fix"

@doctrinebot commented on GitHub (Aug 12, 2010): Issue was closed with resolution "Won't Fix"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#853