Details
Description
If an entity has a foreign key as part of its primary key and you try to query that entity in a subselect clause in DQL, an exception is thrown in ClassMetadataInfo->getQuotedColumnName. The problem seems to be that it's only considering the field mappings rather than both the field and association mappings when it's looking for the correct column name.
Example entities:
- Article(id primary key, title, content)
- ArticleTag(article_id, tag, primary key (article_id, tag))
Example DQL: select art from Article art where exists (select tag from ArticleTag tag where tag.article = art)
Activity
Benjamin Eberlei
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Assignee | Benjamin Eberlei [ beberlei ] | Guilherme Blanco [ guilhermeblanco ] |
Guilherme Blanco
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Fix Version/s | 2.2-DEV [ 10157 ] | |
| Resolution | Fixed [ 1 ] |
Benjamin Eberlei
made changes -
| Fix Version/s | 2.1.3 [ 10164 ] | |
| Fix Version/s | 2.2-DEV [ 10157 ] |
Benjamin Eberlei
made changes -
| Workflow | jira [ 13100 ] | jira-feedback [ 15072 ] |
Benjamin Eberlei
made changes -
| Workflow | jira-feedback [ 15072 ] | jira-feedback2 [ 16936 ] |
Benjamin Eberlei
made changes -
| Workflow | jira-feedback2 [ 16936 ] | jira-feedback3 [ 19189 ] |
This list may be incomplete, as errors occurred whilst retrieving source from linked applications:
- Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-1435, expand=changesets[-21:-1].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)
Verified:
/** * @group DDC-1435 */ public function testForeignKeyAsPrimaryKeySubselect() { $this->assertSqlGeneration( "SELECT s FROM Doctrine\Tests\Models\DDC117\DDC117Article s WHERE EXISTS (SELECT r FROM Doctrine\Tests\Models\DDC117\DDC117Reference r WHERE r.source = s)", "" ); }This however is not possible anyways, since you cannot have "r" in a SimpleSelectExpression when it resolves to multiple columns. You can try to select just one arbitrary field, for example."SELECT r.foobar FROM .."