<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Sat May 18 16:09:26 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://doctrine-project.org/jira/si/jira.issueviews:issue-xml/DDC-1918/DDC-1918.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://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-1918] Paginator gives strange results in the end of the resultset</title>
                <link>http://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://doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="3" iconUrl="http://doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="5" iconUrl="http://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>