<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Wed Jun 19 12:13:04 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/DC-81/DC-81.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>[DC-81] Using WITH in combinations with LIMIT returns unexpected results</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-81</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When I try to limit left joined records with an additional WITH clause, it seems to be bugged when also specifying a LIMIT.&lt;/p&gt;

&lt;p&gt;My DQL:&lt;/p&gt;

&lt;p&gt;FROM Transporter t LEFT JOIN t.Profile p LEFT JOIN t.Requests r WITH (r.distributor_id = ?) WHERE t.is_active = ? ORDER BY p.company_country, p.company_name LIMIT 20&lt;/p&gt;

&lt;p&gt;This returns me 0 results, while removing the LIMIT (or the WITH) will return me 2 results.&lt;/p&gt;</description>
                <environment>Mac OS X 10.6.1</environment>
            <key id="10143">DC-81</key>
            <summary>Using WITH in combinations with LIMIT returns unexpected results</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="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/reopened.png">Reopened</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="gerryvdm">Gerry Vandermaesen</reporter>
                        <labels>
                    </labels>
                <created>Tue, 6 Oct 2009 07:59:08 +0000</created>
                <updated>Tue, 15 Jun 2010 10:15:33 +0000</updated>
                                    <version>1.2.0-ALPHA1</version>
                                                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="10420" author="jwage" created="Mon, 2 Nov 2009 22:35:55 +0000"  >&lt;p&gt;Sorry this is just not enough information to produce the problem. I ran some basic tests looking for what you pointed out but I didn&apos;t see any issues. Plus our tests cover this functionality so I imagine that if it were broke we&apos;d get some failures. However, I could be wrong so if you could re-open and provide a failing test case for us that would help with getting it fixed.&lt;/p&gt;</comment>
                    <comment id="12688" author="gerryvdm" created="Fri, 16 Apr 2010 05:27:46 +0000"  >&lt;p&gt;I actually ran into this problem once again in another problem.&lt;/p&gt;

&lt;p&gt;Schema:&lt;/p&gt;

&lt;p&gt;Story:&lt;br/&gt;
  columns:&lt;br/&gt;
    id:&lt;br/&gt;
      type: integer(4)&lt;br/&gt;
      unsigned: true&lt;br/&gt;
      primary: true&lt;br/&gt;
      autoincrement: true&lt;/p&gt;

&lt;p&gt;Picture:&lt;br/&gt;
  columns:&lt;br/&gt;
    id:&lt;br/&gt;
      type: integer(4)&lt;br/&gt;
      unsigned: true&lt;br/&gt;
      primary: true&lt;br/&gt;
      autoincrement: true&lt;br/&gt;
    story_id:&lt;br/&gt;
      type: integer(4)&lt;br/&gt;
      unsigned: true&lt;br/&gt;
      notnull: true&lt;br/&gt;
    is_selected:&lt;br/&gt;
      type: boolean&lt;br/&gt;
      notnull: true&lt;br/&gt;
      default: false&lt;br/&gt;
  relations:&lt;br/&gt;
    Story:&lt;br/&gt;
      foreignAlias: Pictures&lt;br/&gt;
      local: story_id&lt;br/&gt;
      foreign: id&lt;br/&gt;
      type: one&lt;br/&gt;
      foreignType: many&lt;br/&gt;
      onDelete: CASCADE&lt;/p&gt;

&lt;p&gt;Query:&lt;/p&gt;

&lt;p&gt;Doctrine_Query::create()&lt;br/&gt;
	-&amp;gt;from(&apos;Story s&apos;)&lt;br/&gt;
	-&amp;gt;leftJoin(&apos;s.Pictures p WITH p.is_selected = ?&apos;, true)&lt;br/&gt;
	-&amp;gt;where(&apos;s.id = ?&apos;, 5)&lt;br/&gt;
	-&amp;gt;limit(10);&lt;/p&gt;

&lt;p&gt;Outputted SQL:&lt;/p&gt;

&lt;p&gt;SELECT  &quot;s&quot;.&quot;id&quot; AS &quot;s_&lt;em&gt;id&quot;, &quot;s&quot;.&quot;first_name&quot; AS &quot;s&lt;/em&gt;&lt;em&gt;first_name&quot;, &quot;s&quot;.&quot;last_name&quot; AS  &quot;s&lt;/em&gt;&lt;em&gt;last_name&quot;, &quot;s&quot;.&quot;country&quot; AS  &quot;s&lt;/em&gt;&lt;em&gt;country&quot;, &quot;s&quot;.&quot;email&quot; AS &quot;s&lt;/em&gt;&lt;em&gt;email&quot;, &quot;s&quot;.&quot;content&quot; AS &quot;s&lt;/em&gt;&lt;em&gt;content&quot;, &quot;s&quot;.&quot;title&quot; AS &quot;s&lt;/em&gt;&lt;em&gt;title&quot;, &quot;s&quot;.&quot;summary&quot; AS &quot;s&lt;/em&gt;&lt;em&gt;summary&quot;, &quot;s&quot;.&quot;is_published&quot; AS  &quot;s&lt;/em&gt;&lt;em&gt;is_published&quot;, &quot;s&quot;.&quot;is_rejected&quot; AS  &quot;s&lt;/em&gt;&lt;em&gt;is_rejected&quot;, &quot;s&quot;.&quot;is_promoted&quot; AS  &quot;s&lt;/em&gt;&lt;em&gt;is_promoted&quot;, &quot;s&quot;.&quot;published_at&quot; AS  &quot;s&lt;/em&gt;&lt;em&gt;published_at&quot;, &quot;s&quot;.&quot;created_at&quot; AS  &quot;s&lt;/em&gt;&lt;em&gt;created_at&quot;, &quot;s&quot;.&quot;updated_at&quot; AS  &quot;s&lt;/em&gt;&lt;em&gt;updated_at&quot;, &quot;p&quot;.&quot;id&quot; AS &quot;p&lt;/em&gt;&lt;em&gt;id&quot;, &quot;p&quot;.&quot;story_id&quot; AS &quot;p&lt;/em&gt;&lt;em&gt;story_id&quot;, &quot;p&quot;.&quot;filename_original&quot; AS  &quot;p&lt;/em&gt;&lt;em&gt;filename_original&quot;, &quot;p&quot;.&quot;filename_large&quot; AS &quot;p&lt;/em&gt;&lt;em&gt;filename_large&quot;, &quot;p&quot;.&quot;filename_thumb&quot; AS &quot;p&lt;/em&gt;&lt;em&gt;filename_thumb&quot;, &quot;p&quot;.&quot;mime_type&quot; AS  &quot;p&lt;/em&gt;&lt;em&gt;mime_type&quot;, &quot;p&quot;.&quot;is_selected&quot; AS  &quot;p&lt;/em&gt;&lt;em&gt;is_selected&quot;, &quot;p&quot;.&quot;created_at&quot; AS  &quot;p&lt;/em&gt;&lt;em&gt;created_at&quot;, &quot;p&quot;.&quot;updated_at&quot; AS  &quot;p&lt;/em&gt;_updated_at&quot; FROM &quot;story&quot; &quot;s&quot; LEFT JOIN &quot;picture&quot; &quot;p&quot; ON &quot;s&quot;.&quot;id&quot; = &quot;p&quot;.&quot;story_id&quot; AND (&quot;p&quot;.&quot;is_selected&quot; = &apos;1&apos;) WHERE &quot;s&quot;.&quot;id&quot; IN (SELECT  DISTINCT &quot;s2&quot;.&quot;id&quot; FROM &quot;story&quot; &quot;s2&quot; LEFT JOIN &quot;picture&quot; &quot;p2&quot; ON &quot;s2&quot;.&quot;id&quot; = &quot;p2&quot;.&quot;story_id&quot; AND (&quot;p2&quot;.&quot;is_selected&quot; = &apos;5&apos;) WHERE &quot;s2&quot;.&quot;id&quot; = &apos;1&apos; ORDER BY &quot;s2&quot;.&quot;published_at&quot; DESC LIMIT  10) AND (&quot;s&quot;.&quot;id&quot; = &apos;5&apos;) ORDER BY  &quot;s&quot;.&quot;published_at&quot; DESC&lt;/p&gt;

&lt;p&gt;Notice the WHERE &quot;s2&quot;.&quot;id&quot; = &apos;1&apos; !&lt;/p&gt;</comment>
                    <comment id="13194" author="jwage" created="Tue, 8 Jun 2010 15:01:06 +0000"  >&lt;p&gt;Can you provide a test case we can run?&lt;/p&gt;</comment>
                    <comment id="13327" author="gerryvdm" created="Tue, 15 Jun 2010 10:15:33 +0000"  >&lt;p&gt;I could not figure out what test to write but I did narrow the problem down.&lt;/p&gt;

&lt;p&gt;It seems that the order of the generated SQL clauses does not match the order of the passed parameters, so in the final SQL query the values are mixed up. You can actually see that happening in the SQL query above. I also noticed there a special cases hardcoded in the code for MySQL and PgSQL as far as these &quot;limit subqueries&quot; go, so that might be another reason why you havent bumped into problem before. I was using an SQLite driver.&lt;/p&gt;

&lt;p&gt;I suppose something goes wrong in the SQL generation, but I don&apos;t know the core good enough to find out where exactly it does go wrong, so I&apos;m afraid I can&apos;t attach a test case, but it should be easy to reproduce now anyway.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>