mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-1161: DQL generate duplicate SQL Alias with CTI + oneToOne self referencing #1456
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (May 20, 2011).
Originally assigned to: @guilhermeblanco on GitHub.
Jira issue originally created by user nico_b:
Hi,
I have a Entity "Content" whith several childs entities like "Page" , "Article" in Joined inheritance.
I make DQL directly on entity "Content", that work perfectly with the discriminator map for return/delete/update appropriates objects.
I use "Page" or "Article" entity only for make a new object and persist.
But now I have add a oneToOne self relation in "Content" :
Content#parent_id => Content#id , no cascade.
And now every DQL return :
SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: XX
And yes I see in generated SQL that Content's alias is not unique :
For DQL : SELECT c FROM Content WHERE c.status = 1
SQL Result :
=> SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'n0_'
But if I use getRepository like this :
$em->getRepository('Content')->findBy(array('status'=>1));
It works, and return appropriates objects.
And I can see that "Content" have several unique alias in the SQL query :
Regards,
@doctrinebot commented on GitHub (Jun 5, 2011):
Comment created by @beberlei:
Fixed formatting.
@doctrinebot commented on GitHub (Jun 5, 2011):
Comment created by @beberlei:
Can you upload the mapping files and php code? This looks very weird and i dont know where to start debugging from your description.
@doctrinebot commented on GitHub (Jun 6, 2011):
Comment created by nico_b:
Done, Mapping and Entities (simplified).
I have a little question, how we can acces to the discriminator map in a DQL query or Entity's object ? Because we cannot mappe this field.
@doctrinebot commented on GitHub (Oct 16, 2011):
Comment created by @guilhermeblanco:
Hi Nicholas,
In 2.2-DEV this issue seems to be addressed already.
We did an internal refactoring (that leads us to not merge into 2.1) that addressed this issue.
I added coverage to your issue with this commit and it works nicely:
33bcf7ad6fMarking the ticket as fixed in 2.2
@doctrinebot commented on GitHub (Oct 16, 2011):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Dec 13, 2015):
Imported 2 attachments from Jira into https://gist.github.com/125e146e07f067cf1614