<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Tue Jun 18 05:52:07 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-1256/DDC-1256.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-1256] Generated SQL error with DQL WITH and JOINED inheritance</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-1256</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;I&apos;ve created an entity that has a one to one relationship to a class in an inheritance tree and I&apos;m using class table inheritance in Doctrine. When I try to add a DQL WITH statement on a column in the super class to the join, the generated SQL incorrectly places the statement in the child classes JOIN ON section.&lt;/p&gt;

&lt;p&gt;Here&apos;s the DQL:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
SELECT p FROM Fampus_Entity_Photo p LEFT JOIN p.flag f WITH f.status=&apos;ok&apos;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here&apos;s the generated SQL:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
SELECT p0_.id AS id0, p0_.name AS name1, p0_.path AS path2, p0_.type AS type3, p0_.reference_id AS reference_id4, p0_.view_count AS view_count5, p0_.created AS created6, p0_.modified AS modified7, p0_.event_id AS event_id8, p0_.user_id AS user_id9, p0_.school_id AS school_id10, p0_.flag_id AS flag_id11 FROM photos p0_ LEFT JOIN flaggedcontent_photo f1_ ON p0_.flag_id = f1_.id AND (f2_.status = &apos;ok&apos;) LEFT JOIN flaggedcontent f2_ ON f1_.id = f2_.id
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Note that f2_.status = &apos;ok&apos; is the correct statement, but it is in the wrong LEFT JOIN ON section.&lt;/p&gt;

&lt;p&gt;Here are my entities (significantly clipped):&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
/**
 * @Table(name=&lt;span class=&quot;code-quote&quot;&gt;&quot;photos&quot;&lt;/span&gt;)
*/
class Photo {
    /**
     * @OneToOne(targetEntity=&lt;span class=&quot;code-quote&quot;&gt;&quot;FlaggedContent_Photo&quot;&lt;/span&gt;, mappedBy=&lt;span class=&quot;code-quote&quot;&gt;&quot;photo&quot;&lt;/span&gt;)
     * @JoinColumn(nullable=&lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;)
     */
    &lt;span class=&quot;code-keyword&quot;&gt;protected&lt;/span&gt; $flag;
}

/**
 * @DiscriminatorColumn(name=&lt;span class=&quot;code-quote&quot;&gt;&quot;type&quot;&lt;/span&gt;)
 * @DiscriminatorMap({
 *     &lt;span class=&quot;code-quote&quot;&gt;&quot;photo&quot;&lt;/span&gt; = &lt;span class=&quot;code-quote&quot;&gt;&quot;FlaggedContent_Photo&quot;&lt;/span&gt;
 * })
 * @InheritanceType(&lt;span class=&quot;code-quote&quot;&gt;&quot;JOINED&quot;&lt;/span&gt;)
 * @Table(name=&lt;span class=&quot;code-quote&quot;&gt;&quot;flaggedcontent&quot;&lt;/span&gt;)
*/
&lt;span class=&quot;code-keyword&quot;&gt;abstract&lt;/span&gt; class FlaggedContent {
    /**
     * Database identifier
     *
     * @Id
     * @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;integer&quot;&lt;/span&gt;)
     * @GeneratedValue(strategy=&lt;span class=&quot;code-quote&quot;&gt;&quot;AUTO&quot;&lt;/span&gt;)
     */
    &lt;span class=&quot;code-keyword&quot;&gt;protected&lt;/span&gt; $id;

    /**
     * Status
     *
     * @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;text&quot;&lt;/span&gt;)
     * @&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt; string
     */
    &lt;span class=&quot;code-keyword&quot;&gt;protected&lt;/span&gt; $status;
}

/**
 * @Entity
 * @Table(name=&lt;span class=&quot;code-quote&quot;&gt;&quot;flaggedcontent_photo&quot;&lt;/span&gt;)
 */
class FlaggedContent_Photo &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; FlaggedContent {
    /**
     * @OneToOne(targetEntity=&lt;span class=&quot;code-quote&quot;&gt;&quot;Photo&quot;&lt;/span&gt;, inversedBy=&lt;span class=&quot;code-quote&quot;&gt;&quot;flag&quot;&lt;/span&gt;)
     */
    &lt;span class=&quot;code-keyword&quot;&gt;protected&lt;/span&gt; $photo;
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment>Ubuntu 11.04</environment>
            <key id="12797">DDC-1256</key>
            <summary>Generated SQL error with DQL WITH and JOINED inheritance</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/minor.png">Minor</priority>
                    <status id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/resolved.png">Resolved</status>
                    <resolution id="3">Duplicate</resolution>
                    <security id="10000">All</security>
                        <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="toxygene">Justin Hendrickson</reporter>
                        <labels>
                    </labels>
                <created>Wed, 6 Jul 2011 19:01:28 +0000</created>
                <updated>Wed, 1 May 2013 18:46:53 +0000</updated>
                    <resolved>Wed, 1 May 2013 18:46:35 +0000</resolved>
                            <version>2.0.3</version>
                <version>2.3</version>
                                                <component>DQL</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="16123" author="mridgway" created="Wed, 6 Jul 2011 20:18:42 +0000"  >&lt;p&gt;I created a test for this: &lt;a href=&quot;https://github.com/mridgway/doctrine2/commit/1bb26a46188f180270d723e395ee707443ebdda1&quot; class=&quot;external-link&quot;&gt;https://github.com/mridgway/doctrine2/commit/1bb26a46188f180270d723e395ee707443ebdda1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I&apos;ll see if I can figure this out.&lt;/p&gt;</comment>
                    <comment id="16145" author="mridgway" created="Mon, 11 Jul 2011 15:36:32 +0000"  >&lt;p&gt;It doesn&apos;t seem that you would get the correct result if the WITH statement was on the &apos;flaggedcontent&apos; table anyway. In order for this to work, the query would have to join &apos;flaggedcontent&apos; first and then join to &apos;flaggedcontent_photo&apos; based on f2_.id.  While we can probably (but not easily) fix where the condition is placed, I don&apos;t think this will ever be able to give the expected results for ALL cases.&lt;/p&gt;</comment>
                    <comment id="16151" author="beberlei" created="Tue, 12 Jul 2011 20:19:16 +0000"  >&lt;p&gt;Formatting&lt;/p&gt;</comment>
                    <comment id="16152" author="beberlei" created="Tue, 12 Jul 2011 20:20:43 +0000"  >&lt;p&gt;This issue is unfixable, we tend towards throwing an exception in this case to notify developers that they cannot do this.&lt;/p&gt;

&lt;p&gt;The only way to make it work is to move the status check to the WHERE clause.&lt;/p&gt;</comment>
                    <comment id="16327" author="guilhermeblanco" created="Sun, 14 Aug 2011 03:59:03 +0000"  >&lt;p&gt;This issue is fixable by applying what we call as nested joins when generating the SQL.&lt;/p&gt;

&lt;p&gt;This issue report #&lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-349&quot; title=&quot;Add support for specifying precedence in joins in DQL&quot;&gt;DDC-349&lt;/a&gt; (&lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-349&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/jira/browse/DDC-349&lt;/a&gt;) suggest us to support it in DQL, but I think we can introduce this generation on SQL only.&lt;br/&gt;
It&apos;s not a trivial implementation, but it would solve a couple of other issue I was looking into.&lt;/p&gt;

&lt;p&gt;Cheers,&lt;/p&gt;</comment>
                    <comment id="20179" author="beberlei" created="Wed, 1 May 2013 18:46:35 +0000"  >&lt;p&gt;Duplicate of &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-349&quot; title=&quot;Add support for specifying precedence in joins in DQL&quot;&gt;DDC-349&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                <issuelinks>
                        <issuelinktype id="10000">
                <name>Duplicate</name>
                                <outwardlinks description="duplicates">
                            <issuelink>
            <issuekey id="10915">DDC-349</issuekey>
        </issuelink>
                    </outwardlinks>
                                                <inwardlinks description="is duplicated by">
                            <issuelink>
            <issuekey id="14202">DDC-2131</issuekey>
        </issuelink>
                    </inwardlinks>
                            </issuelinktype>
                    </issuelinks>
                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>