Details
Description
I have 2 entities subclassing a "master" entity using single table inheritance:
HistoryItem:
createdAt datetime
PhotoHistoryItem extends HistoryItem
photo: (foreign key to Photo entity)
CommentHistoryItem extends HistoryItem
comment: (foreign key to Comment entity)
I want to select all of them using the following DQL:
SELECT p, c FROM ProFolioBundle:PhotoHistoryItem p, ProFolioBundle:CommentHistoryItem c LEFT JOIN p.photo LEFT JOIN c.comment
But the generated SQL has an error in the final AND syntax (it generates "AND AND"):
SELECT h0_.id AS id0, h0_.createdAt AS createdAt1, h1_.id AS id2, h1_.createdAt AS createdAt3, h0_.type AS type4, h1_.type AS type5 FROM HistoryItem h0_, HistoryItem h1_ LEFT JOIN Photo p2_ ON h0_.photo_id = p2_.id INNER JOIN Comment c3_ ON h1_.comment_id = c3_.id WHERE (h0_.type IN ('photo') AND AND h1_.type IN ('comment')) LIMIT 20
The error MySQL throws is:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND h1_.type IN ('comment')) LIMIT 20' at line 1