<!--
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Fri May 24 17:54:31 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/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=project+%3D+10032+AND+labels+%3D+paginator&tempMax=1000&field=key&field=summary
-->
<!-- If you wish to do custom client-side styling of RSS, uncomment this:
<?xml-stylesheet href="http://www.doctrine-project.org/jira/styles/jiraxml2html.xsl" type="text/xsl"?>
-->
<rss version="0.92">
    <channel>
        <title>Doctrine Project</title>
        <link>http://www.doctrine-project.org/jira/secure/IssueNavigator.jspa?reset=true&amp;jqlQuery=project+%3D+10032+AND+labels+%3D+paginator</link>
        <description>An XML representation of a search request</description>
                <language>en-us</language>
                        <issue start="0" end="8" total="8"/>
                <build-info>
            <version>5.2.7</version>
            <build-number>850</build-number>
            <build-date>21-02-2013</build-date>
        </build-info>
<item>
            <title>[DDC-2381] Pagination query can be simplified when simple joins are applied</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-2381</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;Hi.&lt;br/&gt;
In mysql db table i have &amp;gt; 200,000 items.&lt;br/&gt;
I use native doctrine pagination for paging the items list.&lt;br/&gt;
But generated query that gets ids for items list in paging works more then 150 sec on my workstation&lt;/p&gt;

&lt;p&gt;SELECT DISTINCT id0 FROM (SELECT m0_.id AS id0, m0_.title AS title1, m0_.text AS text2, m0_.price AS price3, m0_.originalPrice AS originalPrice4, m0_.condition_type AS condition_type5, m0_.image_1 AS image_16, m0_.image_2 AS image_27, m0_.image_3 AS image_38, m0_.image_4 AS image_49, m0_.image_5 AS image_510, m0_.video AS video11, m0_.contact_email AS contact_email12, m0_.contact_name AS contact_name13, m0_.contact_phone AS contact_phone14, m0_.contact_type AS contact_type15, m0_.published AS published16, m0_.type AS type17, m0_.status AS status18, m0_.highlight AS highlight19, m0_.urgent AS urgent20, m0_.topads AS topads21, m0_.period AS period22, m0_.hits AS hits23, m0_.ip AS ip24, m0_.created_at AS created_at25, m0_.updated_at AS updated_at26 FROM milla_message m0_ INNER JOIN milla_currency m1_ ON m0_.currency_id = m1_.id INNER JOIN milla_category m2_ ON m0_.category_id = m2_.id INNER JOIN milla_region m3_ ON m0_.region_id = m3_.id INNER JOIN milla_city m4_ ON m0_.city_id = m4_.id WHERE m0_.status = 1 ORDER BY m0_.published DESC) dctrn_result LIMIT 20 OFFSET 0&lt;/p&gt;

&lt;p&gt;source code&lt;br/&gt;
&lt;a href=&quot;https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php#L141&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php#L141&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;why SELECT DISTINCT %s FROM (%s) dctrn_result ???&lt;br/&gt;
why not SELECT DISTINCT m0_.id AS id0 FROM milla_message m0_ WHERE m0_.status = 1 ORDER BY m0_.published DESC LIMIT 20 OFFSET 0&lt;/p&gt;</description>
                <environment></environment>
            <key id="14746">DDC-2381</key>
            <summary>Pagination query can be simplified when simple joins are applied</summary>
                <type id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/improvement.png">Improvement</type>
                                <priority id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/minor.png">Minor</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                    <security id="10000">All</security>
                        <assignee username="ocramius">Marco Pivetta</assignee>
                                <reporter username="sergic">Sergey Gerdel</reporter>
                        <labels>
                        <label>paginator</label>
                    </labels>
                <created>Sun, 31 Mar 2013 13:58:43 +0000</created>
                <updated>Mon, 8 Apr 2013 22:32:03 +0000</updated>
                                    <version>2.3</version>
                <version>2.4</version>
                                                <component>ORM</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="19908" author="ocramius" created="Sun, 31 Mar 2013 14:09:48 +0000"  >&lt;p&gt;Not a blocker&lt;/p&gt;</comment>
                    <comment id="19909" author="ocramius" created="Sun, 31 Mar 2013 14:14:11 +0000"  >&lt;p&gt;What&apos;s the result of `EXPLAIN` on a query without the subquery?&lt;/p&gt;</comment>
                    <comment id="19910" author="sergic" created="Sun, 31 Mar 2013 14:52:02 +0000"  >&lt;p&gt;explain without the subquery&lt;/p&gt;</comment>
                    <comment id="19911" author="ocramius" created="Sun, 31 Mar 2013 14:56:28 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=sergic&quot; class=&quot;user-hover&quot; rel=&quot;sergic&quot;&gt;Sergey Gerdel&lt;/a&gt; that&apos;s not the same query.&lt;/p&gt;</comment>
                    <comment id="19912" author="ocramius" created="Sun, 31 Mar 2013 15:09:52 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=sergic&quot; class=&quot;user-hover&quot; rel=&quot;sergic&quot;&gt;Sergey Gerdel&lt;/a&gt; this is still using&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;Using index; Using temporary; Using filesort
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Check your indexes&lt;/p&gt;</comment>
                    <comment id="19913" author="sergic" created="Sun, 31 Mar 2013 20:42:19 +0000"  >&lt;p&gt;Not in the index problem&lt;/p&gt;

&lt;p&gt;SELECT DISTINCT id0 FROM (SELECT m0_.id AS id0, m0_.title AS title1, m0_.text AS text2, m0_.price AS price3, m0_.originalPrice AS originalPrice4, m0_.condition_type AS condition_type5, m0_.image_1 AS image_16, m0_.image_2 AS image_27, m0_.image_3 AS image_38, m0_.image_4 AS image_49, m0_.image_5 AS image_510, m0_.video AS video11, m0_.contact_email AS contact_email12, m0_.contact_name AS contact_name13, m0_.contact_phone AS contact_phone14, m0_.contact_type AS contact_type15, m0_.published AS published16, m0_.type AS type17, m0_.status AS status18, m0_.highlight AS highlight19, m0_.urgent AS urgent20, m0_.topads AS topads21, m0_.period AS period22, m0_.hits AS hits23, m0_.ip AS ip24, m0_.created_at AS created_at25, m0_.updated_at AS updated_at26 FROM milla_message m0_ WHERE m0_.status = 1 ORDER BY m0_.published DESC) dctrn_result LIMIT 20 OFFSET 0&lt;/p&gt;

&lt;p&gt;Time: 104.614s explain 3&lt;/p&gt;

&lt;p&gt;SELECT DISTINCT m0_.id AS id0 FROM milla_message m0_ WHERE m0_.status = 1 ORDER BY m0_.published DESC LIMIT 20 OFFSET 0; &lt;/p&gt;

&lt;p&gt;Time: 0.001s explain 4&lt;/p&gt;</comment>
                    <comment id="19914" author="ocramius" created="Mon, 1 Apr 2013 06:17:54 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=sergic&quot; class=&quot;user-hover&quot; rel=&quot;sergic&quot;&gt;Sergey Gerdel&lt;/a&gt; the ORM cannot simplify a complex query that way. There may be a conditional on one of the joined results, or generally usage of one of the joined results.&lt;/p&gt;

&lt;p&gt;Things that &lt;b&gt;could&lt;/b&gt; be optimized here are:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Removal of the `ORDER BY` clause when grouping (check ORM master, I think somebody already did that)&lt;/li&gt;
	&lt;li&gt;Trying to simplify the query by doing some serious hacking on the AST.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The problem I see here is that the chance to spawn random bugs because of the optimization is very high, and you&apos;d have to rewrite `walkSelectStatement`&lt;/p&gt;</comment>
                    <comment id="19915" author="ocramius" created="Mon, 1 Apr 2013 06:19:15 +0000"  >&lt;p&gt;Marking as improvement&lt;/p&gt;</comment>
                    <comment id="19950" author="sergic" created="Sun, 7 Apr 2013 10:52:01 +0000"  >&lt;p&gt;Minor? &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/biggrin.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;br/&gt;
i have 100 sec for this query.&lt;br/&gt;
200k items are selected for temporary table. wtf?&lt;/p&gt;

&lt;p&gt;OK. Programmers may be mistaken in parser&lt;br/&gt;
expect ORDER BY m0_.published DESC LIMIT 20 OFFSET 0) dctrn_result &lt;br/&gt;
Time: 0.001s&lt;/p&gt;

&lt;p&gt;reality ORDER BY m0_.published DESC) dctrn_result LIMIT 20 OFFSET 0&lt;/p&gt;</comment>
                    <comment id="19951" author="ocramius" created="Sun, 7 Apr 2013 11:22:41 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=sergic&quot; class=&quot;user-hover&quot; rel=&quot;sergic&quot;&gt;Sergey Gerdel&lt;/a&gt; this problem does not introduce security issues and can be worked around by you while using your own pagination logic. It does not stop you from doing anything, that&apos;s why it&apos;s minor. &lt;/p&gt;</comment>
                    <comment id="19965" author="sergic" created="Mon, 8 Apr 2013 22:32:03 +0000"  >&lt;p&gt;ok)&lt;br/&gt;
i have already created my own paginator.&lt;br/&gt;
at last&lt;br/&gt;
please see how to fix this problem&lt;br/&gt;
&lt;a href=&quot;https://github.com/Sergic/doctrine2/commit/2733c815387273d3bd199a68acb717e0cbc8ccfe&quot; class=&quot;external-link&quot;&gt;https://github.com/Sergic/doctrine2/commit/2733c815387273d3bd199a68acb717e0cbc8ccfe&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="11514" name="EXPLAIN.htmL" size="6667" author="sergic" created="Sun, 31 Mar 2013 13:58:43 +0000" />
                    <attachment id="11515" name="EXPLAIN1.html" size="3006" author="sergic" created="Sun, 31 Mar 2013 14:51:57 +0000" />
                    <attachment id="11517" name="EXPLAIN2.html" size="4690" author="sergic" created="Sun, 31 Mar 2013 15:08:08 +0000" />
                    <attachment id="11518" name="EXPLAIN3.htm" size="4083" author="sergic" created="Sun, 31 Mar 2013 20:42:11 +0000" />
                    <attachment id="11519" name="EXPLAIN4.htm" size="3006" author="sergic" created="Sun, 31 Mar 2013 20:42:16 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DDC-2283] Paginator with orderBy in joined data retrieve bad result</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-2283</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;entity A have many entity B&lt;/p&gt;

&lt;p&gt;If DQL is something like &quot;select A, B from A join B order by A.field1, B.field2&quot;&lt;br/&gt;
Then Paginator retrieve different Id by a query like : &lt;br/&gt;
&quot;select distinct a.id, a.field1, b.field2 from ( ....) order by a.field1 ASC , b.field2 ASC limit 15 offset 0&quot;&lt;/p&gt;


&lt;p&gt;so, if a entity A have 20 entity B (and these sub-entity have all a different b.field2) then there&apos;s only 1 A retrieved &lt;/p&gt;</description>
                <environment></environment>
            <key id="14463">DDC-2283</key>
            <summary>Paginator with orderBy in joined data retrieve bad result</summary>
                <type id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/improvement.png">Improvement</type>
                                <priority id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/minor.png">Minor</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="sylfel">Jean-Philippe THEVENOUX</reporter>
                        <labels>
                        <label>paginator</label>
                    </labels>
                <created>Thu, 7 Feb 2013 15:33:45 +0000</created>
                <updated>Tue, 26 Feb 2013 08:52:40 +0000</updated>
                                    <version>2.3.2</version>
                                                <component>ORM</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DDC-2236] SUM(..) with Pagination gives incorrect result</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-2236</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;&lt;a href=&quot;https://github.com/whiteoctober/Pagerfanta/issues/69&quot; class=&quot;external-link&quot;&gt;https://github.com/whiteoctober/Pagerfanta/issues/69&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;?php&lt;br/&gt;
$query = $em-&amp;gt;getRepository(&apos;M\E\Q&apos;)&lt;br/&gt;
       -&amp;gt;createQueryBuilder(&apos;q&apos;)&lt;br/&gt;
       -&amp;gt;select(&apos;q&apos;, &apos;SUM(q.price) AS amount&apos;)&lt;br/&gt;
       -&amp;gt;where(&apos;q.id IN(19, 20, 22)&apos;)&lt;br/&gt;
      -&amp;gt;groupBy(&apos;q.customer&apos;)&lt;br/&gt;
;&lt;/p&gt;

&lt;p&gt;$pager = new Pagerfanta(new DoctrineORMAdapter($query));&lt;br/&gt;
$pager-&amp;gt;setMaxPerPage(30);&lt;br/&gt;
$pager-&amp;gt;setCurrentPage($request-&amp;gt;query-&amp;gt;get(&apos;page&apos;, 1));&lt;/p&gt;

&lt;p&gt;$result = $pager-&amp;gt;getCurrentPageResults();&lt;br/&gt;
print_r($result&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;amount&amp;#39;&amp;#93;&lt;/span&gt;); // 156.71 - Incorrect&lt;/p&gt;

&lt;p&gt;$result = $query-&amp;gt;getQuery()-&amp;gt;getResult();&lt;br/&gt;
print_r($result&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;amount&amp;#39;&amp;#93;&lt;/span&gt;); // 553.47&lt;br/&gt;
?&amp;gt;&lt;/p&gt;

&lt;p&gt;Sql for the above:&lt;/p&gt;

&lt;p&gt;SELECT DISTINCT id0 FROM (SELECT q0_.id AS id0, SUM(q0_.price) AS sclr36 FROM Q q0_ WHERE q0_.id IN (19, 20, 22) GROUP BY q0_.customer_id) dctrn_result LIMIT 30 OFFSET 0&lt;br/&gt;
SELECT q0_.id AS id0, SUM(q0_.price) AS sclr36 FROM Q q0_ WHERE q0_.id IN (19, 20, 22) AND q0_.id IN (&apos;19&apos;) GROUP BY q0_.customer_id&lt;br/&gt;
SELECT q0_.id AS id21, SUM(q0_.price) AS sclr36 FROM Q q0_ WHERE q0_.id IN (19, 20, 22) GROUP BY q0_.customer_id&lt;/p&gt;


&lt;p&gt;Sql with fetchJoin = false (new DoctrineORMAdapter($query, false))&lt;/p&gt;

&lt;p&gt;SELECT q0_.id AS id0, SUM(q0_.price) AS sclr36 FROM Quote q0_ WHERE q0_.id IN (19, 20, 22) GROUP BY q0_.customer_id LIMIT 30 OFFSET 0&lt;br/&gt;
SELECT q0_.id AS id0, SUM(q0_.price) AS sclr36 FROM Quote q0_ WHERE q0_.id IN (19, 20, 22) GROUP BY q0_.customer_id&lt;/p&gt;</description>
                <environment>Linux</environment>
            <key id="14375">DDC-2236</key>
            <summary>SUM(..) with Pagination gives incorrect result</summary>
                <type id="6" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/documentation.png">Documentation</type>
                                <priority id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/minor.png">Minor</priority>
                    <status id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/inprogress.png">In Progress</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="olegk">Oleg</reporter>
                        <labels>
                        <label>paginator</label>
                    </labels>
                <created>Fri, 11 Jan 2013 16:24:56 +0000</created>
                <updated>Sun, 10 Feb 2013 18:21:58 +0000</updated>
                                    <version>2.2.3</version>
                                                <component>Tools</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>4</watches>
                        <comments>
                    <comment id="19511" author="asm89" created="Sat, 9 Feb 2013 23:48:30 +0000"  >&lt;p&gt;Can you also test this with doctrine &amp;gt;= 2.3? The pagination code changed quite a lot.&lt;/p&gt;</comment>
                    <comment id="19517" author="olegk" created="Sun, 10 Feb 2013 11:30:24 +0000"  >&lt;p&gt;Looks like no change&lt;/p&gt;

&lt;p&gt;composer.json:&lt;br/&gt;
&quot;doctrine/orm&quot;: &quot;2.3.*&quot;,&lt;br/&gt;
&amp;#8211;&lt;br/&gt;
php composer.phar update&lt;br/&gt;
Loading composer repositories with package information&lt;br/&gt;
Updating dependencies&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Installing doctrine/common (2.3.0)&lt;br/&gt;
    Loading from cache&lt;/li&gt;
&lt;/ul&gt;


&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Installing doctrine/dbal (2.3.2)&lt;br/&gt;
    Loading from cache&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;then cleared cache but result is same&lt;br/&gt;
Here&apos;s the code&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-none&quot;&gt; 
$query = $this-&amp;gt;getDoctrine()-&amp;gt;getEntityManager()-&amp;gt;getRepository(&apos;MyBundle:Invoice&apos;)
  -&amp;gt;createQueryBuilder(&apos;q&apos;)
  -&amp;gt;select(&apos;q&apos;, &apos;SUM(q.amount) AS amount&apos;)
  -&amp;gt;groupBy(&apos;q.customer&apos;)
;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&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-sql&quot;&gt; 
95 Connect	root@localhost on **
95 Query	&lt;span class=&quot;code-keyword&quot;&gt;SELECT&lt;/span&gt; DISTINCT id0 &lt;span class=&quot;code-keyword&quot;&gt;FROM&lt;/span&gt; (&lt;span class=&quot;code-keyword&quot;&gt;SELECT&lt;/span&gt; i0_.id AS id0, i0_.invoice_num AS invoice_num1, i0_.date AS date2, i0_.amount AS amount3, i0_.vat_amount AS vat_amount4, i0_.amount_paid AS amount_paid5, i0_.md5 AS md56, i0_.is_exported AS is_exported7, i0_.created AS created8, SUM(i0_.amount) AS sclr9 &lt;span class=&quot;code-keyword&quot;&gt;FROM&lt;/span&gt; Invoice i0_ &lt;span class=&quot;code-keyword&quot;&gt;GROUP&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;BY&lt;/span&gt; i0_.customer_id) dctrn_result LIMIT 30 OFFSET 0
95 Query	&lt;span class=&quot;code-keyword&quot;&gt;SELECT&lt;/span&gt; i0_.id AS id0, i0_.invoice_num AS invoice_num1, i0_.date AS date2, i0_.amount AS amount3, i0_.vat_amount AS vat_amount4, i0_.amount_paid AS amount_paid5, i0_.md5 AS md56, i0_.is_exported AS is_exported7, i0_.created AS created8, SUM(i0_.amount) AS sclr9, i0_.customer_id AS customer_id10 &lt;span class=&quot;code-keyword&quot;&gt;FROM&lt;/span&gt; Invoice i0_ &lt;span class=&quot;code-keyword&quot;&gt;WHERE&lt;/span&gt; i0_.id IN (&apos;2&apos;) &lt;span class=&quot;code-keyword&quot;&gt;GROUP&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;BY&lt;/span&gt; i0_.customer_id
95 Query	&lt;span class=&quot;code-keyword&quot;&gt;SELECT&lt;/span&gt; i0_.id AS id0, i0_.invoice_num AS invoice_num1, i0_.date AS date2, i0_.amount AS amount3, i0_.vat_amount AS vat_amount4, i0_.amount_paid AS amount_paid5, i0_.md5 AS md56, i0_.is_exported AS is_exported7, i0_.created AS created8, SUM(i0_.amount) AS sclr9, i0_.customer_id AS customer_id10 &lt;span class=&quot;code-keyword&quot;&gt;FROM&lt;/span&gt; Invoice i0_ &lt;span class=&quot;code-keyword&quot;&gt;GROUP&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;BY&lt;/span&gt; i0_.customer_id
130210 16:08:25	   95 Quit	
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 


&lt;p&gt;But I understand why that happens, it&apos;s due to group by and pagination nature. &lt;br/&gt;
The first query returns only one row with id &quot;2&quot;, second query should be actually &quot;..WHERE i0_.id IN (&apos;2&apos;, &apos;3&apos;, &apos;4&apos;)&quot;&lt;/p&gt;

&lt;p&gt;If I do&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-none&quot;&gt;
$pager = new Pagerfanta(new DoctrineORMAdapter($query, false));
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I get this 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-sql&quot;&gt;
&lt;span class=&quot;code-keyword&quot;&gt;SELECT&lt;/span&gt; i0_.id AS id0, i0_.invoice_num AS invoice_num1, i0_.date AS date2, i0_.amount AS amount3, i0_.vat_amount AS vat_amount4, i0_.amount_paid AS amount_paid5, i0_.md5 AS md56, i0_.is_exported AS is_exported7, i0_.created AS created8, SUM(i0_.amount) AS sclr9, i0_.customer_id AS customer_id10 &lt;span class=&quot;code-keyword&quot;&gt;FROM&lt;/span&gt; Invoice i0_ LIMIT 30 OFFSET 0
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;


&lt;p&gt;I think it should be noted somewhere that if you do groupBy you should set fetchJoin to false? &lt;/p&gt;</comment>
                    <comment id="19525" author="ocramius" created="Sun, 10 Feb 2013 18:21:58 +0000"  >&lt;p&gt;Updating to Documentation issue.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DDC-2213] Paginator does not work with composite primary key entity</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-2213</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;Paginator does not work with composed primary key.&lt;/p&gt;

&lt;p&gt;&quot;Single id is not allowed on composite primary key in entity&quot; exception is thrown here &lt;br/&gt;
&lt;a href=&quot;https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php#L90&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php#L90&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Only first column values are fetched while retrieving primary keys here&lt;br/&gt;
&lt;a href=&quot;https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/Pagination/Paginator.php#L173&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/Pagination/Paginator.php#L173&lt;/a&gt;&lt;/p&gt;</description>
                <environment>php 5.4</environment>
            <key id="14332">DDC-2213</key>
            <summary>Paginator does not work with composite primary key entity</summary>
                <type id="2" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/newfeature.png">New Feature</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                    <security id="10000">All</security>
                        <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="thestanislav">Stanislav Anisimov</reporter>
                        <labels>
                        <label>composed</label>
                        <label>key</label>
                        <label>paginator</label>
                    </labels>
                <created>Tue, 25 Dec 2012 13:24:27 +0000</created>
                <updated>Wed, 23 Jan 2013 21:20:21 +0000</updated>
                                    <version>2.3.1</version>
                                                <component>ORM</component>
                <component>Tools</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>4</watches>
                        <comments>
                    <comment id="19369" author="ocramius" created="Wed, 23 Jan 2013 21:20:21 +0000"  >&lt;p&gt;Limitation was confused by issue reporter and considered bug&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DDC-1958] pager produces wrong results on postgresql</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-1958</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;The query build by pager to get the subset of PKs to fetch produces wrong results on potgresql (and probably any database), that conforms to the SQL standard. The standard says, that if you wish to have the results in specific order, then you have to specify that by using an ORDER BY clause. If such a clause is not present the database can return the results in whatever order it sees fit.&lt;/p&gt;

&lt;p&gt;Testcase fixtures:&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;
CREATE TABLE test (
    id integer,
    name text
);

INSERT INTO test VALUES (1, &apos;c&apos;);
INSERT INTO test VALUES (2, &apos;a&apos;);
INSERT INTO test VALUES (3, &apos;e&apos;);
INSERT INTO test VALUES (4, &apos;b&apos;);
INSERT INTO test VALUES (5, &apos;d&apos;);
INSERT INTO test VALUES (6, &apos;a&apos;);
INSERT INTO test VALUES (7, &apos;g&apos;);
INSERT INTO test VALUES (8, &apos;h&apos;);
INSERT INTO test VALUES (9, &apos;e&apos;);
INSERT INTO test VALUES (10, &apos;j&apos;);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Passing f.e.&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;
$qb = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;repository
    -&amp;gt;createQueryBuilder(&apos;t&apos;)
    -&amp;gt;select(&apos;t&apos;)
    -&amp;gt;setFirstResult(0)
    -&amp;gt;setMaxResults(5)
    -&amp;gt;addOrderBy(&apos;t.name&apos;, &apos;ASC&apos;)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;to pager produces SQL like this modified for readability&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 DISTINCT id FROM (
    SELECT id, name FROM test ORDER BY name
  ) dctrn_result
  LIMIT 5 OFFSET 0
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now there is nothing wrong with this modified query per se, but there is no ORDER BY clause in the outer query so according to the standard the DB can choose whatever order it seems fit. Now mysql chooses the same order, but postgresql does not and it&apos;s probably not the only DB doing so.&lt;/p&gt;

&lt;p&gt;If you are interested in the results, this is the output I&apos;m seeing:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;postgresql: 8,4,1,5,3&lt;/li&gt;
	&lt;li&gt;mysql     : 2,6,4,1,5&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;I and my coworker came to the standard compliant solution it was also tested on the dataset above on both postgresql and mysql and it produced equal results. We have found only one corner case this won&apos;t work and IMHO that can&apos;t be fixed. The problem is when you do a sort on a field from a table that is in 1:n relation to the main table.. e.g  tables posts and tags, where one post can have a multiple tags and you want your results sorted by a tag.&lt;/p&gt;

&lt;p&gt;Recipe for a correct query is:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;remember the ORDER BY fields from original query and then remove them&lt;/li&gt;
	&lt;li&gt;wrap the original query with a DISTINCT query, but add the fields from ORDER BY to the SELECT part of that query and add the whole ORDER BY to the end of it, also add the PK to the order by clause, and add the LIMIT clause&lt;/li&gt;
	&lt;li&gt;wrap the resulting query into another query and select just the id.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;so if I take the example from above the SQL should look like this:&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 id FROM (
  SELECT DISTINCT id, name FROM (
    SELECT id, name FROM test
  ) dctrn_result_inner
  ORDER BY name, id LIMIT 5 OFFSET 0
) dctrn_result
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment>* Postgres 9.1, 9.2&lt;br/&gt;
* PHP 5.4</environment>
            <key id="13897">DDC-1958</key>
            <summary>pager produces wrong results on postgresql</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="mvrhov">Miha Vrhovnik</reporter>
                        <labels>
                        <label>paginator</label>
                    </labels>
                <created>Mon, 30 Jul 2012 14:11:37 +0000</created>
                <updated>Tue, 9 Apr 2013 20:22:45 +0000</updated>
                    <resolved>Mon, 12 Nov 2012 14:05:03 +0000</resolved>
                            <version>2.3</version>
                                <fixVersion>2.3.1</fixVersion>
                                <component>Tools</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>3</watches>
                        <comments>
                    <comment id="18958" author="sylfel" created="Thu, 8 Nov 2012 10:20:52 +0000"  >&lt;p&gt;I reproduce same problem with Postgres 7.4, Doctrine 2.3 whereas with doctrine 2.2, all is fine&lt;br/&gt;
Hope there&apos;ll a fix in next doctrine version&lt;/p&gt;</comment>
                    <comment id="19969" author="rkolbe" created="Tue, 9 Apr 2013 20:22:45 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-1800&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/jira/browse/DDC-1800&lt;/a&gt; This relates.&lt;/p&gt;

&lt;p&gt;I just published a PR for an Oracle fix, but your solution appears to work for Oracle as well (issue is the same).&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DDC-1935] Not all identifier properties can be found in the ResultSetMapping: id</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-1935</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;$qb1 = $em-&amp;gt;createQueryBuilder()-&amp;gt;select(&apos;c.id&apos;);&lt;br/&gt;
...&lt;br/&gt;
$query1 = $qb1-&amp;gt;getQuery(); &lt;/p&gt;

&lt;p&gt;$doctrinePaginator = new \Doctrine\ORM\Tools\Pagination\Paginator($query1);&lt;br/&gt;
$doctrinePaginator-&amp;gt;count(); =&amp;gt; generate error&lt;/p&gt;

&lt;p&gt;But works fine with $query2 !&lt;/p&gt;

&lt;p&gt;$qb2 = $em-&amp;gt;createQueryBuilder()-&amp;gt;select(&apos;c&apos;);&lt;br/&gt;
...&lt;br/&gt;
$query2 = $qb2-&amp;gt;getQuery(); &lt;/p&gt;



&lt;p&gt;$doctrinePaginator = new \Doctrine\ORM\Tools\Pagination\Paginator($query2);&lt;br/&gt;
$doctrinePaginator-&amp;gt;count(); =&amp;gt; no error&lt;/p&gt;</description>
                <environment></environment>
            <key id="13868">DDC-1935</key>
            <summary>Not all identifier properties can be found in the ResultSetMapping: id</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="3">Duplicate</resolution>
                    <security id="10000">All</security>
                        <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="dquintard">dquintard</reporter>
                        <labels>
                        <label>paginator</label>
                    </labels>
                <created>Thu, 19 Jul 2012 14:21:28 +0000</created>
                <updated>Sun, 29 Jul 2012 07:40:19 +0000</updated>
                    <resolved>Sun, 29 Jul 2012 07:40:19 +0000</resolved>
                            <version>Git Master</version>
                                                <component>Tools</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="18356" author="dquintard" created="Fri, 20 Jul 2012 08:31:56 +0000"  >
&lt;p&gt;It seems that this issue is the same that:&lt;br/&gt;
&lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-1927&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/jira/browse/DDC-1927&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="18397" author="beberlei" created="Sun, 29 Jul 2012 07:40:19 +0000"  >&lt;p&gt;Duplicate of &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-1927&quot; title=&quot;Pagination of a SELECT of specific fields results in a RuntimeException&quot;&gt;&lt;del&gt;DDC-1927&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DDC-1927] Pagination of a SELECT of specific fields results in a RuntimeException</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-1927</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;When paginating a DQL string which selects specific fields it results in the following error: PHP Fatal error:  Uncaught exception &apos;RuntimeException&apos; with message &apos;Not all identifier properties can be found in the ResultSetMapping: id&apos;&lt;/p&gt;

&lt;p&gt;NOT working: &apos;SELECT c.id, c.number FROM Application\Entity\Course c&apos;&lt;br/&gt;
WORKING: &apos;SELECT c FROM Application\Entity\Course c&apos;&lt;br/&gt;
WORKING: &apos;SELECT c, c.id, c.number FROM Application\Entity\Course c&apos;&lt;/p&gt;

&lt;p&gt;Setting hydration mode to scalar results makes no difference.&lt;/p&gt;

&lt;p&gt;Gist to example code and stack trace: &lt;a href=&quot;https://gist.github.com/d5cd6d0b0ac28e722dd7&quot; class=&quot;external-link&quot;&gt;https://gist.github.com/d5cd6d0b0ac28e722dd7&lt;/a&gt;&lt;/p&gt;</description>
                <environment></environment>
            <key id="13854">DDC-1927</key>
            <summary>Pagination of a SELECT of specific fields results in a RuntimeException</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="7">Can&apos;t Fix</resolution>
                    <security id="10000">All</security>
                        <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="netiul">Zacharias Luiten</reporter>
                        <labels>
                        <label>paginator</label>
                    </labels>
                <created>Mon, 16 Jul 2012 10:10:55 +0000</created>
                <updated>Thu, 18 Apr 2013 20:22:25 +0000</updated>
                    <resolved>Sun, 25 Nov 2012 12:23:36 +0000</resolved>
                            <version>Git Master</version>
                                                <component>ORM</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>5</watches>
                        <comments>
                    <comment id="18403" author="beberlei" created="Sun, 29 Jul 2012 08:47:56 +0000"  >&lt;p&gt;First results: This is very complicated to support, the pagination was designed for entity results. I have to check this when I have more time.&lt;/p&gt;</comment>
                    <comment id="18477" author="dquintard" created="Wed, 8 Aug 2012 12:00:22 +0000"  >&lt;p&gt;Hi Benjamin,&lt;br/&gt;
I can change my code to select entity results (even for hundreds/thousands results).&lt;br/&gt;
But for now Pagination is not usable with ResultSetMapping::addScalarResult &lt;/p&gt;</comment>
                    <comment id="18982" author="mpinkston" created="Tue, 13 Nov 2012 17:06:42 +0000"  >&lt;p&gt;The reason this error occurs is because the Paginator creates its own ResultSetMapping and relies on the SqlWalker to configure it (see Doctrine\ORM\Query\SqlWalker::walkSelectExpression).&lt;/p&gt;

&lt;p&gt;Doctrine will interpret each field in the first example (SELECT c.id, c.number...) as a PathExpression and add it to the result set mapping as a scalar result. This makes it impossible for the paginator to reliably know which field can be considered an identifier.&lt;/p&gt;

&lt;p&gt;A quick fix might be to re-write the query to use PartialObjectExpression: SELECT partial c.&lt;/p&gt;
{id, number}
&lt;p&gt; ...&lt;/p&gt;

&lt;p&gt;(edited after a re-read and realization that a custom ResultSetMapping wouldn&apos;t cut it)&lt;/p&gt;
</comment>
                    <comment id="19052" author="beberlei" created="Sun, 25 Nov 2012 12:23:36 +0000"  >&lt;p&gt;Allowing generic+complex pagination on scalar results is impossible for us, closing as can&apos;t fix. &lt;/p&gt;

&lt;p&gt;Just use LIMITs yourself here or as suggested partial objects.&lt;/p&gt;</comment>
                    <comment id="20060" author="vecchia" created="Thu, 18 Apr 2013 20:22:25 +0000"  >&lt;p&gt;imho this pagination feature is quite useless if we are forced to fetch the complete Entity. Take for example a big table with a lot of data: extracting all the infos will take a lot of time... There should be a way to support the first query type&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DDC-1918] Paginator gives strange results in the end of the resultset</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-1918</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;Hello,&lt;br/&gt;
i&apos;ve an image and a tag entities, image has a one to many with tags. I was using limit and offset and it was giving 7 images instead of 9 (limit is set to 9) due one image has 3 tags. So i started using paginator to resolve the join-fetch issue. It worked fine at the beginning of the resultset, the problem is at the end (i have 29 images), when i increase the offset.&lt;br/&gt;
These are the last 3 calls:&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;offset 27, distinct query is:&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;SELECT DISTINCT i0_.id AS id0, i0_.creation_time AS creation_time1 FROM Image i0_ LEFT JOIN Tag t1_ ON i0_.id = t1_.image WHERE i0_.owner = 1 ORDER BY i0_.creation_time DESC LIMIT 9 OFFSET 27&lt;/p&gt;

&lt;p&gt;   it returns 2 images, correct, so the final query is&lt;/p&gt;


&lt;p&gt;SELECT i0_.id AS id0, i0_.name AS name1, i0_.status AS status2, i0_.last_processing AS last_processing3, i0_.creation_time AS creation_time4, i0_.height AS height5, i0_.width AS width6, i0_.layers AS layers7, i0_.foldersize AS foldersize8, i0_.sourcesize AS sourcesize9, i0_.title AS title10, i0_.description AS description11, i0_.originalUrl AS originalUrl12, i0_.private AS private13, i0_.watermark AS watermark14, i0_.favorite AS favorite15, t1_.id AS id16, t1_.tag AS tag17, i0_.owner AS owner18, t1_.image AS image19 FROM Image i0_ LEFT JOIN Tag t1_ ON i0_.id = t1_.image WHERE i0_.owner = 1 AND i0_.id IN (?, ?) ORDER BY i0_.creation_time DESC&lt;/p&gt;

&lt;p&gt;   with parameters the 2 images id, still correct.&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;offset 29, distinct query is:&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;SELECT DISTINCT i0_.id AS id0, i0_.creation_time AS creation_time1 FROM Image i0_ LEFT JOIN Tag t1_ ON i0_.id = t1_.image WHERE i0_.owner = 1 ORDER BY i0_.creation_time DESC LIMIT 9 OFFSET 29&lt;/p&gt;

&lt;p&gt;   which doesn&apos;t get any result, but it still goes on querying without id filter:&lt;/p&gt;


&lt;p&gt;SELECT i0_.id AS id0, i0_.name AS name1, i0_.status AS status2, i0_.last_processing AS last_processing3, i0_.creation_time AS creation_time4, i0_.height AS height5, i0_.width AS width6, i0_.layers AS layers7, i0_.foldersize AS foldersize8, i0_.sourcesize AS sourcesize9, i0_.title AS title10, i0_.description AS description11, i0_.originalUrl AS originalUrl12, i0_.private AS private13, i0_.watermark AS watermark14, i0_.favorite AS favorite15, t1_.id AS id16, t1_.tag AS tag17, i0_.owner AS owner18, t1_.image AS image19 FROM Image i0_ LEFT JOIN Tag t1_ ON i0_.id = t1_.image WHERE i0_.owner = 1 ORDER BY i0_.creation_time DESC LIMIT 9 OFFSET 29&lt;/p&gt;

&lt;p&gt;and it gets the last 2 images maybe due the fetch join like as i&apos;m not using paginator.&lt;/p&gt;</description>
                <environment>Mac OSX MAMP (apache + php 5.3.6 + mysql 5)</environment>
            <key id="13843">DDC-1918</key>
            <summary>Paginator gives strange results in the end of the resultset</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="alex88">Alessandro Tagliapietra</reporter>
                        <labels>
                        <label>paginator</label>
                    </labels>
                <created>Tue, 10 Jul 2012 13:27:13 +0000</created>
                <updated>Wed, 29 Aug 2012 16:24:13 +0000</updated>
                    <resolved>Wed, 29 Aug 2012 16:24:13 +0000</resolved>
                            <version>Git Master</version>
                                <fixVersion>Git Master</fixVersion>
                                <component>DQL</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="18517" author="alex88" created="Wed, 15 Aug 2012 12:12:50 +0000"  >&lt;p&gt;No updates?&lt;/p&gt;</comment>
                    <comment id="18518" author="beberlei" created="Wed, 15 Aug 2012 12:58:45 +0000"  >&lt;p&gt;Sorry I am swamped with work at the moment and other important projects, I couldnt look into it yet.&lt;/p&gt;</comment>
                    <comment id="18544" author="alex88" created="Mon, 27 Aug 2012 08:58:31 +0000"  >&lt;p&gt;Commenting the if this part:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-style: solid;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;border-bottom-style: solid;&quot;&gt;&lt;b&gt;Paginator.php&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
            &lt;span class=&quot;code-comment&quot;&gt;// don&apos;t &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; an empty id array
&lt;/span&gt;            &lt;span class=&quot;code-comment&quot;&gt;//&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (count($ids) &amp;gt; 0) {
&lt;/span&gt;                $namespace = WhereInWalker::PAGINATOR_ID_ALIAS;

                $whereInQuery-&amp;gt;setHint(Query::HINT_CUSTOM_TREE_WALKERS, array(&apos;Doctrine\ORM\Tools\Pagination\WhereInWalker&apos;));
                $whereInQuery-&amp;gt;setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, count($ids));
                $whereInQuery-&amp;gt;setFirstResult(&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;)-&amp;gt;setMaxResults(&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;);
                foreach ($ids as $i =&amp;gt; $id) {
                    $i++;
                    $whereInQuery-&amp;gt;setParameter(&lt;span class=&quot;code-quote&quot;&gt;&quot;{$namespace}_{$i}&quot;&lt;/span&gt;, $id);
                }
            &lt;span class=&quot;code-comment&quot;&gt;//}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;make it works, for me is better, because if you don&apos;t have results to show as the result of the select distinct is empty you shouldn&apos;t have any result at all. Because if you don&apos;t add the &quot;WHERE IN&quot; query you get the results joined with no difference between using or not the paginator.&lt;/p&gt;</comment>
                    <comment id="18562" author="beberlei" created="Wed, 29 Aug 2012 11:34:57 +0000"  >&lt;p&gt;This is weird, an empty IN() normally produces an error. We could add a non matching condition instead,  like 0 = 1.&lt;/p&gt;</comment>
                    <comment id="18574" author="alex88" created="Wed, 29 Aug 2012 12:58:02 +0000"  >&lt;p&gt;Not really, in my case (mysql) it creates the following query:&lt;/p&gt;

&lt;p&gt;SELECT i0_.id AS id0, i0_.name AS name1, i0_.status AS status2, i0_.last_processing AS last_processing3, i0_.creation_time AS creation_time4, i0_.height AS height5, i0_.width AS width6, i0_.layers AS layers7, i0_.foldersize AS foldersize8, i0_.sourcesize AS sourcesize9, i0_.title AS title10, i0_.description AS description11, i0_.originalUrl AS originalUrl12, i0_.private AS private13, i0_.watermark AS watermark14, i0_.favorite AS favorite15, t1_.id AS id16, t1_.tag AS tag17, i0_.owner AS owner18, t1_.image AS image19 FROM Image i0_ LEFT JOIN Tag t1_ ON i0_.id = t1_.image WHERE i0_.owner = 1 AND i0_.id IS NULL ORDER BY i0_.creation_time DESC&lt;/p&gt;

&lt;p&gt;so it sets &quot;AND i0_.id IS NULL&quot; which solves the problem, the best solution for me is to directly return an empty set if the DISTINCT gives no results.&lt;/p&gt;</comment>
                    <comment id="18579" author="alex88" created="Wed, 29 Aug 2012 16:24:13 +0000"  >&lt;p&gt;Solved with commit bc2476f342ceda98559b87a314806581cf969796&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>