<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Sat May 18 15:47:52 UTC 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/si/jira.issueviews:issue-xml/DDC-1770/DDC-1770.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://www.doctrine-project.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.7</version>
        <build-number>850</build-number>
        <build-date>21-02-2013</build-date>
    </build-info>

<item>
            <title>[DDC-1770] Select from multiple subclassed entities generates SQL syntax error</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-1770</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;I have 2 entities subclassing a &quot;master&quot; entity using single table inheritance:&lt;/p&gt;

&lt;p&gt;HistoryItem:&lt;br/&gt;
     createdAt  datetime&lt;/p&gt;

&lt;p&gt;PhotoHistoryItem extends HistoryItem&lt;br/&gt;
    photo: (foreign key to Photo entity)&lt;/p&gt;

&lt;p&gt;CommentHistoryItem extends HistoryItem&lt;br/&gt;
    comment: (foreign key to Comment entity)&lt;/p&gt;

&lt;p&gt;I want to select all of them using the following DQL:&lt;/p&gt;

&lt;p&gt;SELECT p, c FROM ProFolioBundle:PhotoHistoryItem p, ProFolioBundle:CommentHistoryItem c LEFT JOIN p.photo LEFT JOIN c.comment&lt;/p&gt;

&lt;p&gt;But the generated SQL has an error in the final AND syntax (it generates &quot;AND AND&quot;):&lt;/p&gt;

&lt;p&gt;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 (&apos;photo&apos;) AND AND h1_.type IN (&apos;comment&apos;)) LIMIT 20&lt;/p&gt;

&lt;p&gt;The error MySQL throws is:&lt;/p&gt;

&lt;p&gt;SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;42000&amp;#93;&lt;/span&gt;: 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 &apos;AND h1_.type IN (&apos;comment&apos;)) LIMIT 20&apos; at line 1 &lt;/p&gt;</description>
                <environment>Symfony 2.0.12&lt;br/&gt;
PHP 5.3.10&lt;br/&gt;
MySQL 5.1</environment>
            <key id="13616">DDC-1770</key>
            <summary>Select from multiple subclassed entities generates SQL syntax error</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/resolved.png">Resolved</status>
                    <resolution id="1">Fixed</resolution>
                    <security id="10000">All</security>
                        <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="nlaplante">Nicolas Laplante</reporter>
                        <labels>
                    </labels>
                <created>Thu, 5 Apr 2012 22:56:20 +0000</created>
                <updated>Sun, 27 May 2012 17:58:16 +0000</updated>
                    <resolved>Sun, 27 May 2012 17:58:16 +0000</resolved>
                            <version>2.1.6</version>
                                <fixVersion>2.1.7</fixVersion>
                                <component>DQL</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="17779" author="nlaplante" created="Thu, 5 Apr 2012 22:57:50 +0000"  >&lt;p&gt;Fix entity names&lt;/p&gt;</comment>
                    <comment id="17856" author="fabio.bat.silva" created="Tue, 17 Apr 2012 01:56:22 +0000"  >&lt;p&gt;Hi Nicolas&lt;/p&gt;

&lt;p&gt;Could you attach your entities please ?&lt;/p&gt;</comment>
                    <comment id="17857" author="nlaplante" created="Tue, 17 Apr 2012 03:03:48 +0000"  >&lt;p&gt;Sure, here are the 3 entities&lt;/p&gt;</comment>
                    <comment id="17858" author="nlaplante" created="Tue, 17 Apr 2012 03:06:45 +0000"  >&lt;p&gt;Here are the referenced entities in case you need them too&lt;/p&gt;</comment>
                    <comment id="18017" author="beberlei" created="Sun, 27 May 2012 17:58:16 +0000"  >&lt;p&gt;Fixed&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="11183" name="Comment.php" size="4901" author="nlaplante" created="Tue, 17 Apr 2012 03:06:45 +0000" />
                    <attachment id="11180" name="CommentHistoryItem.php" size="911" author="nlaplante" created="Tue, 17 Apr 2012 03:03:48 +0000" />
                    <attachment id="11179" name="HistoryItem.php" size="1485" author="nlaplante" created="Tue, 17 Apr 2012 03:03:48 +0000" />
                    <attachment id="11182" name="Photo.php" size="10332" author="nlaplante" created="Tue, 17 Apr 2012 03:06:45 +0000" />
                    <attachment id="11181" name="PhotoHistoryItem.php" size="882" author="nlaplante" created="Tue, 17 Apr 2012 03:03:48 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>