Affects Version/s: 1.1.4
Fix Version/s: None
moved my ticket #1941 from trac
Let's consider an environment:
We have a table "Article" and another table "Tag". There is a many to many relation between those two tables via link table "TagArticle". Schema and fixtures provided in attachments. It is simple.
Now let's consider a situation:
We want to display a list of all articles with on of tags. But we want to display this list also with the rest of tags connected to articles with specified tag:
We want a list of all articles with "tag2" - so it will be Article1 and Article2, but the same query should also retrieve the rest of tags.
It is really simple to do with one-to-many relation: by just joining two tables with different aliases.
However, it is impossible now to do it with many-to-many relation, because Doctrine generates wrong table aliases in SQL.
Looks logical. But it throws an exception:
"Doctrine_Connection_Mysql_Exception" with message "SQLSTATE: Syntax error or access violation: 1066 Not unique table/alias: 't2'" in ...doctrine\lib\DoctrineConnection.php:1084
Let's look at our query:
As we can see, there is a duplicated alias on "tag_article".