<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Fri May 24 00:28:46 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-49/DC-49.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-49] Wrong query parameter order when using limit() on PostgreSQL</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-49</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Trying to add limit() to complex query with many where&apos;s and some joins. In pgsql it causes nested limit subquery and in some cases parameter order (when limit subquery exists params array just merges with itself, i. e. (1,2) becomes (1,2,1,2)) makes result query wrong, i. e. params array order doesn&apos;t correspond placeholders order in query.&lt;/p&gt;

&lt;p&gt;With named query parameters all ok.&lt;/p&gt;

&lt;p&gt;Testcase attached.&lt;/p&gt;</description>
                <environment>latest doctrine 1.1 revision, linux x64, PostgeSQL 8.4, php 5.2.10</environment>
            <key id="10098">DC-49</key>
            <summary>Wrong query parameter order when using limit() 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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="guilhermeblanco">Guilherme Blanco</assignee>
                                <reporter username="corristo">Nicholas Kasyanov</reporter>
                        <labels>
                    </labels>
                <created>Tue, 22 Sep 2009 09:07:18 +0000</created>
                <updated>Mon, 26 Jul 2010 10:01:23 +0000</updated>
                                    <version>1.1.4</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>2</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="10121" author="jwage" created="Thu, 24 Sep 2009 20:54:11 +0000"  >&lt;p&gt;here is the working test case:&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;class Doctrine_Ticket_DC49_TestCase &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_UnitTestCase 
{
        &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;static&lt;/span&gt; $query;
        &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;static&lt;/span&gt; $params;

        &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function init()
        {
                $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;dbh = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Doctrine_Adapter_Mock(&apos;pgsql&apos;);
                $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;conn = Doctrine_Manager::getInstance()-&amp;gt;openConnection($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;dbh);
                $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;conn-&amp;gt;addListener(&lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; PPB_QueryListener());
        }
        
        &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function prepareTables()
        {
                $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;tables = array(&apos;PPB_Section&apos;, &apos;PPB_Post&apos;, &apos;PPB_PostVote&apos;);
                
                parent::prepareTables();
        }
        
        &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function testBug()
        {
                $q = Doctrine_Query::create()-&amp;gt;from(&apos;PPB_Post p&apos;)
                                             -&amp;gt;where(&apos;p.section_id = ?&apos;, 1)
                                             -&amp;gt;addWhere(&apos;p.id = ?&apos;, 15)
                                             -&amp;gt;leftJoin(&apos;p.Votes v WITH v.user_id = ?&apos;, 10)
                                             -&amp;gt;limit(10);
                                             
                $q-&amp;gt;execute();
                
                $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;assertEqual(self::$query, &lt;span class=&quot;code-quote&quot;&gt;&quot;SELECT p.id AS p__id, p.section_id AS p__section_id, p2.id AS p2__id, p2.post_id AS p2__post_id, p2.user_id AS p2__user_id FROM p_p_b__post p LEFT JOIN p_p_b__post_vote p2 ON p.id = p2.post_id AND (p2.user_id = ?) WHERE p.id IN (SELECT doctrine_subquery_alias.id FROM (SELECT DISTINCT p3.id FROM p_p_b__post p3 LEFT JOIN p_p_b__post_vote p4 ON p3.id = p4.post_id AND (p4.user_id = ?) WHERE p3.section_id = ? AND p3.id = ? LIMIT 10) AS doctrine_subquery_alias) AND (p.section_id = ? AND p.id = ?)&quot;&lt;/span&gt;);
                
                $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;assertEqual(implode(&lt;span class=&quot;code-quote&quot;&gt;&quot;,&quot;&lt;/span&gt;, self::$params), &apos;10,10,1,15,1,15&apos;); &lt;span class=&quot;code-comment&quot;&gt;// correct order of params
&lt;/span&gt;        }
}

class PPB_Post &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Record
{
        &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setTableDefinition()
        {
                $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;section_id&apos;, &apos;integer&apos;);
        }
        
        &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setUp()
        {
                $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasOne(&apos;PPB_Section&apos;, array(&apos;local&apos; =&amp;gt; &apos;section_id&apos;,
                                                   &apos;foreign&apos; =&amp;gt; &apos;id&apos;));
                                                   
                $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasMany(&apos;PPB_PostVote as Votes&apos;, array(&apos;local&apos; =&amp;gt; &apos;id&apos;,
                                                              &apos;foreign&apos; =&amp;gt; &apos;post_id&apos;));
        }
}

class PPB_Section &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Record
{
        &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setTableDefinition()
        {
        }
}

class PPB_PostVote &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Record
{
        &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setTableDefinition()
        {
                $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;post_id&apos;, &apos;integer&apos;);
                $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;user_id&apos;, &apos;integer&apos;);
        }
}

class PPB_QueryListener &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_EventListener
{
        &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function postStmtExecute(Doctrine_Event $event)
        {
                &lt;span class=&quot;code-comment&quot;&gt;//var_dump($event-&amp;gt;getQuery());
&lt;/span&gt;                &lt;span class=&quot;code-comment&quot;&gt;//var_dump($event-&amp;gt;getParams());
&lt;/span&gt;                
                Doctrine_Ticket_DC49_TestCase::$query = $event-&amp;gt;getQuery();
                Doctrine_Ticket_DC49_TestCase::$params = $event-&amp;gt;getParams();
        }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                    <comment id="13705" author="dbojdo" created="Mon, 26 Jul 2010 10:01:23 +0000"  >&lt;p&gt;I fixed this bug. Patch in attachment. I hope it&apos;s clear enough.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10709" name="Doctrine_Query_Abstract.diff" size="570" author="dbojdo" created="Mon, 26 Jul 2010 10:01:23 +0000" />
                    <attachment id="10036" name="PostgresParamsBugTestCase.php" size="4520" author="corristo" created="Tue, 22 Sep 2009 09:07:18 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>