{"action":"created","issue":{"url":"https://api.github.com/repos/doctrine/doctrine2/issues/2422","labels_url":"https://api.github.com/repos/doctrine/doctrine2/issues/2422/labels{/name}","comments_url":"https://api.github.com/repos/doctrine/doctrine2/issues/2422/comments","events_url":"https://api.github.com/repos/doctrine/doctrine2/issues/2422/events","html_url":"https://github.com/doctrine/doctrine2/issues/2422","id":120667111,"number":2422,"title":"DDC-1770: Select from multiple subclassed entities generates SQL syntax error","user":{"login":"doctrinebot","id":2414358,"avatar_url":"https://avatars.githubusercontent.com/u/2414358?v=3","gravatar_id":"","url":"https://api.github.com/users/doctrinebot","html_url":"https://github.com/doctrinebot","followers_url":"https://api.github.com/users/doctrinebot/followers","following_url":"https://api.github.com/users/doctrinebot/following{/other_user}","gists_url":"https://api.github.com/users/doctrinebot/gists{/gist_id}","starred_url":"https://api.github.com/users/doctrinebot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doctrinebot/subscriptions","organizations_url":"https://api.github.com/users/doctrinebot/orgs","repos_url":"https://api.github.com/users/doctrinebot/repos","events_url":"https://api.github.com/users/doctrinebot/events{/privacy}","received_events_url":"https://api.github.com/users/doctrinebot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/doctrine/doctrine2/labels/Bug","name":"Bug","color":"e11d21"}],"state":"closed","locked":false,"assignee":{"login":"beberlei","id":26936,"avatar_url":"https://avatars.githubusercontent.com/u/26936?v=3","gravatar_id":"","url":"https://api.github.com/users/beberlei","html_url":"https://github.com/beberlei","followers_url":"https://api.github.com/users/beberlei/followers","following_url":"https://api.github.com/users/beberlei/following{/other_user}","gists_url":"https://api.github.com/users/beberlei/gists{/gist_id}","starred_url":"https://api.github.com/users/beberlei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beberlei/subscriptions","organizations_url":"https://api.github.com/users/beberlei/orgs","repos_url":"https://api.github.com/users/beberlei/repos","events_url":"https://api.github.com/users/beberlei/events{/privacy}","received_events_url":"https://api.github.com/users/beberlei/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/doctrine/doctrine2/milestones/29","html_url":"https://github.com/doctrine/doctrine2/milestones/2.1.7","labels_url":"https://api.github.com/repos/doctrine/doctrine2/milestones/29/labels","id":1446300,"number":29,"title":"2.1.7","description":null,"creator":{"login":"beberlei","id":26936,"avatar_url":"https://avatars.githubusercontent.com/u/26936?v=3","gravatar_id":"","url":"https://api.github.com/users/beberlei","html_url":"https://github.com/beberlei","followers_url":"https://api.github.com/users/beberlei/followers","following_url":"https://api.github.com/users/beberlei/following{/other_user}","gists_url":"https://api.github.com/users/beberlei/gists{/gist_id}","starred_url":"https://api.github.com/users/beberlei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beberlei/subscriptions","organizations_url":"https://api.github.com/users/beberlei/orgs","repos_url":"https://api.github.com/users/beberlei/repos","events_url":"https://api.github.com/users/beberlei/events{/privacy}","received_events_url":"https://api.github.com/users/beberlei/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":14,"state":"closed","created_at":"2015-12-06T13:21:12Z","updated_at":"2015-12-06T22:53:34Z","due_on":"2012-05-28T23:59:59Z","closed_at":"2015-12-06T13:21:12Z"},"comments":7,"created_at":"2012-04-05T22:56:20Z","updated_at":"2015-12-13T18:40:07Z","closed_at":"2015-12-06T22:52:11Z","body":"Jira issue originally created by user nlaplante:\n\nI have 2 entities subclassing a \"master\" entity using single table inheritance:\n\nHistoryItem:\n     createdAt  datetime\n\nPhotoHistoryItem extends HistoryItem\n    photo: (foreign key to Photo entity)\n\nCommentHistoryItem extends HistoryItem\n    comment: (foreign key to Comment entity)\n\nI want to select all of them using the following DQL:\n\nSELECT p, c FROM ProFolioBundle:PhotoHistoryItem p, ProFolioBundle:CommentHistoryItem c LEFT JOIN p.photo LEFT JOIN c.comment\n\nBut the generated SQL has an error in the final AND syntax (it generates \"AND AND\"):\n\nSELECT 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\n\nThe error MySQL throws is:\n\nSQLSTATE[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 "},"comment":{"url":"https://api.github.com/repos/doctrine/doctrine2/issues/comments/164286678","html_url":"https://github.com/doctrine/doctrine2/issues/2422#issuecomment-164286678","issue_url":"https://api.github.com/repos/doctrine/doctrine2/issues/2422","id":164286678,"user":{"login":"doctrinebot","id":2414358,"avatar_url":"https://avatars.githubusercontent.com/u/2414358?v=3","gravatar_id":"","url":"https://api.github.com/users/doctrinebot","html_url":"https://github.com/doctrinebot","followers_url":"https://api.github.com/users/doctrinebot/followers","following_url":"https://api.github.com/users/doctrinebot/following{/other_user}","gists_url":"https://api.github.com/users/doctrinebot/gists{/gist_id}","starred_url":"https://api.github.com/users/doctrinebot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doctrinebot/subscriptions","organizations_url":"https://api.github.com/users/doctrinebot/orgs","repos_url":"https://api.github.com/users/doctrinebot/repos","events_url":"https://api.github.com/users/doctrinebot/events{/privacy}","received_events_url":"https://api.github.com/users/doctrinebot/received_events","type":"User","site_admin":false},"created_at":"2015-12-13T18:40:07Z","updated_at":"2015-12-13T18:40:07Z","body":"Imported 5 attachments from Jira into https://gist.github.com/235b849e75bca10370e6\n\n- [11179_HistoryItem.php](https://gist.github.com/235b849e75bca10370e6#file-11179_HistoryItem-php)\n- [11180_CommentHistoryItem.php](https://gist.github.com/235b849e75bca10370e6#file-11180_CommentHistoryItem-php)\n- [11181_PhotoHistoryItem.php](https://gist.github.com/235b849e75bca10370e6#file-11181_PhotoHistoryItem-php)\n- [11182_Photo.php](https://gist.github.com/235b849e75bca10370e6#file-11182_Photo-php)\n- [11183_Comment.php](https://gist.github.com/235b849e75bca10370e6#file-11183_Comment-php)\n"}}