Details
Description
Query builder creates bad DQL if multiple FROM and JOIN parts are used.
As example such query builder code
$qb->from('A', 'a')
->from('B', 'b')
->join('b.c', 'c')
->join('c.d', 'd');
will generate DQL
...
FROM A a
INNER JOIN c.d d,
B b
INNER JOIN b.c c
...
but should generate this instead
...
FROM A a,
B b
INNER JOIN b.c c
INNER JOIN c.d d
...
The DQL parser raises exception
Doctrine\ORM\Query\QueryException: [Semantical Error] line 0, col 61 near '.d d, B': Error: Identification Variable c used in join path expression but was not defined before.
Activity
Aigars Gedroics
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Description |
Query builder creates bad DQL if multiple FROM and JOIN parts are used. As example such query builder code {code} $qb->from('A', 'a') ->from('B', 'b') ->join('b.c', 'c') ->join('c.d', 'd'); {code} will generate DQL {code} ... FROM A a INNER JOIN c.d d, B b INNER JOIN b.c c ... {code} but should generate this instead {code} ... FROM A a, B b INNER JOIN b.c c INNER JOIN c.d d ... {code} The DQL parser raises exception {code} Doctrine\ORM\Query\QueryException: [Semantical Error] line 0, col 61 near '.d d, Supra\Tests\Doctrine\DDC2000B': Error: Identification Variable c used in join path expression but was not defined before. {code} |
Query builder creates bad DQL if multiple FROM and JOIN parts are used. As example such query builder code {code} $qb->from('A', 'a') ->from('B', 'b') ->join('b.c', 'c') ->join('c.d', 'd'); {code} will generate DQL {code} ... FROM A a INNER JOIN c.d d, B b INNER JOIN b.c c ... {code} but should generate this instead {code} ... FROM A a, B b INNER JOIN b.c c INNER JOIN c.d d ... {code} The DQL parser raises exception {code} Doctrine\ORM\Query\QueryException: [Semantical Error] line 0, col 61 near '.d d, B': Error: Identification Variable c used in join path expression but was not defined before. {code} |
Aigars Gedroics
made changes -
| Attachment | DDC1757Test.php [ 11176 ] |
Aigars Gedroics
made changes -
| Attachment | patch-1757.patch [ 11177 ] |
Benjamin Eberlei
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Fix Version/s | 2.3 [ 10185 ] | |
| Resolution | Fixed [ 1 ] |
Benjamin Eberlei
made changes -
| Workflow | jira [ 13596 ] | jira-feedback [ 15306 ] |
Benjamin Eberlei
made changes -
| Workflow | jira-feedback [ 15306 ] | jira-feedback2 [ 17170 ] |
Benjamin Eberlei
made changes -
| Workflow | jira-feedback2 [ 17170 ] | jira-feedback3 [ 19424 ] |
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-1757, expand=changesets[-21:-1].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)
The test case attached.
The problem is that for the relation c.d the query builder uses the first root entity as the master which makes it to be included before the join b.c.