[DDC-2046] QueryBuilder allows joining with the same alias multiple times Created: 27/Sep/12  Updated: 23/Jan/13  Resolved: 23/Jan/13

Status: Closed
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Minor
Reporter: Marco Pivetta Assignee: Marco Pivetta
Resolution: Won't Fix Votes: 0
Labels: None

Attachments: File DDC2046Test.php    


Currently, QueryBuilder allows assembling broken DQL like

SELECT u FROM User u JOIN u.posts p JOIN u.logs p


SELECT u FROM User u JOIN u.posts u

It may be interesting if we either replace DQL parts by associating them to their alias.

Another solution, since Alexander noted that it is a dumb string builder, is to throw exceptions early to disallow broken DQL generation (such as in the second case).

It may also be useful to allow giving insights about the currently existing joined aliases.

public function hasJoinedAlias($alias);

Comment by Marco Pivetta [ 27/Sep/12 ]

Attaching failing test case

Comment by Marco Pivetta [ 23/Jan/13 ]

The query builder should not worry about validity of produced DQL

Generated at Tue Oct 06 16:15:01 EDT 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.