<!--
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Sat May 25 20:10:12 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+DC+AND+resolution+%3D+Unresolved+AND+assignee+%3D+guilhermeblanco+ORDER+BY+priority+DESC&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+DC+AND+resolution+%3D+Unresolved+AND+assignee+%3D+guilhermeblanco+ORDER+BY+priority+DESC</link>
        <description>An XML representation of a search request</description>
                <language>en-us</language>
                        <issue start="0" end="80" total="80"/>
                <build-info>
            <version>5.2.7</version>
            <build-number>850</build-number>
            <build-date>21-02-2013</build-date>
        </build-info>
<item>
            <title>[DC-926] Doctrine ignored PORTABILITY_FIX_CASE and ATTR_FIELD_CASE settings when building query</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-926</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Setting:&lt;br/&gt;
$conn-&amp;gt;setAttribute(Doctrine_Core::ATTR_PORTABILITY, Doctrine_Core::PORTABILITY_FIX_CASE)&lt;br/&gt;
$conn-&amp;gt;setAttribute(Doctrine_Core::ATTR_FIELD_CASE, CASE_UPPER)&lt;/p&gt;

&lt;p&gt;I expect column names in built queries to be uppercase, but they remain to be lowercase.&lt;/p&gt;</description>
                <environment>Tested on CentOS 5, Ubuntu 10.4, MYSQL and MSSQL databases</environment>
            <key id="12101">DC-926</key>
            <summary>Doctrine ignored PORTABILITY_FIX_CASE and ATTR_FIELD_CASE settings when building query</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/blocker.png">Blocker</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="dziamid">Dziamid Zayankouski</reporter>
                        <labels>
                    </labels>
                <created>Fri, 12 Nov 2010 17:27:10 +0000</created>
                <updated>Fri, 12 Nov 2010 17:29:13 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-972] MySQL field aliases with triple ticks</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-972</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;In revision 7691 something has happened. Ever since I updated my Doctrine to that revision all my queries having &quot; ... fieldname AS aliasname ... &quot; go crazy and make the PHP to throw an exception, like this:&lt;/p&gt;

&lt;p&gt;&apos;Doctrine_Connection_Mysql_Exception&apos; with message &apos;SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;42S22&amp;#93;&lt;/span&gt;: Column not found: 1054 Unknown column &apos;t.`id`&apos; in &apos;field list&apos;.  Failing Query:&lt;br/&gt;
&quot;SELECT `t`.`id` AS `t_&lt;em&gt;id`, `t`.```id``` AS `t&lt;/em&gt;&lt;em&gt;0`, `t`.```name``` AS `t&lt;/em&gt;&lt;em&gt;1`, `t`.`id` AS `t&lt;/em&gt;&lt;em&gt;0`, `t`.`name` AS `t&lt;/em&gt;_1` FROM `territoryCombined` `t` ORDER BY `t`.`name` asc&quot;&apos;&lt;br/&gt;
in ...path here.../doctrine/lib/Doctrine/Connection.php:1082&lt;/p&gt;

&lt;p&gt;The problem is that the DQL parser somewhere along the process encapsualtes aliases in ticks, but then it does it again in lib/Doctrine/Formatter.php : quoteIdentifier() , which is called in lib/Doctrine/Connection : quoteIdentifier() , which is called in lib/Doctrine/Query.php : processPendingFields() @ between lines 485 and 512. The problem is that by the time the alias name gets to line 507 it is already encapsualted in ticks, but it does it again. At the end we end up with ```alias``` , which is not good.&lt;/p&gt;

&lt;p&gt;It only happens to aliases. If I say select(&apos;*&apos;) or select(&quot;t.id, t.name&quot;) then it executes properly. Only the aliases couse problems.&lt;/p&gt;

&lt;p&gt;A test query:&lt;/p&gt;

&lt;p&gt;$vTerritories = Doctrine_Query::create()&lt;br/&gt;
                    -&amp;gt;select(&quot;t.id as territory_id, t.name as territory_name&quot;)&lt;br/&gt;
                    -&amp;gt;from(&apos;TerritoryCombined t&apos;)&lt;br/&gt;
                    -&amp;gt;orderBy(&apos;t.name asc&apos;)&lt;br/&gt;
                    -&amp;gt;fetchArray();&lt;/p&gt;


&lt;p&gt;MY PROPOSED PATCH:&lt;/p&gt;

&lt;p&gt;If I change the Formatter::quoteIdentifier() to this:&lt;/p&gt;

&lt;p&gt;    public function quoteIdentifier($str, $checkOption = true)&lt;/p&gt;
    {
        $tmp = $this-&amp;gt;conn-&amp;gt;identifier_quoting; // I move up this line to here because I need it

        if ( (substr($str, 0, 1) == $tmp[&apos;start&apos;]) &amp;amp;&amp;amp; (substr($str, -1) == $tmp[&apos;end&apos;]) ) return $str; // new line; is it already quoted? if yes, then don&apos;t do it again

        // the rest is unchanged
    }

&lt;p&gt;then it works correctly. Please note I only tested that in MySQL, as we use MySQL in all our projects.&lt;/p&gt;</description>
                <environment>MySQL 5, PHP 5</environment>
            <key id="12396">DC-972</key>
            <summary>MySQL field aliases with triple ticks</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/blocker.png">Blocker</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="hroland">Roland Huszti</reporter>
                        <labels>
                    </labels>
                <created>Wed, 16 Feb 2011 11:14:24 +0000</created>
                <updated>Wed, 16 Feb 2011 11:14:24 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>1</watches>
                                <attachments>
                    <attachment id="10941" name="BaseTerritoryCombined.php" size="2337" author="hroland" created="Wed, 16 Feb 2011 11:14:24 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-665] Named parameters doesn&apos;t work on MSSQL anymore</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-665</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;After upgrading to Doctrine 1.2.2 queries with named arguments doesn&apos;t work anymore.&lt;br/&gt;
Whenever querying like&lt;br/&gt;
                    $query = Doctrine_Query::create();&lt;br/&gt;
                    $customer = $query-&amp;gt;from(&apos;Customers&apos;)&lt;br/&gt;
                                      -&amp;gt;where(&quot;id = :id&quot;&lt;br/&gt;
                                            , array(&apos;id&apos;=&amp;gt;$user&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;customer_id&amp;#39;&amp;#93;&lt;/span&gt;))&lt;br/&gt;
                                      -&amp;gt;fetchOne(array(), Doctrine::HYDRATE_ARRAY);&lt;/p&gt;

&lt;p&gt;I get the error &lt;br/&gt;
SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;HY000&amp;#93;&lt;/span&gt;: General error: 10007 Incorrect syntax near &apos;:&apos;. &lt;span class=&quot;error&quot;&gt;&amp;#91;10007&amp;#93;&lt;/span&gt; (severity 5) &lt;/p&gt;

&lt;p&gt;If changing the query to &lt;br/&gt;
                    $query = Doctrine_Query::create();&lt;br/&gt;
                    $customer = $query-&amp;gt;from(&apos;Customers&apos;)&lt;br/&gt;
                                      -&amp;gt;where(&quot;id = ?&quot;&lt;br/&gt;
                                            , array($user&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;customer_id&amp;#39;&amp;#93;&lt;/span&gt;))&lt;br/&gt;
                                      -&amp;gt;fetchOne(array(), Doctrine::HYDRATE_ARRAY);&lt;br/&gt;
it works fine.&lt;br/&gt;
Testing with MySQL works fine, so it seems contained to MSSQL&lt;/p&gt;
</description>
                <environment>Windows Server 2003. PHP 5.2.12. MS SQL Server 2008</environment>
            <key id="11319">DC-665</key>
            <summary>Named parameters doesn&apos;t work on MSSQL anymore</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/blocker.png">Blocker</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="denpet">Dennis Pettersson</reporter>
                        <labels>
                    </labels>
                <created>Wed, 5 May 2010 10:43:34 +0000</created>
                <updated>Wed, 22 Sep 2010 00:55:15 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="12842" author="denpet" created="Thu, 6 May 2010 03:07:13 +0000"  >&lt;p&gt;Should mention I upgraded from 1.1.6 to 1.2.2, so the problem might be present in earlier 1.2.x versions as well.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-627] Work on link-table and leftJoin</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-627</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Looking at the attachment to see the little schema.&lt;br/&gt;
Tree table : items, items_children and children.&lt;/p&gt;

&lt;p&gt;The link-table items_children is here to create a many-to-many relationships between Items and Children.&lt;/p&gt;

&lt;p&gt;So, after configure the YAML and generated Models.&lt;br/&gt;
We can do something like that :&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;$query	= Doctrine_Query::create ()&lt;br/&gt;
    		-&amp;gt;select (&quot;items.title, children.title&quot;)&lt;br/&gt;
    		-&amp;gt;from (&quot;Item items&quot;)&lt;br/&gt;
    		-&amp;gt;leftJoin (&quot;item.children children&quot;);&lt;br/&gt;
$items = $query-&amp;gt;execute ();&lt;/p&gt;

&lt;p&gt;$items //An array of items&lt;br/&gt;
$items&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;-&amp;gt;title //A string&lt;br/&gt;
$items&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;-&amp;gt;children //An array of children&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;The SQL Output of the query is :&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SELECT `i`.`id_item` AS `i_&lt;em&gt;id_item`, `i`.`title` AS `i&lt;/em&gt;&lt;em&gt;title`, `c`.`id_child` AS `c&lt;/em&gt;&lt;em&gt;id_child`, `c`.`title` AS `c&lt;/em&gt;_title` FROM `items` `i` LEFT JOIN `items_children` `i2` ON (`i`.`id_item` = `i2`.`id_item`) LEFT JOIN `children` `c` ON `i2`.`id_child` = `c`.`id_child` &lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;All array are order by something, in this case it&apos;s a natural order which come from the items_children order into database.&lt;/p&gt;

&lt;p&gt;Now, I want to apply a condition, or a filter on the items_children table.&lt;br/&gt;
If I translate my demand to SQL Query :&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SELECT `i`.`id_item` AS `i_&lt;em&gt;id_item`, `i`.`title` AS `i&lt;/em&gt;&lt;em&gt;title`, `c`.`id_child` AS `c&lt;/em&gt;&lt;em&gt;id_child`, `c`.`title` AS `c&lt;/em&gt;_title` FROM `items` `i` LEFT JOIN `items_children` `i2` ON (`i`.`id_item` = `i2`.`id_item`) LEFT JOIN `children` `c` ON `i2`.`id_child` = `c`.`id_child` ORDER BY `c1`.`index`&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Or something crazy :&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SELECT `i`.`id_item` AS `i_&lt;em&gt;id_item`, `i`.`title` AS `i&lt;/em&gt;&lt;em&gt;title`, `c`.`id_child` AS `c&lt;/em&gt;&lt;em&gt;id_child`, `c`.`title` AS `c&lt;/em&gt;_title` FROM `items` `i` LEFT JOIN `items_children` `i2` ON (`i`.`id_item` = `i2`.`id_item`) LEFT JOIN `children` `c` ON `i2`.`id_child` = `c`.`id_child` WHERE `c1`.`index` &amp;gt; 2&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;But how can I do that with DQL ? Because I have no access to the Link-table.&lt;/p&gt;

&lt;p&gt;Link-Table are use to create many-to-many, that could be OOP array. So we have to be allowed to add &quot;index&quot; to order the result. Also, we have to be allowed to add condition on this tables, like &quot;datePromote&quot; or simply &quot;enabled&quot;.&lt;/p&gt;

&lt;p&gt;The solution should be on the following DQL Query :&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;$query	= Doctrine_Query::create ()&lt;br/&gt;
    		-&amp;gt;select (&quot;items.title, children.title&quot;)&lt;br/&gt;
    		-&amp;gt;from (&quot;Item items&quot;)&lt;br/&gt;
    		-&amp;gt;leftJoin (&quot;item.children children&quot;)&lt;br/&gt;
    		-&amp;gt;leftJoin (&quot;ItemsChildren link_table&quot;)&lt;br/&gt;
    		-&amp;gt;orderBy (&quot;link_table.index&quot;)&lt;br/&gt;
$items = $query-&amp;gt;execute ();&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;But the SQL Output is :&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SELECT `i`.`id_item` AS `i_&lt;em&gt;id_item`, `i`.`title` AS `i&lt;/em&gt;&lt;em&gt;title`, `c`.`id_child` AS `c&lt;/em&gt;&lt;em&gt;id_child`, `c`.`title` AS `c&lt;/em&gt;_title` FROM `items` `i` LEFT JOIN `items_children` `i2` ON (`i`.`id_item` = `i2`.`id_item`) LEFT JOIN `children` `c` ON `i2`.`id_child` = `c`.`id_child`, `items_children` `i3` ORDER BY `i3`.`index` &lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;To conclude, it&apos;s a blocker problem. Because I can&apos;t use a standard DB schema.&lt;/p&gt;

&lt;p&gt;Regards,&lt;br/&gt;
Armetiz.&lt;/p&gt;</description>
                <environment>Windows Seven - WAMP 2.0i</environment>
            <key id="11215">DC-627</key>
            <summary>Work on link-table and leftJoin</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/blocker.png">Blocker</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="armetiz">Thomas Tourlourat - Armetiz</reporter>
                        <labels>
                    </labels>
                <created>Tue, 13 Apr 2010 04:56:01 +0000</created>
                <updated>Tue, 13 Apr 2010 05:07:32 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                    <attachment id="10568" name="composition.png" size="14915" author="armetiz" created="Tue, 13 Apr 2010 04:56:01 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-1009] save() also updates fields which should not be</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-1009</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When I want to do a simple update like this :&lt;/p&gt;

&lt;p&gt; $batches = ExamResultsBatchTable::getInstance()-&amp;gt;retrieveByExamBatchStatus(ExamResultsBatch::valid_status_code);&lt;br/&gt;
foreach($batches as $batch)&lt;br/&gt;
{&lt;br/&gt;
        $batch-&amp;gt;setExamBatchStatusId($batchStatusId);&lt;br/&gt;
        $batch-&amp;gt;setStatusDate(date(&apos;Y-m-d&apos;));&lt;br/&gt;
        $batch-&amp;gt;save();&lt;br/&gt;
}&lt;br/&gt;
Only exam_batch_status_id and status_date should be updated (see screenshot before), but columns exam_batch_status_id ,status_date AND exam_subject_id are updated,with the same value (23) (screenshot after_with_save).&lt;/p&gt;

&lt;p&gt;If I run this:&lt;br/&gt;
        $toto = Doctrine_Query::create()&lt;br/&gt;
                       -&amp;gt;update(&apos;ExamResultsBatch erb&apos;)&lt;br/&gt;
                        -&amp;gt;set(&apos;erb.exam_batch_status_id&apos;, 23)&lt;br/&gt;
                        -&amp;gt;set(&apos;erb.status_date&apos;, date(&apos;Y-m-d&apos;))&lt;br/&gt;
                       &lt;del&gt;&amp;gt;where(&apos;erb.id = ?&apos; , $batch&lt;/del&gt;&amp;gt;getId())&lt;br/&gt;
                       -&amp;gt;execute(); &lt;br/&gt;
Everything is correctly done.&lt;/p&gt;

&lt;p&gt;here is the simpliest case.&lt;/p&gt;

&lt;p&gt;The same problems are signaled on other tables in the database, but different tables can be impacted by one save() (the execute() query still works fine).&lt;/p&gt;

&lt;p&gt;Example : 2 foreign tables will be updated , even if the save() action should only concern the main table, and one field (which is not a foreign key).&lt;br/&gt;
The corresponding foreign key fields in the 2 foreign tables, will be updated with the value given (here 23).&lt;/p&gt;

&lt;p&gt;Because save() is used in a lot of different places in our app, I need to find a solution to fix save(), or if not possible to override it to run a execute()like query.&lt;/p&gt;

&lt;p&gt;Thanks for your help.&lt;br/&gt;
Don&apos;t hesitate to ask if you want more details.&lt;/p&gt;

&lt;p&gt;Yan&lt;/p&gt;</description>
                <environment>Windows server 2003  PHP 5.2.17 / XP PRO 32bits XAMPP PHP 5.3.5&lt;br/&gt;
MSSQL / MYSQL&lt;br/&gt;
Symfony 1.4.6</environment>
            <key id="12702">DC-1009</key>
            <summary>save() also updates fields which should not be</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="2" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/critical.png">Critical</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="karibusan">Yan Urquiza</reporter>
                        <labels>
                    </labels>
                <created>Wed, 8 Jun 2011 15:24:12 +0000</created>
                <updated>Wed, 8 Jun 2011 15:40:42 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                                <attachments>
                    <attachment id="11012" name="after_with_execute.PNG" size="110183" author="karibusan" created="Wed, 8 Jun 2011 15:24:12 +0000" />
                    <attachment id="11011" name="after_with_save.PNG" size="110270" author="karibusan" created="Wed, 8 Jun 2011 15:24:12 +0000" />
                    <attachment id="11010" name="before.PNG" size="108968" author="karibusan" created="Wed, 8 Jun 2011 15:24:12 +0000" />
                    <attachment id="11014" name="retrieveByExamBatchStatus.php" size="1246" author="karibusan" created="Wed, 8 Jun 2011 15:29:50 +0000" />
                    <attachment id="11013" name="schema.yml" size="4243" author="karibusan" created="Wed, 8 Jun 2011 15:29:50 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-347] AddPendingJoinConditions doesn&apos;t work if alias equals model name</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-347</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;If the alias in a from-query is equal to the model name, I get an exception when executing the query after adding a &quot;pendingJoinCondition&quot;.&lt;/p&gt;

&lt;p&gt;See attached testCase.&lt;/p&gt;</description>
                <environment></environment>
            <key id="10594">DC-347</key>
            <summary>AddPendingJoinConditions doesn&apos;t work if alias equals model name</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="2" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/critical.png">Critical</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="jensen83">Christian Jaentsch</reporter>
                        <labels>
                    </labels>
                <created>Wed, 9 Dec 2009 14:51:23 +0000</created>
                <updated>Fri, 29 Jan 2010 06:50:10 +0000</updated>
                                    <version>1.2.1</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="11517" author="hobodave" created="Fri, 29 Jan 2010 03:05:21 +0000"  >&lt;p&gt;I fail to see why you would use an alias that is equal to the model name.&lt;/p&gt;</comment>
                    <comment id="11519" author="jensen83" created="Fri, 29 Jan 2010 06:50:10 +0000"  >&lt;p&gt;To clarify again: Using an alias equal to the model name is the same as not using an alias at all. The built sql is the same afterwards (and the addPendingJoinCondition behaviour is the same as well).&lt;/p&gt;

&lt;p&gt;I would not use an alias equal to the model name myself, but sometimes this is used in Doctrine core, e.g. in Doctrine_Relation_ForeignKey around line 60. So to solve the problem either all the core queries, where no alias or an alias equal to the model name is used, have to be rewritten or the behaviour of a respective query has to be changed somehow so that applying an addPendingJoinCondition is possible even in the given case.&lt;/p&gt;
</comment>
                </comments>
                    <attachments>
                    <attachment id="10223" name="AliasEqualsModelNameTestCase.php" size="2441" author="jensen83" created="Wed, 9 Dec 2009 14:51:23 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-515] HYDRATE_RECORD_HIERARCHY broken with many roots</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-515</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;DB schema:&lt;/p&gt;

&lt;p&gt;Category:&lt;br/&gt;
  actAs:&lt;br/&gt;
    NestedSet:&lt;br/&gt;
      hasManyRoots: true&lt;br/&gt;
      rootColumnName: root_id&lt;br/&gt;
  columns:&lt;br/&gt;
    id:&lt;br/&gt;
      type: integer(4)&lt;br/&gt;
      primary: true&lt;br/&gt;
      autoincrement: true&lt;br/&gt;
    name:&lt;br/&gt;
      type: string(64)&lt;br/&gt;
      notnull: true&lt;br/&gt;
    image: string(64)&lt;br/&gt;
  indexes:&lt;br/&gt;
    tree:&lt;br/&gt;
      fields: &lt;span class=&quot;error&quot;&gt;&amp;#91;lft, rgt, root_id&amp;#93;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Sample data:&lt;/p&gt;

&lt;p&gt;id: &apos;1&apos;                                                                   &lt;br/&gt;
  name: &apos;Przyk&#322;adowa kategoria 1&apos;                                           &lt;br/&gt;
  image: null                                                               &lt;br/&gt;
  root_id: &apos;1&apos;                                                              &lt;br/&gt;
  lft: &apos;1&apos;                                                                  &lt;br/&gt;
  rgt: &apos;6&apos;                                                                  &lt;br/&gt;
  level: &apos;0&apos;                                                                &lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;&lt;p&gt;  id: &apos;2&apos;                                                                   &lt;br/&gt;
  name: &apos;Przyk&#322;adowa kategoria 2&apos;                                           &lt;br/&gt;
  image: null                                                               &lt;br/&gt;
  root_id: &apos;2&apos;&lt;br/&gt;
  lft: &apos;1&apos;&lt;br/&gt;
  rgt: &apos;6&apos;&lt;br/&gt;
  level: &apos;0&apos;&lt;br/&gt;
-&lt;br/&gt;
  id: &apos;3&apos;&lt;br/&gt;
  name: &apos;Przyk&#322;adowa podkategoria 1&apos;&lt;br/&gt;
  image: null&lt;br/&gt;
  root_id: &apos;2&apos;&lt;br/&gt;
  lft: &apos;2&apos;&lt;br/&gt;
  rgt: &apos;5&apos;&lt;br/&gt;
  level: &apos;1&apos;&lt;br/&gt;
-&lt;br/&gt;
  id: &apos;4&apos;&lt;br/&gt;
  name: &apos;Przyk&#322;adowa podkategoria 2&apos;&lt;br/&gt;
  image: null&lt;br/&gt;
  root_id: &apos;2&apos;&lt;br/&gt;
  lft: &apos;3&apos;&lt;br/&gt;
  rgt: &apos;4&apos;&lt;br/&gt;
  level: &apos;2&apos;&lt;br/&gt;
-&lt;br/&gt;
  id: &apos;5&apos;&lt;br/&gt;
  name: teset1&lt;br/&gt;
  image: null&lt;br/&gt;
  root_id: &apos;1&apos;&lt;br/&gt;
  lft: &apos;2&apos;&lt;br/&gt;
  rgt: &apos;5&apos;&lt;br/&gt;
  level: &apos;1&apos;&lt;br/&gt;
-&lt;br/&gt;
  id: &apos;6&apos;&lt;br/&gt;
  name: test2&lt;br/&gt;
  image: null&lt;br/&gt;
  root_id: &apos;1&apos;&lt;br/&gt;
  lft: &apos;3&apos;&lt;br/&gt;
  rgt: &apos;4&apos;&lt;br/&gt;
  level: &apos;2&apos;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;When using HYDRATE_RECORD_HIERARCHY, the first top-level category is empty. Everything is assigned to the other one. Only single-root trees work properly.&lt;/p&gt;</description>
                <environment></environment>
            <key id="10935">DC-515</key>
            <summary>HYDRATE_RECORD_HIERARCHY broken with many roots</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="2" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/critical.png">Critical</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="guilhermeblanco">Guilherme Blanco</assignee>
                                <reporter username="krojew">Kamil Rojewski</reporter>
                        <labels>
                    </labels>
                <created>Mon, 22 Feb 2010 15:30:42 +0000</created>
                <updated>Wed, 9 Jun 2010 03:11:58 +0000</updated>
                                    <version>1.2.0</version>
                                                <component>Nested Set</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="12304" author="krojew" created="Wed, 17 Mar 2010 05:46:20 +0000"  >&lt;p&gt;If you look at Doctrine_Collection::toHierarchy() you&apos;ll notice that there is NO reference to root_id, therefore it treats the entire collection as 1 tree (which is false). The bug is 100% repeatable. I&apos;ve made a fast walkaround ba adding a multi-tree hydrator:&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 MultiRootHydrator &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Hydrator_RecordDriver
{
  &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function hydrateResultSet($stmt)
  {
    $result = parent::hydrateResultSet($stmt);

    $collection = array();
    foreach ($result as $item)
    {
      &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (!isset($collection[$item-&amp;gt;root_id]))
        $collection[$item-&amp;gt;root_id] = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Doctrine_Collection($result-&amp;gt;getTable());

      $collection[$item-&amp;gt;root_id]-&amp;gt;add($item);
    }

    $result = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Doctrine_Collection($result-&amp;gt;getTable());
    foreach ($collection as $tree)
    {
      $tree = $tree-&amp;gt;toHierarchy();
      $record = $tree-&amp;gt;getFirst();

      $result-&amp;gt;add($record, $record-&amp;gt;root_id);
    }

    &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; $result;
  }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It should clarify the problem.&lt;/p&gt;</comment>
                    <comment id="13206" author="jwage" created="Tue, 8 Jun 2010 16:31:25 +0000"  >&lt;p&gt;I think it was intended that you would only convert a single tree to a hierarchy. What would the structure of the returned data be like?&lt;/p&gt;</comment>
                    <comment id="13243" author="krojew" created="Wed, 9 Jun 2010 03:11:58 +0000"  >&lt;p&gt;A Doctrine_Collection with root nodes seems to work fine. It allows to traverse the tree for each root.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-815] Model&apos;s default sorting breaks subqueries</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-815</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;It works except subqueries. Main table&apos;s order is added to subquery and vice versa. SQL query looks like this:&lt;/p&gt;

&lt;p&gt;{{&lt;br/&gt;
SELECT t.id AS t_&lt;em&gt;id FROM ticket&lt;/em&gt;_d_c9999_&lt;em&gt;record t WHERE (t.id = (SELECT MAX(t2.id) AS t2&lt;/em&gt;&lt;em&gt;0 FROM ticket&lt;/em&gt;_d_c9999__record t2 ORDER BY t.id ASC, t2.id ASC)) ORDER BY t.id ASC, t2.id ASC&lt;br/&gt;
}}&lt;/p&gt;

&lt;p&gt;Query fails because there is &amp;gt;&amp;gt;no such column &quot;t.id&quot;&amp;lt;&amp;lt;.&lt;/p&gt;

&lt;p&gt;I include a testcase when it is all visible.&lt;/p&gt;

&lt;p&gt;BTW. there is nothing about that feature (and relation orderBy) in docs. It is only in UPGRADE file.&lt;/p&gt;</description>
                <environment></environment>
            <key id="11752">DC-815</key>
            <summary>Model&apos;s default sorting breaks subqueries</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="2" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/critical.png">Critical</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="extreme">Jacek J&#281;drzejewski</reporter>
                        <labels>
                    </labels>
                <created>Wed, 11 Aug 2010 07:31:23 +0000</created>
                <updated>Mon, 14 Mar 2011 18:01:49 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                <component>Record</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="14064" author="extreme" created="Wed, 25 Aug 2010 07:26:04 +0000"  >&lt;p&gt;Anyone?&lt;/p&gt;</comment>
                    <comment id="15487" author="beverage" created="Thu, 10 Mar 2011 08:57:34 +0000"  >&lt;p&gt;Am having the same issue!&lt;/p&gt;

&lt;p&gt;Eventually found the orderBy option on both the model and on relationships and was over joyed as I&apos;d been trying to find a way of doing this, but it didn&apos;t work!!&lt;/p&gt;

&lt;p&gt;Found the patch &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-651&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/jira/browse/DC-651&lt;/a&gt; which solved the first problem I encountered but now I&apos;m getting this.&lt;/p&gt;</comment>
                    <comment id="15498" author="beverage" created="Mon, 14 Mar 2011 18:01:49 +0000"  >&lt;p&gt;Had a look at the code and tried only setting the orderBy if the current component is actually referenced in the from sql part of the query.&lt;/p&gt;

&lt;p&gt;Looking at what is selected from, &lt;tt&gt;$this-&amp;gt;_sqlParts&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;from&amp;#39;&amp;#93;&lt;/span&gt;&lt;/tt&gt;, it appears that the main table (&lt;tt&gt;$map&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;table&amp;#39;&amp;#93;&lt;/span&gt;-&amp;gt;getTableName()&lt;/tt&gt;) and &lt;tt&gt;$sqlAlias&lt;/tt&gt; is include with a zero index and joined tables are keyed by their &lt;tt&gt;$alias&lt;/tt&gt; (or at least the content of these variables within the loop).&lt;/p&gt;

&lt;p&gt;From this I believe I could detect if the current entry in the loop was from a table that was in the current &quot;FROM&quot; part of the query by looking for the table name and alias as an entry or the current alias as a key in the &quot;FROM&quot; array.&lt;/p&gt;

&lt;p&gt;Within my sub query the orderBy valeus would still get applied but only in the subquery and not in the main query where they were included before, out of scope.&lt;/p&gt;

&lt;p&gt;With patch &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-651&quot; title=&quot;[PATCH] Doctrine_Record::option(&amp;#39;orderBy&amp;#39;, ...) of join&amp;#39;s right side being applied to refTable in m2m relationship&quot;&gt;DC-651&lt;/a&gt; applied my code in Query.php at line 1315 noew looks as follows:&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;
                &lt;span class=&quot;code-comment&quot;&gt;// Note: Only include orderBy values &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; tables we&apos;re actually selecting from (both the root table or
&lt;/span&gt;                &lt;span class=&quot;code-comment&quot;&gt;// tables referenced from it)
&lt;/span&gt;                &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (in_array(&lt;span class=&quot;code-quote&quot;&gt;&quot;{$map[&apos;table&apos;]-&amp;gt;getTableName()} {$sqlAlias}&quot;&lt;/span&gt;, $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_sqlParts[&apos;from&apos;]) || array_key_exists($alias, $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_sqlParts[&apos;from&apos;])) {
                    &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (isset($map[&apos;relation&apos;])) {
                        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (isset($map[&apos;ref&apos;])) {
                            $orderBy = $map[&apos;relation&apos;][&apos;refTable&apos;]-&amp;gt;processOrderBy($sqlAlias, $map[&apos;relation&apos;][&apos;orderBy&apos;], &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;);
                            &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($map[&apos;relation&apos;][&apos;orderBy&apos;] &amp;amp;&amp;amp; $orderBy == $map[&apos;relation&apos;][&apos;orderBy&apos;]) {
                                $orderBy = $map[&apos;relation&apos;]-&amp;gt;getOrderByStatement($sqlAlias, &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;);
                            }
                        } &lt;span class=&quot;code-keyword&quot;&gt;else&lt;/span&gt; {
                            $orderBy = $map[&apos;relation&apos;]-&amp;gt;getOrderByStatement($sqlAlias, &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;);
                            &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($orderBy == $map[&apos;relation&apos;][&apos;orderBy&apos;]) {
                                $orderBy = &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;;
                            }
                        }
                    } &lt;span class=&quot;code-keyword&quot;&gt;else&lt;/span&gt; {
                        $orderBy = $map[&apos;table&apos;]-&amp;gt;getOrderByStatement($sqlAlias, &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;);
                    }
                } &lt;span class=&quot;code-keyword&quot;&gt;else&lt;/span&gt; {
                        $orderBy = &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;;
                }

&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Am I correct in my assumptions?&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10735" name="DC9999TestCase.php" size="997" author="extreme" created="Wed, 11 Aug 2010 07:31:23 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-930] Complex query with DISTINCT and LIMIT on pgsql causes a SQLSTATE exception - problem in doctrine_subquery_alias</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-930</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;There is a problem in the following code in Doctrine/Query.php (lines 1257-1279) inside the buildSqlQuery() method:&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;            $subquery = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getLimitSubquery();

            &lt;span class=&quot;code-comment&quot;&gt;// what about composite keys?
&lt;/span&gt;            $idColumnName = $table-&amp;gt;getColumnName($table-&amp;gt;getIdentifier());

            &lt;span class=&quot;code-keyword&quot;&gt;switch&lt;/span&gt; (strtolower($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_conn-&amp;gt;getDriverName())) {
                &lt;span class=&quot;code-keyword&quot;&gt;case&lt;/span&gt; &apos;mysql&apos;:
[...]
                &lt;span class=&quot;code-keyword&quot;&gt;case&lt;/span&gt; &apos;pgsql&apos;:
                    $subqueryAlias = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_conn-&amp;gt;quoteIdentifier(&apos;doctrine_subquery_alias&apos;);

                    &lt;span class=&quot;code-comment&quot;&gt;// pgsql needs special nested LIMIT subquery
&lt;/span&gt;                    $subquery = &apos;SELECT &apos; . $subqueryAlias . &apos;.&apos; . $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_conn-&amp;gt;quoteIdentifier($idColumnName)
                            . &apos; FROM (&apos; . $subquery . &apos;) AS &apos; . $subqueryAlias;

                    &lt;span class=&quot;code-keyword&quot;&gt;break&lt;/span&gt;;
            }
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The above code is executed when a query consist of DISTINCT and LIMIT clauses. The most common situation is using pager. &lt;br/&gt;
The problem is in the subquery variable. The $idColumnName variable often has value &quot;id&quot;. In such a situation in case of  $subquery consist of some JOINs and some tables have column named &quot;id&quot;, we have:&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; doctrine_subquery_alias.id &lt;span class=&quot;code-keyword&quot;&gt;FROM&lt;/span&gt; ((&lt;span class=&quot;code-keyword&quot;&gt;SELECT&lt;/span&gt; DISTINCT d1.id, d2.id &lt;span class=&quot;code-keyword&quot;&gt;FROM&lt;/span&gt; ...)) AS doctrine_subquery_alias
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;It, of course, causes the &quot;ambiguous column name&quot; pgsql exception.&lt;/p&gt;</description>
                <environment>pgsql</environment>
            <key id="12112">DC-930</key>
            <summary>Complex query with DISTINCT and LIMIT on pgsql causes a SQLSTATE exception - problem in doctrine_subquery_alias</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="j.debowczyk">Jacek D&#281;bowczyk</reporter>
                        <labels>
                    </labels>
                <created>Tue, 16 Nov 2010 09:54:02 +0000</created>
                <updated>Tue, 16 Nov 2010 09:54:02 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-927] Query with left join and group clause returns only one row, even though there are multiple results</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-927</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;under certain circumstances, Doctrine will only return one result out of a bunch of results, for example:&lt;/p&gt;

&lt;p&gt;$ symfony doctrine:dql &quot;from Tafel t, t.Reservering r where t.restaurant_id=4 select date(t.tijd), count(t.id) tafels, count(r.id) reserveringen group by date(t.tijd)&quot;&lt;br/&gt;
&amp;gt;&amp;gt; doctrine  executing dql query&lt;br/&gt;
DQL: from Tafel t, t.Reservering r where t.restaurant_id=4 select date(t.tijd), count(t.id) tafels, count(r.id) reserveringen group by date(t.tijd)&lt;br/&gt;
found 2 results&lt;br/&gt;
-&lt;br/&gt;
  date: &apos;2010-11-14&apos;&lt;br/&gt;
  tafels: &apos;1&apos;&lt;br/&gt;
  reserveringen: &apos;1&apos;&lt;/p&gt;

&lt;p&gt;Expected outcome:&lt;br/&gt;
found 2 results&lt;br/&gt;
-&lt;br/&gt;
  date: &apos;2010-11-14&apos;&lt;br/&gt;
  tafels: &apos;1&apos;&lt;br/&gt;
  reserveringen: &apos;1&apos;&lt;br/&gt;
-&lt;br/&gt;
  date: &apos;2010-11-16&apos;&lt;br/&gt;
  tafels: &apos;1&apos;&lt;br/&gt;
  reserveringen: &apos;0&apos;&lt;/p&gt;

&lt;p&gt;The query works fine without the left join:&lt;br/&gt;
$ symfony doctrine:dql &quot;from Tafel t where t.restaurant_id=4 select date(t.tijd), count(t.id) tafels group by date(t.tijd)&quot;&lt;br/&gt;
&amp;gt;&amp;gt; doctrine  executing dql query&lt;br/&gt;
DQL: from Tafel t  where t.restaurant_id=4 select date(t.tijd), count(t.id) tafels, group by date(t.tijd)&lt;br/&gt;
found 2 results&lt;br/&gt;
-&lt;br/&gt;
  date: &apos;2010-11-14&apos;&lt;br/&gt;
  tafels: &apos;1&apos;&lt;br/&gt;
-&lt;br/&gt;
  date: &apos;2010-11-16&apos;&lt;br/&gt;
  tafels: &apos;1&apos;&lt;/p&gt;</description>
                <environment>Windows 7-64 bit&lt;br/&gt;
Symfony 1.4.8</environment>
            <key id="12102">DC-927</key>
            <summary>Query with left join and group clause returns only one row, even though there are multiple 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="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="dareaper">Bart van den Burg</reporter>
                        <labels>
                    </labels>
                <created>Sun, 14 Nov 2010 07:55:55 +0000</created>
                <updated>Thu, 19 May 2011 07:50:36 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>4</votes>
                        <watches>4</watches>
                        <comments>
                    <comment id="14734" author="dareaper" created="Sun, 14 Nov 2010 07:56:37 +0000"  >&lt;p&gt;As you can see, by the way, it does actually say &quot;found 2 results&quot;, but then returns only one.&lt;/p&gt;</comment>
                    <comment id="15239" author="geckow" created="Tue, 8 Feb 2011 07:08:14 +0000"  >&lt;p&gt;There are multiple reports from people that are hurt by this bug:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.devcomments.com/doctrine-execute-only-returns-one-row-to286270.htm&quot; class=&quot;external-link&quot;&gt;http://www.devcomments.com/doctrine-execute-only-returns-one-row-to286270.htm&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://www.devcomments.com/Problem-with-Doctrine-and-Join-GroupBy-query-at87536.htm&quot; class=&quot;external-link&quot;&gt;http://www.devcomments.com/Problem-with-Doctrine-and-Join-GroupBy-query-at87536.htm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Setting the Hydration-mode to HYDRATE_NONE yields multiple result rows (but is not useful). &lt;/p&gt;</comment>
                    <comment id="15337" author="victoruiz" created="Fri, 18 Feb 2011 13:49:55 +0000"  >&lt;p&gt;Related in some way with multiple order by clauses. If I remove all of them but one it works, the problem appears when I put more than one order by criteria.&lt;/p&gt;</comment>
                    <comment id="15865" author="mikeseth" created="Thu, 19 May 2011 07:50:36 +0000"  >&lt;p&gt;This is a hydration problem that occurs because the ID columns of the joined tables are not SELECT&apos;ed explicitly. The offending code is a loop in the graph base hydrator, but I don&apos;t understand it well enough to fix it with any certainty that I don&apos;t break anything. &lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-920] The ability to add sql in the query between the first word and body of the query (allowing &quot;SELECT STRAIGHT_JOIN&quot; etc)</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-920</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;I recently discovered that I could greatly optimize some of the queries that were being run through our system by adding a STRAIGHT_JOIN keyword to the front of the select&lt;/p&gt;

&lt;p&gt;I added a feature to doctrine which allows me to inject sql into the query in the right place to enable features such as &quot;STRAIGHT_JOIN&quot; but I can&apos;t post the patch because my patches are starting to run together &amp;#8211; the syntax with in the generated patch would also contain parts of other patches I have posted to jira but have not yet been included in the doctrine svn.&lt;/p&gt;

&lt;p&gt;I still wanted to make this post because it will give me a ticket number to base my test cases around.&lt;/p&gt;

&lt;p&gt;Will Ferrer&lt;/p&gt;</description>
                <environment>XP XAMP</environment>
            <key id="12082">DC-920</key>
            <summary>The ability to add sql in the query between the first word and body of the query (allowing &quot;SELECT STRAIGHT_JOIN&quot; etc)</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>
                                <assignee username="guilhermeblanco">Guilherme Blanco</assignee>
                                <reporter username="willf1976">will ferrer</reporter>
                        <labels>
                    </labels>
                <created>Tue, 9 Nov 2010 02:30:49 +0000</created>
                <updated>Tue, 9 Nov 2010 22:25:55 +0000</updated>
                                                                    <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="14698" author="willf1976" created="Tue, 9 Nov 2010 22:25:35 +0000"  >&lt;p&gt;In order to show what this patch fixes I am including my test case for the patch below:&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;&amp;lt;?php
/*
 *  $Id$
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * &lt;span class=&quot;code-quote&quot;&gt;&quot;AS IS&quot;&lt;/span&gt; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the LGPL. For more information, see
 * &amp;lt;http:&lt;span class=&quot;code-comment&quot;&gt;//www.doctrine-project.org&amp;gt;.
&lt;/span&gt; */

/**
 * Doctrine_Ticket_DC920_TestCase
 *
 * @&lt;span class=&quot;code-keyword&quot;&gt;package&lt;/span&gt;     Doctrine
 * @author      Will Ferrer
 * @license     http:&lt;span class=&quot;code-comment&quot;&gt;//www.opensource.org/licenses/lgpl-license.php LGPL
&lt;/span&gt; * @category    &lt;span class=&quot;code-object&quot;&gt;Object&lt;/span&gt; Relational Mapping
 * @link        www.doctrine-project.org
 * @since       1.0
 * @version     $Revision$
 */
class Doctrine_Ticket_DC920_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; function testBeforeBodySelect()
    {
        $q = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Doctrine_Query();
        
        $q-&amp;gt;parseDqlQuery(&lt;span class=&quot;code-quote&quot;&gt;&quot;SELECT DISTINCT STRAIGHT_JOIN u.name, p.id FROM User u LEFT JOIN u.Phonenumber p ON p.phonenumber = &apos;123 123&apos;&quot;&lt;/span&gt;);
		$&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;assertEqual($q-&amp;gt;getSqlQuery(), &lt;span class=&quot;code-quote&quot;&gt;&quot;SELECT DISTINCT STRAIGHT_JOIN e.id AS e__id, e.name AS e__name, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON (p.phonenumber = &apos;123 123&apos;) WHERE (e.type = 0)&quot;&lt;/span&gt;);
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;assertEqual($q-&amp;gt;getDql(), &lt;span class=&quot;code-quote&quot;&gt;&quot;SELECT DISTINCT STRAIGHT_JOIN u.name, p.id FROM User u LEFT JOIN u.Phonenumber p ON p.phonenumber = &apos;123 123&apos;&quot;&lt;/span&gt;);
    }

	&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function testBeforeBodySelectNoneDQL() 
    {
        $q = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Doctrine_Query();
        $q-&amp;gt;select(&lt;span class=&quot;code-quote&quot;&gt;&quot;DISTINCT STRAIGHT_JOIN u.name, p.id&quot;&lt;/span&gt;);
		$q-&amp;gt;from(&apos;User u&apos;);
		$q-&amp;gt;leftJoin(&lt;span class=&quot;code-quote&quot;&gt;&quot;u.Phonenumber p ON (p.phonenumber = &apos;123 123&apos;)&quot;&lt;/span&gt;);
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;assertEqual($q-&amp;gt;getSqlQuery(), &lt;span class=&quot;code-quote&quot;&gt;&quot;SELECT DISTINCT STRAIGHT_JOIN e.id AS e__id, e.name AS e__name, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON (p.phonenumber = &apos;123 123&apos;) WHERE (e.type = 0)&quot;&lt;/span&gt;);
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;assertEqual($q-&amp;gt;getDql(), &lt;span class=&quot;code-quote&quot;&gt;&quot;SELECT DISTINCT STRAIGHT_JOIN u.name, p.id FROM User u LEFT JOIN u.Phonenumber p ON (p.phonenumber = &apos;123 123&apos;)&quot;&lt;/span&gt;);
	}
	
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function testBeforeBodyDelete() 
    {
        $q = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Doctrine_Query();

        $q-&amp;gt;parseDqlQuery(&apos;DELETE IGNORE FROM User&apos;);
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;assertEqual($q-&amp;gt;getSqlQuery(), &apos;DELETE IGNORE FROM entity WHERE (type = 0)&apos;);
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;assertEqual($q-&amp;gt;getDql(), &lt;span class=&quot;code-quote&quot;&gt;&quot;DELETE IGNORE FROM User&quot;&lt;/span&gt;);
    }
	
	&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function testBeforeBodyDeleteNoneDQL() 
    {
        $q = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Doctrine_Query();
        $q-&amp;gt;delete(&apos;IGNORE&apos;);
		$q-&amp;gt;from(&apos;User&apos;);
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;assertEqual($q-&amp;gt;getSqlQuery(), &apos;DELETE IGNORE FROM entity WHERE (type = 0)&apos;);
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;assertEqual($q-&amp;gt;getDql(), &lt;span class=&quot;code-quote&quot;&gt;&quot;DELETE IGNORE FROM User&quot;&lt;/span&gt;);
    }
	
	&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function testBeforeBodyUpdate() 
    {
        $q = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Doctrine_Query();

        $q-&amp;gt;parseDqlQuery(&lt;span class=&quot;code-quote&quot;&gt;&quot;UPDATE IGNORE User u SET u.name = &apos;someone&apos;&quot;&lt;/span&gt;);
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;assertEqual($q-&amp;gt;getSqlQuery(), &lt;span class=&quot;code-quote&quot;&gt;&quot;UPDATE IGNORE entity SET name = &apos;someone&apos; WHERE (type = 0)&quot;&lt;/span&gt;);
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;assertEqual($q-&amp;gt;getDql(), &lt;span class=&quot;code-quote&quot;&gt;&quot;UPDATE IGNORE User u SET u.name = &apos;someone&apos;&quot;&lt;/span&gt;);
    }
	
	&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function testBeforeBodyUpdateNonDql() 
    {
        $q = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Doctrine_Query();
        $q-&amp;gt;update(&apos;IGNORE&apos;);
		$q-&amp;gt;from(&apos;User u&apos;);
		$q-&amp;gt;set(&apos;name&apos;, &lt;span class=&quot;code-quote&quot;&gt;&quot;&apos;someone&apos;&quot;&lt;/span&gt;);
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;assertEqual($q-&amp;gt;getSqlQuery(), &lt;span class=&quot;code-quote&quot;&gt;&quot;UPDATE IGNORE entity SET name = &apos;someone&apos; WHERE (type = 0)&quot;&lt;/span&gt;);
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;assertEqual($q-&amp;gt;getDql(), &lt;span class=&quot;code-quote&quot;&gt;&quot;UPDATE IGNORE User u SET name = &apos;someone&apos;&quot;&lt;/span&gt;);
    }

}

&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-916] fetchOne defect</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-916</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Query fetchOne method now retrieves and hydrates all collection, which can be time consumable. I suggest to add limit 1 in fetchOne method.&lt;/p&gt;</description>
                <environment></environment>
            <key id="12065">DC-916</key>
            <summary>fetchOne defect</summary>
                <type id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/improvement.png">Improvement</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="orlanster">Roman</reporter>
                        <labels>
                    </labels>
                <created>Fri, 5 Nov 2010 04:32:05 +0000</created>
                <updated>Mon, 24 Jan 2011 11:27:24 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="15155" author="gena01" created="Fri, 21 Jan 2011 17:35:47 +0000"  >&lt;p&gt;This is a defect. People assume there&apos;s an implied limit(1) in the query because of fetchOne(). Please fix this, this is pretty serious stuff.&lt;/p&gt;</comment>
                    <comment id="15156" author="gena01" created="Fri, 21 Jan 2011 19:57:54 +0000"  >&lt;p&gt;Doctrine_Table actually &quot;works around&quot; the issue but explicitly doing limit(1) before doing fetchOne():&lt;/p&gt;

&lt;p&gt;public function findOneBy($fieldName, $value, $hydrationMode = null)&lt;/p&gt;
    {
        return $this-&amp;gt;createQuery(&apos;dctrn_find&apos;)
            -&amp;gt;where($this-&amp;gt;buildFindByWhere($fieldName), (array) $value)
            -&amp;gt;limit(1)
            -&amp;gt;fetchOne(array(), $hydrationMode);
    }</comment>
                    <comment id="15171" author="jwage" created="Sun, 23 Jan 2011 14:17:13 +0000"  >&lt;p&gt;Was this always like this or did it change recently?&lt;/p&gt;</comment>
                    <comment id="15179" author="gena01" created="Mon, 24 Jan 2011 11:27:24 +0000"  >&lt;p&gt;Frankly I have no idea. &lt;/p&gt;

&lt;p&gt;Also adding a limit(1) shouldn&apos;t break anything and is straight forward. We would also want to fix findOneBy not to do limit(1) since fetchOne() should take care of this after the fix is in place.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-914] Doctrine_Pager ignores custom COUNT query</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-914</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>
&lt;p&gt;I found some problem when I tried to define custom query for results counting. Defined custom COUNT query is totally ignored and executed default one. I will give you full description of problem bellow.&lt;/p&gt;

&lt;p&gt;We have following source code:&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
$q_select = Doctrine_Query::create ()
-&amp;gt;select ( &apos;DISTINCT p.product_name AS product_name&apos; )
-&amp;gt;from ( &apos;Product p&apos; )
-&amp;gt;where( &apos;p.product_name LIKE ?&apos;, &apos;%motorola%&apos;);
				
$q_count = Doctrine_Query::create ()
-&amp;gt;select ( &apos;COUNT (DISTINCT p.product_name) num_results&apos; )
-&amp;gt;from ( &apos;Product p&apos; )
-&amp;gt;where( &apos;p.product_name LIKE ?&apos;, &apos;%motorola%&apos;);
												
$pager = new Doctrine_Pager( $q_select, 1, 25 );										
$pager-&amp;gt;setCountQuery($q_count);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;Let&apos;s check custom query before calling $pager-&amp;gt;execute() method:&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
echo $pager-&amp;gt;getCountQuery(); 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;Output:&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
SELECT COUNT (DISTINCT p.product_name) num_results FROM Product p WHERE p.product_name LIKE ?
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;Looks like until now is everything is correct.  Let&apos;s call $pager-&amp;gt;execute() method:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
$products = $pager-&amp;gt;execute(); 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;Let&apos;s check executed queries using Symfony SQL queries log panel:&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;SELECT COUNT(*) AS num_results FROM product p WHERE p.product_name LIKE &apos;%motorola%&apos;
7.27s, &quot;doctrine&quot; connection

SELECT DISTINCT p.product_name AS p__0 FROM product p WHERE (p.product_name LIKE &apos;%motorola%&apos;) LIMIT 25
3.25s, &quot;doctrine&quot; connection
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;Executed COUNT query is not same we set using $pager-&amp;gt;setCountQuery($q_count). Our defined custom COUNT query is totally ignored and executed default one:&lt;/p&gt;

&lt;p&gt;INSTEAD OF THIS  CUSTOM COUNT  QUERY:&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;SELECT COUNT (DISTINCT p.product_name) num_results FROM Product p WHERE p.product_name LIKE &apos;%motorola%&apos;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;EXECUTED DEFAULT COUNT QUERY:&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;SELECT COUNT(*) AS num_results FROM product p WHERE p.product_name LIKE &apos;%motorola%&apos;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; </description>
                <environment>Zend Server CE</environment>
            <key id="12058">DC-914</key>
            <summary>Doctrine_Pager ignores custom COUNT query</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="arnlukas">Arnoldas Lukasevicius</reporter>
                        <labels>
                    </labels>
                <created>Tue, 2 Nov 2010 06:23:30 +0000</created>
                <updated>Mon, 7 Nov 2011 22:54:46 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Pager</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="16774" author="blueskypoa" created="Mon, 7 Nov 2011 22:54:46 +0000"  >&lt;p&gt;I found a possible solution to the problem.&lt;/p&gt;

&lt;p&gt;That occurs not because the Pager countQuery but in a method used inside the Query class.&lt;/p&gt;

&lt;p&gt;When you set the Query or CountQuery for Pager and execute it, it calls a Query method called count(). This method by yourself call another Query class method named Query::getCountSqlQuery().&lt;/p&gt;

&lt;p&gt;This method rather than simply execute the query that you passed earlier, simply create a new query.&lt;/p&gt;

&lt;p&gt;Below is a possible solution to the problem:&lt;/p&gt;

&lt;p&gt;Query.php (Doctrine Stable 1.2.4)&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;
--- Query.php	2011-11-07 20:52:48.000000000 -0200
+++ Query.php	2011-11-07 20:51:58.000000000 -0200
@@ -2049,40 +2049,7 @@
         &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (count($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_queryComponents) == 1 &amp;amp;&amp;amp; empty($having)) {
             $q .= $from . $where . $groupby . $having;
         } &lt;span class=&quot;code-keyword&quot;&gt;else&lt;/span&gt; {
-
-            &lt;span class=&quot;code-comment&quot;&gt;// Subselect fields will contain only the pk of root entity
&lt;/span&gt;-            $ta = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_conn-&amp;gt;quoteIdentifier($tableAlias);
-
-            $map = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getRootDeclaration();
-            $idColumnNames = $map[&apos;table&apos;]-&amp;gt;getIdentifierColumnNames();
-
-            $pkFields = $ta . &apos;.&apos; . implode(&apos;, &apos; . $ta . &apos;.&apos;, $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_conn-&amp;gt;quoteMultipleIdentifier($idColumnNames));
-
-            &lt;span class=&quot;code-comment&quot;&gt;// We need to &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; some magic in select fields &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; the query contain anything in having clause
&lt;/span&gt;-            $selectFields = $pkFields;
-
-            &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ( ! empty($having)) {
-                &lt;span class=&quot;code-comment&quot;&gt;// For each field defined in select clause
&lt;/span&gt;-                foreach ($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_sqlParts[&apos;select&apos;] as $field) {
-                    &lt;span class=&quot;code-comment&quot;&gt;// We only include aggregate expressions to count query
&lt;/span&gt;-                    &lt;span class=&quot;code-comment&quot;&gt;// This is needed because HAVING clause will use field aliases
&lt;/span&gt;-                    &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (strpos($field, &apos;(&apos;) !== &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;) {
-                        $selectFields .= &apos;, &apos; . $field;
-                    }
-                }
-                &lt;span class=&quot;code-comment&quot;&gt;// Add having fields that got stripped out of select
&lt;/span&gt;-                preg_match_all(&apos;/`[a-z0-9_]+`\.`[a-z0-9_]+`/i&apos;, $having, $matches, PREG_PATTERN_ORDER);
-                &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (count($matches[0]) &amp;gt; 0) {
-                    $selectFields .= &apos;, &apos; . implode(&apos;, &apos;, array_unique($matches[0]));
-                }
-            }
-
-            &lt;span class=&quot;code-comment&quot;&gt;// If we &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; not have a custom group by, apply the &lt;span class=&quot;code-keyword&quot;&gt;default&lt;/span&gt; one
&lt;/span&gt;-            &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (empty($groupby)) {
-                $groupby = &apos; GROUP BY &apos; . $pkFields;
-            }
-
-            $q .= &apos;(SELECT &apos; . $selectFields . &apos; FROM &apos; . $from . $where . $groupby . $having . &apos;) &apos;
+            $q .= &apos;( &apos;.$&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getSqlQuery().&apos; ) &apos;
                 . $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_conn-&amp;gt;quoteIdentifier(&apos;dctrn_count_query&apos;);
         }
         &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; $q;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-910] Sub queries do not work properly in the on clause of a join</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-910</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When subqueries are used in the on part of a join clause the Doctrine_Query_JoinCondition class does not always create the proper sql. For instance when there are 2 subqueries used in a between doctrine tries to parse the statement as 1 subquery rather 2 subqueries with an &quot;and&quot;. &lt;/p&gt;

&lt;p&gt;I will post my patch that fixes this issue after I make some test cases for it. I also fixed an issue where &quot;(SQL:&quot; syntax was breaking the join as well.&lt;/p&gt;

&lt;p&gt;Will&lt;/p&gt;</description>
                <environment>XP Xamp</environment>
            <key id="12053">DC-910</key>
            <summary>Sub queries do not work properly in the on clause of a join</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="willf1976">will ferrer</reporter>
                        <labels>
                    </labels>
                <created>Mon, 1 Nov 2010 18:54:39 +0000</created>
                <updated>Tue, 2 Nov 2010 00:06:00 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="14658" author="willf1976" created="Tue, 2 Nov 2010 00:06:00 +0000"  >&lt;p&gt;took out some commented code chunks&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10841" name="DC_910_fix.patch" size="11377" author="willf1976" created="Tue, 2 Nov 2010 00:06:00 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-897] Pager ignores default model hasMany ORDER BY statements, caused by getLimitSubquery ignoring same</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-897</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Our model configuration includes several hasMany statements, for example:&lt;/p&gt;

&lt;p&gt;        $this-&amp;gt;hasMany(&apos;Subcategory as Subcategories&apos;, array(&lt;br/&gt;
            &apos;refClass&apos; =&amp;gt; &apos;SubcategoryTone&apos;,&lt;br/&gt;
            &apos;local&apos; =&amp;gt; &apos;tone_id&apos;,&lt;br/&gt;
            &apos;foreign&apos; =&amp;gt; &apos;subcategory_id&apos;,&lt;br/&gt;
            &apos;cascade&apos; =&amp;gt; array(&apos;delete&apos;),&lt;br/&gt;
            &apos;orderBy&apos; =&amp;gt; &apos;order_id&apos;,&lt;br/&gt;
        ));&lt;/p&gt;

&lt;p&gt;We noticed that the ORDER BY directive worked just fine with a normal query, but the order by was being ignored when we fed it into the Pager.&lt;/p&gt;

&lt;p&gt;For example:&lt;br/&gt;
            $aa = $t-&amp;gt;execute(array(), Doctrine_Core::HYDRATE_ARRAY);&lt;br/&gt;
            var_dump($aa&lt;span class=&quot;error&quot;&gt;&amp;#91;4&amp;#93;&lt;/span&gt;);&lt;/p&gt;

&lt;p&gt;            $pager = new Doctrine_Pager($t, $currentPage, $resultsPerPage);&lt;br/&gt;
            $bb = $pager-&amp;gt;execute(array(), Doctrine_Core::HYDRATE_ARRAY);&lt;/p&gt;

&lt;p&gt;            var_dump($bb&lt;span class=&quot;error&quot;&gt;&amp;#91;4&amp;#93;&lt;/span&gt;);&lt;/p&gt;

&lt;p&gt;These two var_dumps would give different results because the ORDER BY is ignored by the limit subquery in the pager.&lt;/p&gt;</description>
                <environment></environment>
            <key id="12025">DC-897</key>
            <summary>Pager ignores default model hasMany ORDER BY statements, caused by getLimitSubquery ignoring same</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="angrygreenfrogs">Andrew Eross</reporter>
                        <labels>
                    </labels>
                <created>Fri, 22 Oct 2010 02:50:21 +0000</created>
                <updated>Wed, 10 Nov 2010 01:41:21 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Pager</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="14593" author="angrygreenfrogs" created="Fri, 22 Oct 2010 03:05:23 +0000"  >&lt;p&gt;I&apos;ve also found a fix for the issue (thanks to George over here for finding the location of the problem) ... we found that simply moving the ORDER BY generation code inside of buildSqlQuery() to be ABOVE the if block containing getLimitSubquery() resolves the issue.&lt;/p&gt;

&lt;p&gt;We&apos;re not super familiar with the Doctrine code-base, so everything looks to work fine after moving the code block, and it fixes the issue, but would love to hear if this is a real fix.&lt;/p&gt;

&lt;p&gt;diff from 1.2.3 via our SVN:&lt;/p&gt;

&lt;p&gt;Index: Query.php&lt;br/&gt;
===================================================================&lt;br/&gt;
&amp;#8212; Query.php   (revision 1120)&lt;br/&gt;
+++ Query.php   (working copy)&lt;br/&gt;
@@ -1256,7 +1256,46 @@&lt;br/&gt;
                 $this-&amp;gt;_sqlParts&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;where&amp;#39;&amp;#93;&lt;/span&gt;[] = &apos;(&apos; . $string . &apos;)&apos;;&lt;br/&gt;
             }&lt;br/&gt;
         }&lt;br/&gt;
+        &lt;br/&gt;
+    // Fix the orderbys so we only have one orderby per value&lt;br/&gt;
+        foreach ($this-&amp;gt;_sqlParts&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;orderby&amp;#39;&amp;#93;&lt;/span&gt; as $k =&amp;gt; $orderBy) {&lt;br/&gt;
+            $e = explode(&apos;, &apos;, $orderBy);&lt;br/&gt;
+            unset($this-&amp;gt;_sqlParts&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;orderby&amp;#39;&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;$k&amp;#93;&lt;/span&gt;);&lt;br/&gt;
+            foreach ($e as $v) &lt;/p&gt;
{
+                $this-&amp;gt;_sqlParts[&apos;orderby&apos;][] = $v;
+            }
&lt;p&gt;+        }&lt;/p&gt;

&lt;p&gt;+        // Add the default orderBy statements defined in the relationships and table classes&lt;br/&gt;
+        // Only do this for SELECT queries&lt;br/&gt;
+        if ($this-&amp;gt;_type === self::SELECT) {&lt;br/&gt;
+            foreach ($this-&amp;gt;_queryComponents as $alias =&amp;gt; $map) {&lt;br/&gt;
+                $sqlAlias = $this-&amp;gt;getSqlTableAlias($alias);&lt;br/&gt;
+                if (isset($map&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;relation&amp;#39;&amp;#93;&lt;/span&gt;)) {&lt;br/&gt;
+                    $orderBy = $map&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;relation&amp;#39;&amp;#93;&lt;/span&gt;-&amp;gt;getOrderByStatement($sqlAlias, true);&lt;br/&gt;
+                    if ($orderBy == $map&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;relation&amp;#39;&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;orderBy&amp;#39;&amp;#93;&lt;/span&gt;) {&lt;br/&gt;
+                        if (isset($map&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;ref&amp;#39;&amp;#93;&lt;/span&gt;)) &lt;/p&gt;
{
+                            $orderBy = $map[&apos;relation&apos;][&apos;refTable&apos;]-&amp;gt;processOrderBy($sqlAlias, $map[&apos;relation&apos;][&apos;orderBy&apos;], true);
+                        }
&lt;p&gt; else &lt;/p&gt;
{
+                            $orderBy = null;
+                        }
&lt;p&gt;+                    }&lt;br/&gt;
+                } else &lt;/p&gt;
{
+                    $orderBy = $map[&apos;table&apos;]-&amp;gt;getOrderByStatement($sqlAlias, true);
+                }
&lt;p&gt;+&lt;br/&gt;
+                if ($orderBy) {&lt;br/&gt;
+                    $e = explode(&apos;,&apos;, $orderBy);&lt;br/&gt;
+                    $e = array_map(&apos;trim&apos;, $e);&lt;br/&gt;
+                    foreach ($e as $v) {&lt;br/&gt;
+                        if ( ! in_array($v, $this-&amp;gt;_sqlParts&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;orderby&amp;#39;&amp;#93;&lt;/span&gt;)) &lt;/p&gt;
{
+                            $this-&amp;gt;_sqlParts[&apos;orderby&apos;][] = $v;
+                        }
&lt;p&gt;+                    }&lt;br/&gt;
+                }&lt;br/&gt;
+            }&lt;br/&gt;
+        }&lt;br/&gt;
+&lt;br/&gt;
         $modifyLimit = true;&lt;br/&gt;
         $limitSubquerySql = &apos;&apos;;&lt;/p&gt;

&lt;p&gt;@@ -1307,47 +1346,8 @@&lt;/p&gt;

&lt;p&gt;             $q .= &apos; WHERE &apos; . $limitSubquerySql . $where;&lt;br/&gt;
             //   .  (($limitSubquerySql == &apos;&apos; &amp;amp;&amp;amp; count($this-&amp;gt;_sqlParts&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;where&amp;#39;&amp;#93;&lt;/span&gt;) == 1) ? substr($where, 1, -1) : $where);&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;}&lt;br/&gt;
+        }        &lt;/li&gt;
&lt;/ul&gt;


&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;// Fix the orderbys so we only have one orderby per value&lt;/li&gt;
	&lt;li&gt;foreach ($this-&amp;gt;_sqlParts&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;orderby&amp;#39;&amp;#93;&lt;/span&gt; as $k =&amp;gt; $orderBy) {&lt;/li&gt;
	&lt;li&gt;$e = explode(&apos;, &apos;, $orderBy);&lt;/li&gt;
	&lt;li&gt;unset($this-&amp;gt;_sqlParts&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;orderby&amp;#39;&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;$k&amp;#93;&lt;/span&gt;);&lt;/li&gt;
	&lt;li&gt;foreach ($e as $v) 
{
-                $this-&amp;gt;_sqlParts[&apos;orderby&apos;][] = $v;
-            }&lt;/li&gt;
	&lt;li&gt;}&lt;br/&gt;
-&lt;/li&gt;
	&lt;li&gt;// Add the default orderBy statements defined in the relationships and table classes&lt;/li&gt;
	&lt;li&gt;// Only do this for SELECT queries&lt;/li&gt;
	&lt;li&gt;if ($this-&amp;gt;_type === self::SELECT) {&lt;/li&gt;
	&lt;li&gt;foreach ($this-&amp;gt;_queryComponents as $alias =&amp;gt; $map) {&lt;/li&gt;
	&lt;li&gt;$sqlAlias = $this-&amp;gt;getSqlTableAlias($alias);&lt;/li&gt;
	&lt;li&gt;if (isset($map&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;relation&amp;#39;&amp;#93;&lt;/span&gt;)) {&lt;/li&gt;
	&lt;li&gt;$orderBy = $map&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;relation&amp;#39;&amp;#93;&lt;/span&gt;-&amp;gt;getOrderByStatement($sqlAlias, true);&lt;/li&gt;
	&lt;li&gt;if ($orderBy == $map&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;relation&amp;#39;&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;orderBy&amp;#39;&amp;#93;&lt;/span&gt;) {&lt;/li&gt;
	&lt;li&gt;if (isset($map&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;ref&amp;#39;&amp;#93;&lt;/span&gt;)) 
{
-                            $orderBy = $map[&apos;relation&apos;][&apos;refTable&apos;]-&amp;gt;processOrderBy($sqlAlias, $map[&apos;relation&apos;][&apos;orderBy&apos;], true);
-                        }
&lt;p&gt; else &lt;/p&gt;
{
-                            $orderBy = null;
-                        }&lt;/li&gt;
	&lt;li&gt;}&lt;/li&gt;
	&lt;li&gt;} else 
{
-                    $orderBy = $map[&apos;table&apos;]-&amp;gt;getOrderByStatement($sqlAlias, true);
-                }
&lt;p&gt;-&lt;/p&gt;&lt;/li&gt;
	&lt;li&gt;if ($orderBy) {&lt;/li&gt;
	&lt;li&gt;$e = explode(&apos;,&apos;, $orderBy);&lt;/li&gt;
	&lt;li&gt;$e = array_map(&apos;trim&apos;, $e);&lt;/li&gt;
	&lt;li&gt;foreach ($e as $v) {&lt;/li&gt;
	&lt;li&gt;if ( ! in_array($v, $this-&amp;gt;_sqlParts&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;orderby&amp;#39;&amp;#93;&lt;/span&gt;)) 
{
-                            $this-&amp;gt;_sqlParts[&apos;orderby&apos;][] = $v;
-                        }&lt;/li&gt;
	&lt;li&gt;}&lt;/li&gt;
	&lt;li&gt;}&lt;/li&gt;
	&lt;li&gt;}&lt;/li&gt;
	&lt;li&gt;}&lt;br/&gt;
-&lt;br/&gt;
         $q .= ( ! empty($this-&amp;gt;_sqlParts&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;groupby&amp;#39;&amp;#93;&lt;/span&gt;)) ? &apos; GROUP BY &apos; . implode(&apos;, &apos;, $this-&amp;gt;_sqlParts&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;groupby&amp;#39;&amp;#93;&lt;/span&gt;)  : &apos;&apos;;&lt;br/&gt;
         $q .= ( ! empty($this-&amp;gt;_sqlParts&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;having&amp;#39;&amp;#93;&lt;/span&gt;)) ?  &apos; HAVING &apos;   . implode(&apos; AND &apos;, $this-&amp;gt;_sqlParts&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;having&amp;#39;&amp;#93;&lt;/span&gt;): &apos;&apos;;&lt;br/&gt;
         $q .= ( ! empty($this-&amp;gt;_sqlParts&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;orderby&amp;#39;&amp;#93;&lt;/span&gt;)) ? &apos; ORDER BY &apos; . implode(&apos;, &apos;, $this-&amp;gt;_sqlParts&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;orderby&amp;#39;&amp;#93;&lt;/span&gt;)  : &apos;&apos;;&lt;br/&gt;
@@ -1396,7 +1396,7 @@&lt;br/&gt;
             $subquery = &apos;SELECT DISTINCT &apos;;&lt;br/&gt;
         }&lt;br/&gt;
         $subquery .= $this-&amp;gt;_conn-&amp;gt;quoteIdentifier($primaryKey);&lt;br/&gt;
-&lt;br/&gt;
+        &lt;br/&gt;
         // pgsql &amp;amp; oracle need the order by fields to be preserved in select clause&lt;br/&gt;
         if ($driverName == &apos;pgsql&apos; || $driverName == &apos;oracle&apos; || $driverName == &apos;oci&apos; || $driverName == &apos;mssql&apos; || $driverName == &apos;odbc&apos;) {&lt;br/&gt;
             foreach ($this-&amp;gt;_sqlParts&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;orderby&amp;#39;&amp;#93;&lt;/span&gt; as $part) 
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unknown macro: {@@ -1420,7 +1420,7 @@                         // don&amp;#39;t add primarykey column (its already in the select clause)                         if ($part !== $primaryKey) {
                             $subquery .= &apos;, &apos; . $partOriginal;
-                        }+                        }&lt;/span&gt; &lt;/div&gt;
&lt;p&gt; &lt;br/&gt;
                     }&lt;br/&gt;
                 }&lt;br/&gt;
             }&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Property changes on: Query.php&lt;br/&gt;
___________________________________________________________________&lt;br/&gt;
Deleted: svn:keywords&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Id Revision&lt;br/&gt;
Deleted: svn:eol-style&lt;/li&gt;
	&lt;li&gt;LF&lt;/li&gt;
&lt;/ul&gt;
</comment>
                    <comment id="14594" author="angrygreenfrogs" created="Fri, 22 Oct 2010 03:05:58 +0000"  >&lt;p&gt;Diff file&lt;/p&gt;</comment>
                    <comment id="14700" author="angrygreenfrogs" created="Wed, 10 Nov 2010 01:41:14 +0000"  >&lt;p&gt;patch -p0 ./libs/doctrine/Doctrine/Query.php ./Doctrine_Query.php.ORDERBY.patch&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10856" name="Doctrine_Query.php.ORDERBY.patch" size="5166" author="angrygreenfrogs" created="Wed, 10 Nov 2010 01:41:14 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-889] Using RANDOM() AS rand as last field WITHOUT a comma between them works, but not randomly</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-889</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;The difference between the two code samples below is that there is a comma after &apos;lo.postal&apos;_code in the second example:&lt;/p&gt;

&lt;p&gt;This code DOES NOT RANDOMIZE But also DOES NOT PRODUCE A PARSER ERROR&lt;br/&gt;
$q = Doctrine_Query::create()&lt;br/&gt;
                            -&amp;gt;select(&quot;li.id,&lt;br/&gt;
                                      ap.name, &lt;br/&gt;
                                      act.title, act.title_short, act.family_friendly, &lt;br/&gt;
                                      o.unix_ts_begin, o.unix_ts_end, &lt;br/&gt;
                                      act.description, &lt;br/&gt;
                                      act.cost_min, act.tags, act.cost_min, act.cost_notes, act.organization, &lt;br/&gt;
                                      lo.thoroughfare, lo.address_extra, lo.locality, lo.administrative_area, lo.country_name_code, lo.postal_code&lt;br/&gt;
                                      RANDOM() AS rand&quot;)&lt;br/&gt;
                             -&amp;gt;from(blah, blah)&lt;br/&gt;
                             -&amp;gt;where(primary key equality statements for joining)&lt;br/&gt;
                             -&amp;gt;orderBy(&apos;rand&apos;);&lt;/p&gt;

&lt;p&gt;This DOES&lt;br/&gt;
$q = Doctrine_Query::create()&lt;br/&gt;
                            -&amp;gt;select(&quot;li.id,&lt;br/&gt;
                                      ap.name, &lt;br/&gt;
                                      act.title, act.title_short, act.family_friendly, &lt;br/&gt;
                                      o.unix_ts_begin, o.unix_ts_end, &lt;br/&gt;
                                      act.description, &lt;br/&gt;
                                      act.cost_min, act.tags, act.cost_min, act.cost_notes, act.organization, &lt;br/&gt;
                                      lo.thoroughfare, lo.address_extra, lo.locality, lo.administrative_area, lo.country_name_code, lo.postal_code,&lt;br/&gt;
                                      RANDOM() AS rand&quot;)&lt;br/&gt;
                             -&amp;gt;from(blah, blah)&lt;br/&gt;
                             -&amp;gt;where(primary key equality statements for joining)&lt;br/&gt;
                             -&amp;gt;orderBy(&apos;rand&apos;);&lt;/p&gt;

</description>
                <environment>ubuntu 64 bit, using a task in symfony</environment>
            <key id="12007">DC-889</key>
            <summary>Using RANDOM() AS rand as last field WITHOUT a comma between them works, but not randomly</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="gearond">Dennis Gearon</reporter>
                        <labels>
                    </labels>
                <created>Thu, 14 Oct 2010 00:22:30 +0000</created>
                <updated>Thu, 14 Oct 2010 00:22:30 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-877] Hydrator fatal error: Found non-unique key mapping named &apos;lang&apos;</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-877</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;You could find the ticket&apos;s test case in the attachments.&lt;/p&gt;</description>
                <environment>PHP 5.2.13</environment>
            <key id="11967">DC-877</key>
            <summary>Hydrator fatal error: Found non-unique key mapping named &apos;lang&apos;</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="fruit">Ilya Sabelnikov</reporter>
                        <labels>
                    </labels>
                <created>Thu, 30 Sep 2010 10:08:55 +0000</created>
                <updated>Fri, 22 Oct 2010 06:04:32 +0000</updated>
                                                                    <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                    <attachment id="10829" name="Ticket_DC877_TestCase.php" size="4859" author="fruit" created="Fri, 22 Oct 2010 06:04:10 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-874] Allow parameters to be passed to Doctrine_Query::select()</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-874</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;While I believe it&apos;s not so extraordinary to have parameters in a SELECT clause, Doctrine_Query::select() does not allow to pass parameters, next to the SELECT clause. You can still pass any parameters to execute(), but I do believe it would be nice to be able to pass the parameter values right away to select() as you can with where() etc.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;Doctrine_Query::create()&lt;del&gt;&amp;gt;select(&apos;f.*, (f.id = ?) AS selected&apos;))&lt;/del&gt;&amp;gt;from(&apos;Foo f&apos;)-&amp;gt;execute(array($selected_id));&lt;/p&gt;

&lt;p&gt;This principle would apply to any select-field that has a calculated value that comes from a parameter.&lt;/p&gt;</description>
                <environment>Any</environment>
            <key id="11964">DC-874</key>
            <summary>Allow parameters to be passed to Doctrine_Query::select()</summary>
                <type id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/improvement.png">Improvement</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="gerryvdm">Gerry Vandermaesen</reporter>
                        <labels>
                    </labels>
                <created>Thu, 30 Sep 2010 06:04:19 +0000</created>
                <updated>Thu, 23 Dec 2010 05:49:10 +0000</updated>
                                                                    <component>Query</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="14999" author="leszczu" created="Thu, 23 Dec 2010 05:49:10 +0000"  >&lt;p&gt;I believe this should be major improvement for Doctrine. Without this feature, some queries can&apos;t be created.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-876] Basic Request return one element.</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-876</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;h4&gt;&lt;a name=&quot;itrytogetallpreferenceswithanIdUserspecified.&quot;&gt;&lt;/a&gt;i try to get all preferences with an IdUser specified.&lt;/h4&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;schema.yml&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;UserHasPreference:
  connection: hopscore
  actAs:
    I18n:
      fields: [value]
    Timestampable:
      created:
        name: created_at
        type: timestamp
        format: Y-m-d H:i:s
  columns:
    idUserHasPreference:
      name: idUserHasPreference as id
      type: integer(4)
      unsigned: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      primary: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      autoincrement: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    UsersIdUser:
      name: UsersIdUser as idUser
      type: integer(4)
      unsigned: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    PreferencesIdPreference:
      name: PreferencesIdPreference as idPreference
      type: integer(4)
      unsigned: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    MatchLinksMatchLinkId:
      name: MatchLinksMatchLinkId as MatchLinkId
      type: integer(4)
      unsigned: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    value:
      type: string(100)
  relations:
    Users:
      class: User
      local: idUser
      foreign: id
      type: one
    Preferences:
      class: Preference
      local: idPreference
      foreign: id
      type: one
    MatchLinks:
      class: MatchLink
      local: MatchLinkId
      foreign: id
      type: one
  options:
    collate: utf8_unicode_ci
    charset: utf8
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&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;Doctrine Request&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;$preferences = Doctrine_Query::create()
		-&amp;gt;select(&apos;uhp.idPreference as idPref&apos;)
		-&amp;gt;addSelect(&apos;uhpt.value as value&apos;)
		-&amp;gt;addSelect(&apos;uhp.MatchLinkId as idItem&apos;)
		-&amp;gt;from(&apos;UserHasPreference uhp&apos;)
		-&amp;gt;innerJoin(&apos;uhp.Translation uhpt&apos;)
		-&amp;gt;where(&apos;uhp.idUser = ?&apos;, intval($idUser))
		-&amp;gt;execute(array(), Doctrine::HYDRATE_ARRAY);
	    &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; $preferences;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;With $preferences-&amp;gt;getSqlQuery(); and getParams(); and report this SQL query in phpmydadmin.&lt;br/&gt;
With SQL i have 13 elements. But in my object &lt;b&gt;$preference&lt;/b&gt; i have one element (Doctrine::HYDRATE_ARRAY)&lt;br/&gt;
With &quot;Doctrine::HYDRATE_NONE&quot;,  i have 13 elements as SQL query.&lt;/p&gt;</description>
                <environment>Windows XP Pro. Service Pack 3, Eclipe PDT, Doctrine 1.2.3,  Php 5.2.11</environment>
            <key id="11966">DC-876</key>
            <summary>Basic Request return one element.</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="rudy.bruneau">rudybruneau</reporter>
                        <labels>
                    </labels>
                <created>Thu, 30 Sep 2010 08:47:10 +0000</created>
                <updated>Tue, 5 Oct 2010 08:08:38 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="14529" author="eirikhm" created="Tue, 5 Oct 2010 08:08:38 +0000"  >&lt;p&gt;I have the same problem, and I think this is related to the select statement. It seems that a select statement where all fields are aliased will cause this behavior. A simple work-around is to select one field without aliasing it. &lt;/p&gt;


&lt;p&gt;Code for reproducing / work-around:&lt;/p&gt;

&lt;p&gt;$query = Doctrine_Query::create();        &lt;br/&gt;
$query-&amp;gt;from(&apos;Results r&apos;);&lt;br/&gt;
$query-&amp;gt;select(&apos;p.id as myid, r.value as foo&apos;);&lt;br/&gt;
$query-&amp;gt;innerJoin(&apos;r.Profil p on (r.pid=123)&apos;);&lt;br/&gt;
$results = $query-&amp;gt;execute(array(), Doctrine_Core::HYDRATE_ARRAY);&lt;/p&gt;

&lt;p&gt;count($results) = 1&lt;/p&gt;


&lt;p&gt;$query = Doctrine_Query::create();        &lt;br/&gt;
$query-&amp;gt;from(&apos;Results r&apos;);&lt;br/&gt;
$query-&amp;gt;select(&apos;p.id as myid, r.value&apos;);&lt;br/&gt;
$query-&amp;gt;innerJoin(&apos;r.Profil p on (r.pid=123)&apos;);&lt;br/&gt;
$results = $query-&amp;gt;execute(array(), Doctrine_Core::HYDRATE_ARRAY);&lt;/p&gt;

&lt;p&gt;count($results) = 250&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10817" name="image.jpg" size="27934" author="rudy.bruneau" created="Thu, 30 Sep 2010 08:47:10 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-873] Update Execute Params do not persist </title>
                <link>http://www.doctrine-project.org/jira/browse/DC-873</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;I have been trying to update numerous records with the one doctrine_query object (which could be my problem) and passing the query execute params to persist to the dbase. eg&lt;/p&gt;

&lt;p&gt;$q = Doctrine_Query::create()&lt;br/&gt;
            -&amp;gt;update(&apos;TdPackageType pt&apos;)&lt;br/&gt;
            -&amp;gt;set(&apos;pt.name&apos;, &apos;?&apos;)&lt;br/&gt;
            -&amp;gt;set(&apos;pt.group_type_id&apos;, &apos;?&apos;)&lt;br/&gt;
            -&amp;gt;where(&apos;pt.id = ?&apos;)&lt;br/&gt;
            ;&lt;/p&gt;

&lt;p&gt;Then iterating over an array of values, passing the required values to the execute method eg&lt;br/&gt;
foreach($foobars as $foobar) {&lt;br/&gt;
   $q-&amp;gt;execute(array($foobar&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;, $foobar&lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt;, $foobar&lt;span class=&quot;error&quot;&gt;&amp;#91;2&amp;#93;&lt;/span&gt;));&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;I thought this the best way by creating only the one query instance and then assigning the vars as required. Trouble being, the data did not persist? I had no errors returned from Doctrine - eg I had the correct number of matched params - but the update would not update. To move on I ended up instantiating a new query object each time I iterated over my array of data values. eg&lt;/p&gt;

&lt;p&gt;foreach($foobars as $foobar) {&lt;/p&gt;

&lt;p&gt;$q = Doctrine_Query::create()&lt;br/&gt;
            -&amp;gt;update(&apos;TdPackageType pt&apos;)&lt;br/&gt;
            -&amp;gt;set(&apos;pt.name&apos;, &apos;?&apos;, $foo&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;)&lt;br/&gt;
            -&amp;gt;set(&apos;pt.group_type_id&apos;, &apos;?&apos;, $foo&lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt;)&lt;br/&gt;
            -&amp;gt;where(&apos;pt.id = ?&apos;, $foo&lt;span class=&quot;error&quot;&gt;&amp;#91;2&amp;#93;&lt;/span&gt;)&lt;br/&gt;
            ;&lt;/p&gt;

&lt;p&gt;            $q-&amp;gt;execute();&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;The values did then persist correctly to the dbase? Am I missing something really fundamental here? eg I would have thought the first code struct was a much better design to re-use the one query object. Or is it as silly as me not adding a hydration method to the execute method?&lt;/p&gt;

&lt;p&gt;Any all help appreciated.&lt;br/&gt;
Thanks&lt;br/&gt;
Kyle&lt;/p&gt;</description>
                <environment>LAMP php5.2.6 Symfony 1.4 </environment>
            <key id="11957">DC-873</key>
            <summary>Update Execute Params do not persist </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="kylerclarke">Kyle Clarke</reporter>
                        <labels>
                    </labels>
                <created>Sun, 26 Sep 2010 20:57:19 +0000</created>
                <updated>Sun, 26 Sep 2010 20:57:19 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-1010] When putting a subquery in the where clause which includes a join and a limit the limit subquery algorithm mistakenly modifies the subquery</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-1010</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;I have fixed this in my own version of doctrine but unfortunately I am to far diverged from the trunk to offer a patch.&lt;/p&gt;

&lt;p&gt;here is a 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;&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function testSubqueryInWhereWithJoinAndLimit()
    {
        $q = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Doctrine_Query();
        $q-&amp;gt;select(&apos;u.id&apos;);
        $q-&amp;gt;from(&apos;User u&apos;);
        $q-&amp;gt;where(&apos;u.id NOT IN (SELECT a.id FROM User u2 LEFT JOIN u2.Album a LIMIT 1)&apos;);
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;assertEqual($q-&amp;gt;getSqlQuery(), &apos;SELECT e.id AS e__id FROM entity e WHERE (e.id NOT IN (SELECT a.id AS a__id FROM entity e2 LEFT JOIN album a ON e2.id = a.user_id WHERE (e2.type = 0) LIMIT 1) AND (e.type = 0))&apos;);
    }
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To fix the issue I changed this line in Doctrine_Query as follows:&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;&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ( ( ! empty($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_sqlParts[&apos;limit&apos;]) || ! empty($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_sqlParts[&apos;offset&apos;])) &amp;amp;&amp;amp; $needsSubQuery &amp;amp;&amp;amp; $limitSubquery) {
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;=&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;&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ( ( ! empty($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_sqlParts[&apos;limit&apos;]) || ! empty($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_sqlParts[&apos;offset&apos;])) &amp;amp;&amp;amp; $needsSubQuery &amp;amp;&amp;amp; $limitSubquery &amp;amp;&amp;amp; !$&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;isSubquery()) {
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Hope that helps.&lt;/p&gt;

&lt;p&gt;Sincerely&lt;/p&gt;

&lt;p&gt;Will Ferrer&lt;/p&gt;</description>
                <environment>XP Xamp</environment>
            <key id="12728">DC-1010</key>
            <summary>When putting a subquery in the where clause which includes a join and a limit the limit subquery algorithm mistakenly modifies the subquery</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="willf1976">will ferrer</reporter>
                        <labels>
                    </labels>
                <created>Tue, 21 Jun 2011 01:44:36 +0000</created>
                <updated>Tue, 21 Jun 2011 01:46:55 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-1008] missing oci_type in Doctrine_Adapter_Statement_Oracle-&gt;bindParam</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-1008</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;in bindParam method there is:&lt;br/&gt;
switch ($type) {&lt;br/&gt;
            case Doctrine_Core::PARAM_STR:&lt;br/&gt;
                $oci_type = SQLT_CHR;&lt;br/&gt;
             break;&lt;br/&gt;
}&lt;br/&gt;
I think there should be other oci_types too. I had to add:&lt;br/&gt;
case Doctrine_Core::PARAM_INT:&lt;br/&gt;
                $oci_type = SQLT_INT;&lt;br/&gt;
because I got ORA-06502: PL/SQL: numeric or value error: character string buffer too small. while executing&lt;br/&gt;
$stmt-&amp;gt;bindParam(&quot;:result&quot;, $result,  Doctrine_Core::PARAM_INT);&lt;/p&gt;

&lt;p&gt;After adding SQLT_INT everything is ok&lt;/p&gt;</description>
                <environment></environment>
            <key id="12685">DC-1008</key>
            <summary>missing oci_type in Doctrine_Adapter_Statement_Oracle-&gt;bindParam</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="madeyt">Tomasz Madeyski</reporter>
                        <labels>
                    </labels>
                <created>Tue, 31 May 2011 08:51:35 +0000</created>
                <updated>Tue, 31 May 2011 08:51:35 +0000</updated>
                                    <version>1.2.4</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-1000] Wrong parsing on HAVING clause</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-1000</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;With Doctrine::ATTR_QUOTE_IDENTIFIER enabled, when you launch a query with a complex having clause, Doctrine_Query_Having class does not handle it correctly.&lt;/p&gt;

&lt;p&gt;By example, when you track the having clause interpretation:&lt;/p&gt;

&lt;p&gt;$query-&amp;gt;addHaving( &apos;SUM( IF( s.id = ? , 1 , 0 ) ) = 0&apos; , 7 );&lt;/p&gt;

&lt;p&gt;At some point, Doctrine_Query_Having at line 70 return something like &quot;`s10`.`id = ?`&quot; instead of  &quot;`s10`.`id` = ?&quot;.&lt;/p&gt;

&lt;p&gt;I just fix it using: &lt;/p&gt;

&lt;p&gt;return $this-&amp;gt;query-&amp;gt;parseClause($func);&lt;/p&gt;

&lt;p&gt;instead of:&lt;/p&gt;

&lt;p&gt;return $this-&amp;gt;_parseAliases($func);&lt;/p&gt;

&lt;p&gt;Now, the parseAliases function is not used anymore...&lt;/p&gt;

&lt;p&gt;See patch attached...&lt;/p&gt;

&lt;p&gt;Loops&lt;/p&gt;</description>
                <environment>symfony 1.4.12-DEV / Windows XP / Apache 2.0 / MySQL 5.1.37 / PHP 5.3.0</environment>
            <key id="12588">DC-1000</key>
            <summary>Wrong parsing on HAVING clause</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="loops">Pierrot Evrard</reporter>
                        <labels>
                    </labels>
                <created>Thu, 28 Apr 2011 04:54:42 +0000</created>
                <updated>Thu, 28 Apr 2011 05:19:36 +0000</updated>
                                    <version>1.2.4</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                    <attachment id="10977" name="Doctrine-DC-1000.patch" size="383" author="loops" created="Thu, 28 Apr 2011 05:19:36 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-997] Doctrine collections are overwritten when created by inner join queries that agree on the WHERE</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-997</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;In brief:&lt;br/&gt;
Doing $result1 = Doctrine_Query::create()&lt;del&gt;&amp;gt;... followed by $result2 = Doctrine_Query::create()&lt;/del&gt;&amp;gt;... can lead to a situation where the content of $result1 has become the value in $result2.&lt;/p&gt;

&lt;p&gt;In detail:&lt;br/&gt;
The attached models.yml defines two simple tables with a One-to-Many relationship; we have people and names and each person can have multiple names.  The DB can be propagated along the lines of:&lt;/p&gt;

&lt;p&gt;INSERT INTO `tblname` VALUES (1,1,&apos;alpha&apos;),(2,2,&apos;beta&apos;),(3,3,&apos;gamma&apos;),(4,4,&apos;delta&apos;),(5,5,&apos;epsilon&apos;),(6,1,&apos;aleph&apos;);&lt;br/&gt;
INSERT INTO `tblperson` VALUES (1),(2),(3),(4),(5);&lt;/p&gt;

&lt;p&gt;Applying the query:&lt;/p&gt;

&lt;p&gt;$results1 = Doctrine_Query::create()&lt;br/&gt;
      -&amp;gt;from(&apos;Person ppa&apos;)&lt;br/&gt;
      -&amp;gt;innerJoin(&apos;ppa.Name n&apos;)&lt;br/&gt;
      -&amp;gt;where(&apos;ppa.id = ?&apos;, 1)&lt;br/&gt;
      -&amp;gt;andWhere(&apos;n.text = ?&apos;, &apos;alpha&apos;)&lt;br/&gt;
      -&amp;gt;execute()&lt;br/&gt;
      -&amp;gt;getFirst()&lt;br/&gt;
      -&amp;gt;Name;&lt;/p&gt;

&lt;p&gt;and then producing output though&lt;/p&gt;

&lt;p&gt;print &apos;Results (1): &apos;.count($results1).&quot;\n&quot;;&lt;br/&gt;
foreach ($results1 as $result) print $result&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;text&amp;#39;&amp;#93;&lt;/span&gt; . &quot;\n&quot;;  &lt;br/&gt;
print &quot;\n\n&quot;;&lt;/p&gt;

&lt;p&gt;produces the expected:&lt;/p&gt;

&lt;p&gt;Results (1): 1&lt;br/&gt;
alpha&lt;/p&gt;

&lt;p&gt;Doing a similarly query to a new variable:&lt;/p&gt;

&lt;p&gt;$results2 = Doctrine_Query::create()&lt;br/&gt;
      -&amp;gt;from(&apos;Person ppa&apos;)&lt;br/&gt;
      -&amp;gt;innerJoin(&apos;ppa.Name n&apos;)&lt;br/&gt;
      -&amp;gt;where(&apos;ppa.id = ?&apos;, 1)&lt;br/&gt;
      -&amp;gt;andWhere(&apos;n.text = ?&apos;, &apos;aleph&apos;)&lt;br/&gt;
      -&amp;gt;execute()&lt;br/&gt;
      -&amp;gt;getFirst()&lt;br/&gt;
      -&amp;gt;Name;&lt;/p&gt;

&lt;p&gt;and printing with&lt;/p&gt;

&lt;p&gt;print &apos;Results (2): &apos;.count($results2).&quot;\n&quot;;&lt;br/&gt;
foreach ($results2 as $result) print $result&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;text&amp;#39;&amp;#93;&lt;/span&gt; . &quot;\n&quot;;  &lt;br/&gt;
print &quot;\n\n&quot;;&lt;/p&gt;

&lt;p&gt;produces the expected:&lt;/p&gt;

&lt;p&gt;Results (2): 1&lt;br/&gt;
aleph&lt;/p&gt;

&lt;p&gt;but printing out the first result object again at this point gives:&lt;/p&gt;

&lt;p&gt;Results (1): 1&lt;br/&gt;
aleph&lt;/p&gt;

&lt;p&gt;which is unexpected - &quot;aleph&quot; rather than &quot;alpha&quot;.&lt;/p&gt;

&lt;p&gt;If, the second query was altered to&lt;/p&gt;

&lt;p&gt;      -&amp;gt;where(&apos;ppa.id = ?&apos;, 2)&lt;br/&gt;
      -&amp;gt;andWhere(&apos;n.text = ?&apos;, &apos;beta&apos;)&lt;/p&gt;

&lt;p&gt;then all three output results are as expected.&lt;/p&gt;

&lt;p&gt;test.zip contains corresponding test files.&lt;/p&gt;</description>
                <environment>OS X 10.6.6 with PHP 5.3.3, Windows with PHP 5.3.1</environment>
            <key id="12560">DC-997</key>
            <summary>Doctrine collections are overwritten when created by inner join queries that agree on the WHERE</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="borrible">Richard Forster</reporter>
                        <labels>
                    </labels>
                <created>Wed, 13 Apr 2011 08:54:24 +0000</created>
                <updated>Wed, 13 Apr 2011 08:54:34 +0000</updated>
                                    <version>1.2.4</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                    <attachment id="10969" name="models.yml" size="488" author="borrible" created="Wed, 13 Apr 2011 08:54:24 +0000" />
                    <attachment id="10970" name="test.zip" size="1452" author="borrible" created="Wed, 13 Apr 2011 08:54:24 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-996] UPDATE query generate ambiguous statement</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-996</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When creating an UPDATE query, the table names are not aliased like in a SELECT statement. This causes ambiguous column names when JOINING in an UPDATE. &lt;/p&gt;

&lt;p&gt;E.g.&lt;br/&gt;
$q = $this-&amp;gt;createQuery(&apos;st&apos;)&lt;br/&gt;
-&amp;gt;update(&apos;SomeTable st&apos;)&lt;br/&gt;
-&amp;gt;set(&apos;st.position&apos;,&apos;st.position + 1&apos;)&lt;br/&gt;
-&amp;gt;leftJoin(&apos;st.SomeOtherTable sot ON st.some_id = sot.id&apos;)&lt;br/&gt;
-&amp;gt;where(&apos;st.id &amp;lt;&amp;gt; ?&apos;, $someId)&lt;br/&gt;
-&amp;gt;andWhere(&apos;sot.some_column = ?&apos;, $someValue)&lt;/p&gt;

&lt;p&gt;The generated SQL for this is : &lt;br/&gt;
UPDATE some_table &lt;br/&gt;
LEFT JOIN some_other_table sot ON st.some_id = sot.id &lt;br/&gt;
SET position = position + 1, updated_at = 2011-04-13 11:01:03, updated_at = 2011-04-13 11:01:03&lt;br/&gt;
WHERE (id &amp;lt;&amp;gt; 4 AND some_column = 7)&lt;/p&gt;

&lt;p&gt;Clearly here &quot;updated_at&quot; and &quot;id&quot; are ambiguous columns. Why the tables are not automatically aliased with unique aliases like in a SELECT statement, and the aliases written before the column name ?&lt;/p&gt;

&lt;p&gt;Thanks.&lt;/p&gt;</description>
                <environment>MAMP on MacBook Pro 10.6.7, with Symfony 1.4.9</environment>
            <key id="12559">DC-996</key>
            <summary>UPDATE query generate ambiguous statement</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="john">John</reporter>
                        <labels>
                    </labels>
                <created>Wed, 13 Apr 2011 06:35:35 +0000</created>
                <updated>Wed, 13 Apr 2011 06:37:28 +0000</updated>
                                                                    <component>Query</component>
                        <due></due>
                    <votes>2</votes>
                        <watches>3</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-973] Statements with empty results are not correctly closed</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-973</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Statements that return no result are not correctly closed in Doctrine_Hydrator_Graph::hydrateResultSet().&lt;/p&gt;

&lt;p&gt;Oracle has limited number of opened cursors, and this bug prevents unsing doctrine in batch task like indexing models with sfSolrPlugin.&lt;/p&gt;

&lt;p&gt;Oracle throws an error `ORA-01000: maximum open cursors exceeded : ` in my case after indexing only 100 records.&lt;/p&gt;

&lt;p&gt;I&apos;ll send a pull request via github for this issue.&lt;/p&gt;</description>
                <environment></environment>
            <key id="12399">DC-973</key>
            <summary>Statements with empty results are not correctly closed</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="adrive">Miloslav &quot;adrive&quot; Kmet</reporter>
                        <labels>
                    </labels>
                <created>Thu, 17 Feb 2011 05:00:08 +0000</created>
                <updated>Thu, 17 Feb 2011 05:00:08 +0000</updated>
                                                                    <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-967] Problems with fetchArray() combined with leftJoin() by using  aliases of columns</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-967</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;They are some strange problems with hydration to array combined with aliases of columns and JOINS. Let&apos;s see this example:&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;$q = Doctrine_Query::create ()
-&amp;gt;select(&apos;c.id AS id, c.path AS path, c.name AS name, cbc.product_count&apos;)
-&amp;gt;from(&apos;Category c&apos;)
-&amp;gt;leftJoin(&apos;c.CategoryBrowserCache cbc&apos;);

$categories = $q-&amp;gt;fetchArray();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This example will throw exception: &quot;The root class of the query (alias lc) must have at least one field selected.&quot;&lt;/p&gt;

&lt;p&gt;OK. Let&apos;s change code  a little bit. Let&apos;s add alias for cbc.product_count column too:&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;$q = Doctrine_Query::create ()
-&amp;gt;select(&apos;c.id AS id, c.path AS path, c.name AS name, cbc.product_count AS product_count&apos;)
-&amp;gt;from(&apos;Category c&apos;)
-&amp;gt;leftJoin(&apos;c.CategoryBrowserCache cbc&apos;);

$categories = $q-&amp;gt;fetchArray();
print_r($categories);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now code executed without exception, BUT  $q-&amp;gt;fetchArray()  returned only ONE (first) record hydrated to array. Other results were ignored.  &lt;/p&gt;

&lt;p&gt;Let&apos;s change code  one more time:&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;$q = Doctrine_Query::create ()
-&amp;gt;select(&apos;c.id, c.path, c.name, cbc.product_count AS product_count&apos;)
-&amp;gt;from(&apos;Category c&apos;)
-&amp;gt;leftJoin(&apos;c.CategoryBrowserCache cbc&apos;);
$categories = $q-&amp;gt;fetchArray();
print_r($categories);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Like you see I just removed all aliases for columns for Category. Now code will be executed without exceptions, All results will be hydrated into array as expected to be. Actually the same result can be reached by removing at least one alias for any Category column. &lt;/p&gt;</description>
                <environment>Symfony Framework v1.3.8, Windows 7</environment>
            <key id="12385">DC-967</key>
            <summary>Problems with fetchArray() combined with leftJoin() by using  aliases of columns</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="arnlukas">Arnoldas Lukasevicius</reporter>
                        <labels>
                    </labels>
                <created>Sun, 13 Feb 2011 18:30:56 +0000</created>
                <updated>Sun, 13 Feb 2011 18:46:58 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Record</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-944] Precedence problem in SQL generation allows bypass of pending joins</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-944</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;&apos;Pending join conditions&apos; are used by listeners to inject extra SQL conditions into a query. They are often used to add basic constraints on every query. An example is the bundled &lt;b&gt;SoftDelete&lt;/b&gt; template. Its listener adds extra constraints such as &lt;b&gt;s.deleted_at IS NULL&lt;/b&gt; to a query, to make sure that deleted rows are never retrieved on a query.&lt;/p&gt;

&lt;p&gt;However, in the emitted SQL, &lt;b&gt;Doctrine_Query&lt;/b&gt; does not use parentheses to group normal SQL conditions together. The pending join condition is simply added to the string without encapsulating existing expressions. This makes it possible to bypass the pending join conditions entirely by using the OR operator.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Example&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;For instance, the following query exhibits this problem:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;$query = Doctrine_Query::create()&lt;br/&gt;
        -&amp;gt;from(&quot;SoftDeleteTest&quot;)&lt;br/&gt;
        -&amp;gt;where(&quot;name=?&quot;, &quot;faulty&quot;)&lt;br/&gt;
        -&amp;gt;orWhere(&quot;name=?&quot;, &quot;faulty&quot;);&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;This query emits the following SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SELECT s.name AS s_&lt;em&gt;name, s.deleted_at AS s&lt;/em&gt;_deleted_at FROM soft_delete_test s WHERE (s.name = &apos;faulty&apos; OR s.name = &apos;faulty&apos; AND (s.deleted_at IS NULL))&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;which returns also a deleted row.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Expected behavior&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;One would expect the pending join conditions always to hold, and to have precedence over regularly added SQL conditions. This could be accomplished in the most simple fashion by:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SELECT s.name AS s_&lt;em&gt;name, s.deleted_at AS s&lt;/em&gt;_deleted_at FROM soft_delete_test s WHERE ( ( s.name = &apos;faulty&apos; OR s.name = &apos;faulty&apos; ) AND (s.deleted_at IS NULL));&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;As the existing expressions are now encapsulated by parentheses, it is no longer possible to bypass the pending join conditions injected by the query listener.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Full test case details:&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;init.sql&lt;/b&gt;&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;create database softdelete;
grant all privileges on softdelete.* to softdelete@localhost identified by &apos;uahwqeruwer&apos;;

use softdelete;
CREATE TABLE soft_delete_test (name VARCHAR(255), 
    deleted_at DATETIME DEFAULT NULL, 
    PRIMARY KEY(name)) ENGINE = INNODB;

insert into soft_delete_test values (&apos;fine&apos;, null);
insert into soft_delete_test values (&apos;faulty&apos;, now());
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;run.php&lt;/b&gt;&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;&amp;lt;?php

require &quot;./1.2.3/lib/Doctrine.php&quot;;

spl_autoload_register(array(&apos;Doctrine&apos;, &apos;autoload&apos;));

require &quot;SoftDeleteTest.php&quot;;

$conn = Doctrine_Manager::connection(&quot;mysql://softdelete:uahwqeruwer@localhost/softdelete&quot;);
$conn-&amp;gt;setAttribute(Doctrine::ATTR_USE_DQL_CALLBACKS, true);

$query = Doctrine_Query::create()
    -&amp;gt;from(&quot;SoftDeleteTest&quot;)
    -&amp;gt;where(&quot;name=?&quot;, &quot;faulty&quot;)
    -&amp;gt;orWhere(&quot;name=?&quot;, &quot;faulty&quot;);

$found = $query-&amp;gt;execute();
foreach ($found as $f) {
    echo &quot;ERROR! Found a deleted row: $f-&amp;gt;name\n&quot;;
}
echo &quot;Done.\n&quot;;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;SoftDeleteTest.php&lt;/b&gt; (copied from Doctrine manual)&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;&amp;lt;?php

class SoftDeleteTest extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this-&amp;gt;hasColumn(&apos;name&apos;, &apos;string&apos;, null, array(
                &apos;primary&apos; =&amp;gt; true
            )
        );
    }

    public function setUp()
    {
        $this-&amp;gt;actAs(&apos;SoftDelete&apos;);
    }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment>PHP 5.2, 5.3</environment>
            <key id="12189">DC-944</key>
            <summary>Precedence problem in SQL generation allows bypass of pending joins</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="walter">Walter Hop</reporter>
                        <labels>
                    </labels>
                <created>Fri, 3 Dec 2010 12:01:34 +0000</created>
                <updated>Sat, 10 Dec 2011 12:44:25 +0000</updated>
                                    <version>1.2.3</version>
                                <fixVersion>1.2.4</fixVersion>
                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="14900" author="walter" created="Fri, 3 Dec 2010 12:02:23 +0000"  >&lt;p&gt;Fixing quote formatting&lt;/p&gt;</comment>
                    <comment id="14903" author="walter" created="Fri, 3 Dec 2010 12:06:05 +0000"  >&lt;p&gt;Final formatting fixes. &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/smile.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="11127" name="Query.pendingjoin.diff" size="1878" author="walter" created="Sat, 10 Dec 2011 12:44:25 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-937] Cross Schema stored procedures are not recognized</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-937</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When you call a stored procedure from a schema other than that of the current connection: &lt;span class=&quot;error&quot;&gt;&amp;#91;schema_name&amp;#93;&lt;/span&gt;.&lt;span class=&quot;error&quot;&gt;&amp;#91;stored_procedure_name&amp;#93;&lt;/span&gt;(&lt;span class=&quot;error&quot;&gt;&amp;#91;stored_procedure_arguments&amp;#93;&lt;/span&gt;) doctrine miss understands the string and throws  a &quot;Couldn&apos;t get short alias for&quot; exception.&lt;/p&gt;

&lt;p&gt;I fixed this by adding some more regex to the getExpressionOwner method of the Query Class.&lt;/p&gt;

&lt;p&gt;I will post the patch shortly.&lt;/p&gt;

&lt;p&gt;Will Ferrer&lt;/p&gt;</description>
                <environment>XP Xamp</environment>
            <key id="12141">DC-937</key>
            <summary>Cross Schema stored procedures are not recognized</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="willf1976">will ferrer</reporter>
                        <labels>
                    </labels>
                <created>Mon, 22 Nov 2010 22:07:08 +0000</created>
                <updated>Wed, 8 Dec 2010 00:10:22 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="14931" author="willf1976" created="Wed, 8 Dec 2010 00:10:21 +0000"  >&lt;p&gt;Fixed an issue where the code wouldn&apos;t work with calls to stored procedure that were nestted in groups in selects.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10888" name="DC_937_fix.patch" size="2848" author="willf1976" created="Wed, 8 Dec 2010 00:10:21 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-1041] Using -&gt;limit() in conjunction with many-to-many with mysql generates wrong SQL</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-1041</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Using -&amp;gt;limit() in conjunction with many-to-many relationships with mysql leads to strange SQL generated. The condition &lt;b&gt;id IS NULL&lt;/b&gt; is added in such case which is not correct at all.&lt;/p&gt;

&lt;p&gt;Here&apos;s example schema&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;User:
  columns:
    username: { type: string(255) }
  relations:
    Operators:
      foreignAlias: Users
      class:        Operator
      refClass:     OperatorUser

Operator:
  columns:
    username: { type: string(255) }
    type:     { type: integer }


OperatorUser:
  columns:
    user_id:      { type: integer }
    operator_id:  { type: integer }
  relations:
    Operator:
      foreignAlias: OperatorUser
    User:
      foreignAlias: OperatorUser
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And here&apos;s query which generates wrong 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;Doctrine_Core::getTable(&apos;User&apos;)
  -&amp;gt;createQuery(&apos;User&apos;)
  -&amp;gt;leftJoin(&apos;User.Operators Operator&apos;)
  -&amp;gt;addWhere(&apos;Operator.type = ?&apos;, 1)
  -&amp;gt;limit(10)
  -&amp;gt;offset(0)
  -&amp;gt;execute()
;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Expected SQL generated:&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; u.id AS u__id, u.username AS u__username, o.id AS o__id, o.username AS o__username, o.type AS o__type
&lt;span class=&quot;code-keyword&quot;&gt;FROM&lt;/span&gt; user u
LEFT JOIN operator_user o2  ON (u.id = o2.user_id)
LEFT JOIN operator o        ON o.id = o2.operator_id
&lt;span class=&quot;code-keyword&quot;&gt;WHERE&lt;/span&gt; (o.type = &apos;1&apos;)
LIMIT 10
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Actual SQL generated:&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; u.id AS u__id, u.username AS u__username, o.id AS o__id, o.username AS o__username, o.type AS o__type
&lt;span class=&quot;code-keyword&quot;&gt;FROM&lt;/span&gt; user u
LEFT JOIN operator_user o2  ON (u.id = o2.user_id)
LEFT JOIN operator o        ON o.id = o2.operator_id
&lt;span class=&quot;code-keyword&quot;&gt;WHERE&lt;/span&gt;
  u.id IS NULL # is not expected
  AND (o.type = &apos;1&apos;)
# there&apos;s no LIMIT clause
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Seems like here&apos;s code which causes the bug &lt;a href=&quot;https://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Query.php#L1307&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Query.php#L1307&lt;/a&gt;&lt;/p&gt;</description>
                <environment>mysql</environment>
            <key id="13229">DC-1041</key>
            <summary>Using -&gt;limit() in conjunction with many-to-many with mysql generates wrong SQL</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="smileua">Evgeniy Afonichev</reporter>
                        <labels>
                    </labels>
                <created>Wed, 30 Nov 2011 09:26:19 +0000</created>
                <updated>Wed, 30 Nov 2011 09:51:21 +0000</updated>
                                                                    <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-1055] Bug in select query when executed against postgreSQL</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-1055</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;In the attached Squema run this query against postgreSQL.&lt;br/&gt;
(it runs ok In mysql)&lt;/p&gt;

&lt;p&gt;$lang = &apos;en&apos;;&lt;br/&gt;
$session = 1;&lt;br/&gt;
$q = Doctrine_Query::create()&lt;br/&gt;
                -&amp;gt;from(&apos;Sys_Trace t&apos;)&lt;br/&gt;
                -&amp;gt;leftJoin(&apos;t.Sys_Session s&apos;)&lt;br/&gt;
                -&amp;gt;leftJoin(&apos;t.Translation tr WITH tr.lang = ?&apos;, array($lang))&lt;br/&gt;
                -&amp;gt;leftJoin(&apos;t.Sys_Oper so&apos;)&lt;br/&gt;
                -&amp;gt;leftJoin(&apos;so.Translation tr2 WITH tr2.lang = ?&apos;, array($lang))&lt;br/&gt;
                &amp;gt;where(&apos;t.session_id = ?&apos;, array($session));&lt;/p&gt;

&lt;p&gt;SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;22P02&amp;#93;&lt;/span&gt;: Invalid text representation: 7 ERROR: invalid input syntax for integer: &quot;en&quot;&lt;/p&gt;</description>
                <environment>symfony-1.4.17  php 5.3.5 apache 2.2.17 WIndows xp/7  PostgreSQL 9.1.2 </environment>
            <key id="13728">DC-1055</key>
            <summary>Bug in select query when executed against 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="damianbh">Damian Bergantinnos</reporter>
                        <labels>
                    </labels>
                <created>Fri, 25 May 2012 15:46:11 +0000</created>
                <updated>Fri, 25 May 2012 15:46:11 +0000</updated>
                                                                    <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                                <attachments>
                    <attachment id="11192" name="schema.rar" size="1025" author="damianbh" created="Fri, 25 May 2012 15:46:11 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-451] preDql events on connection &amp; manager level</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-451</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;I think it would be very helpful if the preDql events also worked on connection and manager level. If it is anyway possible.&lt;/p&gt;

&lt;p&gt;attach a record listener to a connection object, and it should also call the preDql events when doing DQL queries.&lt;/p&gt;</description>
                <environment></environment>
            <key id="10777">DC-451</key>
            <summary>preDql events on connection &amp; manager level</summary>
                <type id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/improvement.png">Improvement</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="sune">Sune Kibsgaard Pedersen</reporter>
                        <labels>
                    </labels>
                <created>Mon, 25 Jan 2010 14:08:30 +0000</created>
                <updated>Mon, 25 Jan 2010 14:08:30 +0000</updated>
                                    <version>1.2.1</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-424] using boolean logic in select don&apos;t work</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-424</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Continuing with same setup as in &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-417&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/jira/browse/DC-417&lt;/a&gt;&lt;br/&gt;
I discovered another issue&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;$result = Doctrine_Query::create()
    -&amp;gt;select(&apos;u.*, m.*, COUNT(m.id) &amp;gt; 0 AS match_check&apos;)
    -&amp;gt;from(&apos;User u&apos;)
    -&amp;gt;leftJoin(&apos;u.Matches m&apos;)
    -&amp;gt;groupBy(&apos;u.id&apos;)
    -&amp;gt;orderBy(&apos;match_check DESC, RAND()&apos;)
    -&amp;gt;execute(array(), Doctrine::HYDRATE_ARRAY);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;match_check will actually be count of matches not 0 or 1 as i expected. &lt;br/&gt;
is it bug or feature?&lt;/p&gt;</description>
                <environment></environment>
            <key id="10726">DC-424</key>
            <summary>using boolean logic in select don&apos;t work</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="ihff">Ivo V&#245;sa</reporter>
                        <labels>
                    </labels>
                <created>Thu, 14 Jan 2010 13:21:28 +0000</created>
                <updated>Wed, 27 Jan 2010 21:14:32 +0000</updated>
                                    <version>1.1.6</version>
                <version>1.2.1</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="11378" author="guilhermeblanco" created="Thu, 14 Jan 2010 13:24:29 +0000"  >&lt;p&gt;SelectExpressions cannot contain ComparisonExpressions.&lt;/p&gt;

&lt;p&gt;That&apos;s a limitation of Doctrine 1, which was resolved in Doctrine 2.&lt;/p&gt;

&lt;p&gt;Cheers,&lt;/p&gt;</comment>
                    <comment id="11493" author="jboyd" created="Wed, 27 Jan 2010 21:14:06 +0000"  >&lt;p&gt;Something like this will work:&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;$result = Doctrine_Query::create()
    -&amp;gt;select(&apos;u.*, m.*)
    -&amp;gt;addSelect(&quot;QUOTE(IF(COUNT(m.id) &amp;gt; 0),1,0)) match_check&apos;)
    -&amp;gt;from(&apos;User u&apos;)
    -&amp;gt;leftJoin(&apos;u.Matches m&apos;)
    -&amp;gt;groupBy(&apos;u.id&apos;)
    -&amp;gt;orderBy(&apos;match_check DESC, RAND()&apos;)
    -&amp;gt;execute(array(), Doctrine::HYDRATE_ARRAY);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-402] aliased fields from root class are not recognized als root class fields, if they&apos;re the only one</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-402</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;If all selected fields from the root class are aliased, &lt;br/&gt;
Doctrine_Query-&amp;gt;processPendingFields() won&apos;t recognize them as fields of the table and the following exception will be thrown:&lt;br/&gt;
&quot;The root class of the query (alias c)  must have at least one field selected.&quot;&lt;/p&gt;

&lt;p&gt;In my real world example, this could only be fixed, using the primary key of the root class/table in select&lt;/p&gt;</description>
                <environment></environment>
            <key id="10691">DC-402</key>
            <summary>aliased fields from root class are not recognized als root class fields, if they&apos;re the only one</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="cmi">Christian Michel</reporter>
                        <labels>
                    </labels>
                <created>Wed, 6 Jan 2010 14:06:56 +0000</created>
                <updated>Wed, 6 Jan 2010 14:06:56 +0000</updated>
                                    <version>1.2.1</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-401] Doctrine_Query-&gt;load crashes with additional ending whitespace in JOIN </title>
                <link>http://www.doctrine-project.org/jira/browse/DC-401</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;following will lead to an error:&lt;/p&gt;

&lt;p&gt;-&amp;gt;leftJoin(&apos;alias.RelatedTable alias2  WITH .....&apos;)&lt;/p&gt;

&lt;p&gt;The problem is the additional whitespace behind alias2.&lt;br/&gt;
On line 1682 in Doctrine_Query class file:&lt;/p&gt;

&lt;p&gt;$tmp            = explode(&apos; &apos;, $path);&lt;/p&gt;

&lt;p&gt;will create an array of 3 elements where the last one is empty but will be used as empty alias mapping after foreach from line 1698.&lt;/p&gt;

</description>
                <environment></environment>
            <key id="10689">DC-401</key>
            <summary>Doctrine_Query-&gt;load crashes with additional ending whitespace in JOIN </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="cmi">Christian Michel</reporter>
                        <labels>
                    </labels>
                <created>Wed, 6 Jan 2010 11:54:52 +0000</created>
                <updated>Wed, 6 Jan 2010 12:02:40 +0000</updated>
                                                                            <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-386] Doctrine_Hydrator_ArrayDriver may segfault Php when loaded by Zend Framework Autoloader</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-386</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Apache and Php segfault with no error information in the logs and a white screen of death when I use Doctrine 1.2.1 in a Zend Framework controller. &lt;/p&gt;

&lt;p&gt;I&apos;ve traced the problem to line 126 of Zend/Loader/Autoloader.php which only seemed to occur when it autoloaded Doctrine_Hydrator_ArrayDriver during a call to save() in the controller. &lt;/p&gt;

&lt;p&gt;I debugged with xdebug and have attached a simple test controller with no other code. The ZF page works fine when all Doctrine is commented out and a Doctrine test page with the same code but outside of ZF worked fine via Apache as did a CLI script.&lt;/p&gt;

&lt;p&gt;Workaround is to not push Doctrine to Zend Loader in the bootstrap.&lt;/p&gt;

&lt;p&gt;Here is the debug output just before a segfault, the stack and the variable values:&lt;/p&gt;

&lt;p&gt;Remote Launch (stepping)	&lt;br/&gt;
	Library/Zend/Loader/Autoloader.php.Zend_Loader_Autoloader::autoload : lineno 126	&lt;br/&gt;
	Library/Zend/Loader/Autoloader.php.is_subclass_of : lineno 0	&lt;br/&gt;
	Library/Doctrine/Query.php.Doctrine_Query-&amp;gt;processPendingFields : lineno 477	&lt;br/&gt;
	Library/Doctrine/Query.php.Doctrine_Query-&amp;gt;buildSqlQuery : lineno 1213	&lt;br/&gt;
	Library/Doctrine/Query.php.Doctrine_Query-&amp;gt;getSqlQuery : lineno 1122	&lt;br/&gt;
	Library/Doctrine/Query/Abstract.php.Doctrine_Query_Abstract-&amp;gt;_getDqlCallbackComponents : lineno 1137	&lt;br/&gt;
	Library/Doctrine/Query/Abstract.php.Doctrine_Query_Abstract-&amp;gt;_preQuery : lineno 1106	&lt;br/&gt;
	Library/Doctrine/Query/Abstract.php.Doctrine_Query_Abstract-&amp;gt;execute : lineno 1001	&lt;br/&gt;
	Library/Doctrine/Template/Listener/Sluggable.php.Doctrine_Template_Listener_Sluggable-&amp;gt;getUniqueSlug : lineno 207	&lt;br/&gt;
	Library/Doctrine/Template/Listener/Sluggable.php.Doctrine_Template_Listener_Sluggable-&amp;gt;buildSlugFromFields : lineno 120	&lt;br/&gt;
	Library/Doctrine/Template/Listener/Sluggable.php.Doctrine_Template_Listener_Sluggable-&amp;gt;preInsert : lineno 65	&lt;br/&gt;
	Library/Doctrine/Record/Listener/Chain.php.Doctrine_Record_Listener_Chain-&amp;gt;preInsert : lineno 342	&lt;br/&gt;
	Library/Doctrine/Record.php.Doctrine_Record-&amp;gt;invokeSaveHooks : lineno 355	&lt;br/&gt;
	Library/Doctrine/Connection/UnitOfWork.php.Doctrine_Connection_UnitOfWork-&amp;gt;insert : lineno 551	&lt;br/&gt;
	Library/Doctrine/Connection/UnitOfWork.php.Doctrine_Connection_UnitOfWork-&amp;gt;saveGraph : lineno 81	&lt;br/&gt;
	Library/Doctrine/Record.php.Doctrine_Record-&amp;gt;save : lineno 1691	&lt;br/&gt;
	Application/controllers/TestingController.php.TestingController-&amp;gt;indexAction : lineno 20	&lt;br/&gt;
	Library/Zend/Controller/Action.php.Zend_Controller_Action-&amp;gt;dispatch : lineno 513	&lt;br/&gt;
	Library/Zend/Controller/Dispatcher/Standard.php.Zend_Controller_Dispatcher_Standard-&amp;gt;dispatch : lineno 289	&lt;br/&gt;
	Library/Zend/Controller/Front.php.Zend_Controller_Front-&amp;gt;dispatch : lineno 946	&lt;br/&gt;
	Library/Zend/Application/Bootstrap/Bootstrap.php.Zend_Application_Bootstrap_Bootstrap-&amp;gt;run : lineno 77	&lt;br/&gt;
	Application/Bootstrap.php.Bootstrap-&amp;gt;run : lineno 52	&lt;br/&gt;
	Library/Zend/Application.php.Zend_Application-&amp;gt;run : lineno 346	&lt;br/&gt;
	Public/index.php.&lt;/p&gt;
{main}
&lt;p&gt; : lineno 26	&lt;/p&gt;

&lt;p&gt;=&lt;del&gt;=&lt;/del&gt;=&lt;del&gt;=&lt;/del&gt;=-=&lt;/p&gt;

&lt;p&gt;$class	Doctrine_Hydrator_ArrayDriver	&lt;br/&gt;
$object	Zend_Loader_Autoloader	&lt;br/&gt;
	_autoloaders	Array &lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt;	&lt;br/&gt;
		0	Array &lt;span class=&quot;error&quot;&gt;&amp;#91;2&amp;#93;&lt;/span&gt;	&lt;br/&gt;
			0	Doctrine	&lt;br/&gt;
			1	autoload	&lt;br/&gt;
	_defaultAutoloader	Array &lt;span class=&quot;error&quot;&gt;&amp;#91;2&amp;#93;&lt;/span&gt;	&lt;br/&gt;
		0	Zend_Loader	&lt;br/&gt;
		1	loadClass	&lt;br/&gt;
	_fallbackAutoloader	false	&lt;br/&gt;
	_internalAutoloader	Array &lt;span class=&quot;error&quot;&gt;&amp;#91;2&amp;#93;&lt;/span&gt;	&lt;br/&gt;
		0	Zend_Loader_Autoloader	&lt;br/&gt;
		1	_autoload	&lt;br/&gt;
	_namespaces	Array &lt;span class=&quot;error&quot;&gt;&amp;#91;5&amp;#93;&lt;/span&gt;	&lt;br/&gt;
		Zend_	true	&lt;br/&gt;
		ZendX_	true	&lt;br/&gt;
		Lisantra_	true	&lt;br/&gt;
		Persistence_	true	&lt;br/&gt;
		Doctrine_	true	&lt;br/&gt;
	_namespaceAutoloaders	Array &lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt;	&lt;br/&gt;
		Array &lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt;	&lt;br/&gt;
			0	Array &lt;span class=&quot;error&quot;&gt;&amp;#91;2&amp;#93;&lt;/span&gt;	&lt;br/&gt;
				0	Doctrine	&lt;br/&gt;
				1	autoload	&lt;br/&gt;
	_suppressNotFoundWarnings	false	&lt;br/&gt;
$self	Zend_Loader_Autoloader	&lt;br/&gt;
	_autoloaders	Array &lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt;	&lt;br/&gt;
		0	Array &lt;span class=&quot;error&quot;&gt;&amp;#91;2&amp;#93;&lt;/span&gt;	&lt;br/&gt;
			0	Doctrine	&lt;br/&gt;
			1	autoload	&lt;br/&gt;
	_defaultAutoloader	Array &lt;span class=&quot;error&quot;&gt;&amp;#91;2&amp;#93;&lt;/span&gt;	&lt;br/&gt;
		0	Zend_Loader	&lt;br/&gt;
		1	loadClass	&lt;br/&gt;
	_fallbackAutoloader	false	&lt;br/&gt;
	_internalAutoloader	Array &lt;span class=&quot;error&quot;&gt;&amp;#91;2&amp;#93;&lt;/span&gt;	&lt;br/&gt;
		0	Zend_Loader_Autoloader	&lt;br/&gt;
		1	_autoload	&lt;br/&gt;
	_namespaces	Array &lt;span class=&quot;error&quot;&gt;&amp;#91;5&amp;#93;&lt;/span&gt;	&lt;br/&gt;
		Zend_	true	&lt;br/&gt;
		ZendX_	true	&lt;br/&gt;
		Lisantra_	true	&lt;br/&gt;
		Persistence_	true	&lt;br/&gt;
		Doctrine_	true	&lt;br/&gt;
	_namespaceAutoloaders	Array &lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt;	&lt;br/&gt;
		Array &lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt;	&lt;br/&gt;
			0	Array &lt;span class=&quot;error&quot;&gt;&amp;#91;2&amp;#93;&lt;/span&gt;	&lt;br/&gt;
				0	Doctrine	&lt;br/&gt;
				1	autoload	&lt;br/&gt;
	_suppressNotFoundWarnings	false	&lt;br/&gt;
$method	_autoload	&lt;br/&gt;
$autoloader	Array &lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;	&lt;/p&gt;</description>
                <environment>Ubuntu 9.04 fully updated with Apache 2.2.11, Php 5.2.6, Zend Framework 1.9.6, Doctrine 1.2.1</environment>
            <key id="10661">DC-386</key>
            <summary>Doctrine_Hydrator_ArrayDriver may segfault Php when loaded by Zend Framework Autoloader</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="mgatto">Michael Gatto</reporter>
                        <labels>
                    </labels>
                <created>Thu, 24 Dec 2009 23:41:15 +0000</created>
                <updated>Thu, 24 Dec 2009 23:46:23 +0000</updated>
                                    <version>1.2.1</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                                <attachments>
                    <attachment id="10258" name="Doctrine.php" size="6572" author="mgatto" created="Thu, 24 Dec 2009 23:41:15 +0000" />
                    <attachment id="10256" name="doctrine_trace.txt.xt" size="1723114" author="mgatto" created="Thu, 24 Dec 2009 23:41:15 +0000" />
                    <attachment id="10257" name="TestingController.php" size="777" author="mgatto" created="Thu, 24 Dec 2009 23:41:15 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-387] mssql fails on find($key)</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-387</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Doctrine_Core::getTable(&apos;Project&apos;)-&amp;gt;find($id)&lt;br/&gt;
this kind of expression produces query like &quot;SELECT TOP 1 &lt;span class=&quot;error&quot;&gt;&amp;#91;inner_tbl&amp;#93;&lt;/span&gt;.&lt;span class=&quot;error&quot;&gt;&amp;#91;id&amp;#93;&lt;/span&gt; AS &lt;span class=&quot;error&quot;&gt;&amp;#91;p__id&amp;#93;&lt;/span&gt; FROM (SELECT TOP 1 &lt;span class=&quot;error&quot;&gt;&amp;#91;p&amp;#93;&lt;/span&gt;.&lt;span class=&quot;error&quot;&gt;&amp;#91;id&amp;#93;&lt;/span&gt; AS &lt;span class=&quot;error&quot;&gt;&amp;#91;p__id&amp;#93;&lt;/span&gt;, &lt;span class=&quot;error&quot;&gt;&amp;#91;p&amp;#93;&lt;/span&gt;.&lt;span class=&quot;error&quot;&gt;&amp;#91;name&amp;#93;&lt;/span&gt; AS &lt;span class=&quot;error&quot;&gt;&amp;#91;p__name&amp;#93;&lt;/span&gt;, &lt;span class=&quot;error&quot;&gt;&amp;#91;p&amp;#93;&lt;/span&gt;.&lt;span class=&quot;error&quot;&gt;&amp;#91;description&amp;#93;&lt;/span&gt; AS &lt;span class=&quot;error&quot;&gt;&amp;#91;p__description&amp;#93;&lt;/span&gt; FROM &lt;span class=&quot;error&quot;&gt;&amp;#91;project&amp;#93;&lt;/span&gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;p&amp;#93;&lt;/span&gt; WHERE (&lt;span class=&quot;error&quot;&gt;&amp;#91;p&amp;#93;&lt;/span&gt;.&lt;span class=&quot;error&quot;&gt;&amp;#91;id&amp;#93;&lt;/span&gt; = ?)) AS &lt;span class=&quot;error&quot;&gt;&amp;#91;inner_tbl&amp;#93;&lt;/span&gt;&quot;&lt;br/&gt;
which fails because there is no &lt;span class=&quot;error&quot;&gt;&amp;#91;inner_tbl&amp;#93;&lt;/span&gt;.&lt;span class=&quot;error&quot;&gt;&amp;#91;id&amp;#93;&lt;/span&gt; &lt;/p&gt;</description>
                <environment></environment>
            <key id="10662">DC-387</key>
            <summary>mssql fails on find($key)</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="zerkms">zerkms</reporter>
                        <labels>
                    </labels>
                <created>Fri, 25 Dec 2009 00:31:21 +0000</created>
                <updated>Tue, 5 Jan 2010 21:37:05 +0000</updated>
                                    <version>1.2.1</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="11330" author="gensisns" created="Tue, 5 Jan 2010 21:37:05 +0000"  >&lt;p&gt;Close as duplicate of &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-289&quot; title=&quot;Using MSSQL connection the find method for models does not work&quot;&gt;&lt;del&gt;DC-289&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-353] Doctrine_Query can&apos;t map a main query colum inside a subquery with join</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-353</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;If i have the following schema:&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;Medidor:
  tableName: TBLMEDIDOR
  columns:
    CODIGO:
      name: NRCODIGO as codigo
      type: integer(10)
      primary: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      sequence: SEQMEDCODIGO
    DESCRICAO:
      name: TXDESCRICAO as descricao
      type: string(1000)
      notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;

AnaliseMedidor:
  tableName: TBLANALISE_MEDIDOR
  columns:
    CODIGO:
      name: NRCODIGO as codigo
      type: integer(10)
      primary: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      sequence: SEQANMCODIGO
    DATA:
      name: DTDATA as dataAnalise
      type: date
      notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    MEDIDOR:
      name: FKMEDCODIGO as medidor_codigo
      type: integer(10)
      notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    OBSERVACAO:
      name: TXOBSERVACAO as observacao
      type: string(1000)
  relations:
    Medidor: { local: medidor_codigo, foreign: codigo, foreignAlias: Analises }
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and execute the following query:&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;$query = Doctrine::getTable(&apos;Medidor&apos;)-&amp;gt;createQuery()
    -&amp;gt;innerJoin(&apos;m.Analises a&apos;)
    -&amp;gt;where(&apos;a.dataAnalise = (SELECT MAX(a2.dataAnalise) FROM &apos;
        . &apos;AnaliseMedidor a2 WHERE a2.medidor_codigo = a.medidor_codigo)&apos;);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;the &quot;a.medidor_codigo&quot; in the subquery don&apos;t get correctly mapped. So Doctrine tells me:&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;{sfDoctrineLogger} executeQuery : SELECT t.nr80102codigo AS t__nr80102codigo, t.tx80102descricao AS t__tx80102descricao FROM TBL80102MEDIDOR t INNER JOIN TBL80103ANALISE_MEDIDOR t2 ON t.nr80102codigo = t2.fk80102codigo WHERE t2.dt80103data = (SELECT MAX(t3.dt80103data) AS t3__0 FROM TBL80103ANALISE_MEDIDOR t3 WHERE t3.fk80102codigo = t2.medidor_codigo)
{Doctrine_Connection_Oracle_Exception} SQLSTATE[HY000]: General error: 904 OCIStmtExecute: ORA-00904: &lt;span class=&quot;code-quote&quot;&gt;&quot;T2&quot;&lt;/span&gt;.&lt;span class=&quot;code-quote&quot;&gt;&quot;MEDIDOR_CODIGO&quot;&lt;/span&gt;: invalid identifier
 (/root/PDO_OCI-1.0/oci_statement.c:142)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If i put the real name column it runs ok:&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;$query = Doctrine::getTable(&apos;Medidor&apos;)-&amp;gt;createQuery()
    -&amp;gt;innerJoin(&apos;m.Analises a&apos;)
    -&amp;gt;where(&apos;a.dataAnalise = (SELECT MAX(a2.dataAnalise) FROM &apos;
        . &apos;AnaliseMedidor a2 WHERE a2.medidor_codigo = a.FKMEDCODIGO)&apos;);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;But, this should not be done, right?&lt;/p&gt;


&lt;p&gt;In Doctrine 1.2 it works fine. But in the related versions don&apos;t.&lt;/p&gt;</description>
                <environment>Apache 2.2.13, PHP 5.3, Fedora 11 or Ubuntu 9.04 (and Symfony 1.2.9/1.2.10 with Doctrine 1.0.12/1.0.14)</environment>
            <key id="10603">DC-353</key>
            <summary>Doctrine_Query can&apos;t map a main query colum inside a subquery with join</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="dead_thinker">Arian Maykon de Ara&#250;jo Di&#243;genes</reporter>
                        <labels>
                    </labels>
                <created>Thu, 10 Dec 2009 23:02:56 +0000</created>
                <updated>Thu, 10 Dec 2009 23:17:04 +0000</updated>
                                    <version>1.0.12</version>
                <version>1.0.14</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="11169" author="dead_thinker" created="Thu, 10 Dec 2009 23:17:04 +0000"  >&lt;p&gt;Haven&apos;t added a TestCase because Doctrine 1.0.14 don&apos;t have them yet!&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-335] Oracle identifier too long in normal SELECT when using longer table name or column</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-335</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Unfortunatelly oracle has max identifier length for 30 characters. When using longer model names eg. misCompanyContributor with column names the generated aliases for selected columns mix tableized modelname with colum name joined by two __, and sometimes the generated alias should exceed the allowed 30 characters long identifiers, and oracle complains with:&lt;/p&gt;

&lt;p&gt;{{&lt;br/&gt;
ORA-00972: identifier is too long&lt;br/&gt;
}}&lt;/p&gt;

&lt;p&gt;An example of large select with alias:&lt;br/&gt;
{{&lt;br/&gt;
SELECT&lt;br/&gt;
...&lt;br/&gt;
mis_contributor.contributor_id AS mis_contributor__contributor_id&lt;br/&gt;
..&lt;br/&gt;
FROM mis_contributor  ...&lt;br/&gt;
}}&lt;/p&gt;</description>
                <environment>Oracle</environment>
            <key id="10579">DC-335</key>
            <summary>Oracle identifier too long in normal SELECT when using longer table name or column</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="adrive">Miloslav &quot;adrive&quot; Kmet</reporter>
                        <labels>
                    </labels>
                <created>Mon, 7 Dec 2009 23:59:18 +0000</created>
                <updated>Wed, 13 Oct 2010 18:28:25 +0000</updated>
                                    <version>1.2.1</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="14562" author="mdhooge" created="Wed, 13 Oct 2010 17:12:31 +0000"  >&lt;p&gt;A workaround is available in &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-72&quot; title=&quot;DQL Auto generated column aliases cause &amp;quot;ORA-00972: identifier is too long&amp;quot; on Oracle&quot;&gt;&lt;del&gt;DC-72&lt;/del&gt;&lt;/a&gt; for version 1.1.4&lt;/p&gt;</comment>
                    <comment id="14563" author="mdhooge" created="Wed, 13 Oct 2010 18:28:25 +0000"  >&lt;p&gt;I have applied the following patch to use aliases of identifiers (what is after the &quot;as&quot; when defining field name).&lt;/p&gt;

&lt;p&gt;So far, it seems to work... But I am quite sure I didn&apos;t take all possible cases into consideration.&lt;/p&gt;


&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;--- lib/vendor/doctrine/Doctrine/Hydrator/Graph.php.orig	2010-10-07 19:09:10.000000000 +0200
+++ lib/vendor/doctrine/Doctrine/Hydrator/Graph.php	2010-10-14 00:08:05.000000000 +0200
@@ -298,10 +298,10 @@
                 }
 
                 $e = explode(&apos;__&apos;, $key);
-                $last = strtolower(array_pop($e));
+                $fieldName = strtolower(array_pop($e));
                 $cache[$key][&apos;dqlAlias&apos;] = $this-&amp;gt;_tableAliases[strtolower(implode(&apos;__&apos;, $e))];
                 $table = $this-&amp;gt;_queryComponents[$cache[$key][&apos;dqlAlias&apos;]][&apos;table&apos;];
-                $fieldName = $table-&amp;gt;getFieldName($last);
+                $last = $table-&amp;gt;getColumnName($fieldName);
                 $cache[$key][&apos;fieldName&apos;] = $fieldName;
                 if ($table-&amp;gt;isIdentifier($fieldName)) {
                     $cache[$key][&apos;isIdentifier&apos;] = true;

--- lib/vendor/doctrine/Doctrine/Query.php.orig	2010-10-07 19:09:10.000000000 +0200
+++ lib/vendor/doctrine/Doctrine/Query.php	2010-10-14 00:03:28.000000000 +0200
@@ -494,12 +494,12 @@
                 $parentAlias = $this-&amp;gt;getSqlTableAlias($componentAlias . &apos;.&apos; . $parent-&amp;gt;getComponentName());
                 $sql[] = $this-&amp;gt;_conn-&amp;gt;quoteIdentifier($parentAlias) . &apos;.&apos; . $this-&amp;gt;_conn-&amp;gt;quoteIdentifier($columnName)
                        . &apos; AS &apos;
-                       . $this-&amp;gt;_conn-&amp;gt;quoteIdentifier($tableAlias . &apos;__&apos; . $columnName);
+                       . $this-&amp;gt;_conn-&amp;gt;quoteIdentifier($tableAlias . &apos;__&apos; . $fieldName);
             } else {
-                $columnName = $table-&amp;gt;getColumnName($fieldName);
+                $columnName = $table-&amp;gt;getColumnName($fieldName); // Really needed?
                 $sql[] = $this-&amp;gt;_conn-&amp;gt;quoteIdentifier($tableAlias) . &apos;.&apos; . $this-&amp;gt;_conn-&amp;gt;quoteIdentifier($columnName)
                        . &apos; AS &apos;
-                       . $this-&amp;gt;_conn-&amp;gt;quoteIdentifier($tableAlias . &apos;__&apos; . $columnName);
+                       . $this-&amp;gt;_conn-&amp;gt;quoteIdentifier($tableAlias . &apos;__&apos; . $fieldName);
             }
         }
 
@@ -554,7 +554,7 @@
 
             return $this-&amp;gt;_conn-&amp;gt;quoteIdentifier($tableAlias . &apos;.&apos; . $name)
                    . &apos; AS &apos;
-                   . $this-&amp;gt;_conn-&amp;gt;quoteIdentifier($tableAlias . &apos;__&apos; . $name);
+                   . $this-&amp;gt;_conn-&amp;gt;quoteIdentifier($tableAlias . &apos;__&apos; . $field);
         }
     }
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-331] Wrong SQL output from Doctrine_Expression for pgsql with timestamp with time zone field</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-331</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;(1) pgsql connection&lt;br/&gt;
(2) timestamp with time zone column&lt;br/&gt;
(3) $doctrine_expression = new Doctrine_Expression(&apos;NOW()&apos;);&lt;br/&gt;
      echo $doctrine_expression-&amp;gt;getSQL();&lt;br/&gt;
 gives:&lt;br/&gt;
LOCALTIMESTAMP(0)&lt;/p&gt;

&lt;p&gt;What I&apos;d like to get access to using that Doctrine construct is the &lt;br/&gt;
functionality of &apos;CURRENT_TIMESTAMP&apos;, (has time zone,&lt;br/&gt;
stores time in TIMESTAMP WITH TIME ZONE columns in UTC time)&lt;/p&gt;

&lt;p&gt;Fortunately, all the databases that I want to use implement &lt;br/&gt;
&apos;CURRENT_TIMESTAMP&apos;, but not all PDO/Doctrine databases&lt;br/&gt;
support that construct, even though it&apos;s ANSI SQL standard, &lt;br/&gt;
(which ANSI I don&apos;t know.)&lt;/p&gt;</description>
                <environment>This is with Symfony 1.3 alpha (which is pretty good) Can&amp;#39;t tell you which Doctrine it comes with</environment>
            <key id="10568">DC-331</key>
            <summary>Wrong SQL output from Doctrine_Expression for pgsql with timestamp with time zone field</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="gearond">Dennis Gearon</reporter>
                        <labels>
                    </labels>
                <created>Sun, 6 Dec 2009 02:29:45 +0000</created>
                <updated>Tue, 5 Jan 2010 00:26:29 +0000</updated>
                                    <version>1.2.0-RC1</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="11316" author="slig" created="Tue, 5 Jan 2010 00:26:29 +0000"  >&lt;p&gt;I&apos;m also seeing this with Symfony 1.4.1 (w/Doctrine 1.2).  Affects timestampable tables (created_at, updated_at).&lt;/p&gt;

&lt;p&gt;also, NOW() AT TIME ZONE &apos;UTC&apos; translates to LOCALTIMESTAMP(0) AT TIME ZONE &apos;UTC&apos; (via buildSqlQuery).&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-312] Doctrine_Pager query &quot;influences&quot; Doctrine::getTable() query</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-312</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When I use the same procedure without Doctrine_Pager everything works fine, with Doctrine_Pager the behavior of later queries is strange. Example:&lt;br/&gt;
----------------WORKING:&lt;br/&gt;
1. I fetch list &lt;br/&gt;
Doctrine_Query::create()&lt;del&gt;&amp;gt;select(&apos;z.&lt;b&gt;,s.&lt;/b&gt;,o.*,u.jmeno as Vlo&#382;il,k.nazev_cs as Kategorie&apos;)&lt;/del&gt;&amp;gt;from(&apos;ShopZbozi z,z.Obrazek o,z.Soubor s,z.Uzivatel u,z.ShopKategorie k&apos;)&lt;del&gt;&amp;gt;orderby(&apos;z.nazev_cs ASC&apos;)&lt;/del&gt;&amp;gt;fetchArray(); &lt;/p&gt;

&lt;p&gt;2. I fetch a row to edit independently on the list above&lt;br/&gt;
$object = Doctrine::getTable(&apos;ShopZbozi&apos;)-&amp;gt;find(123);&lt;/p&gt;

&lt;p&gt;3. edit properties of the object...&lt;/p&gt;

&lt;p&gt;4. $object-&amp;gt;replace();&lt;br/&gt;
the object is fetched with no related objects like &lt;span class=&quot;error&quot;&gt;&amp;#91;Uzivatel&amp;#93;&lt;/span&gt; or &lt;span class=&quot;error&quot;&gt;&amp;#91;Soubor&amp;#93;&lt;/span&gt;, so when I change for example $object-&amp;gt;iduzivatel (related Uzivatel object id) and save it is OK&lt;/p&gt;

&lt;p&gt;----------------BROKEN:&lt;br/&gt;
1. I fetch list in Pager&lt;br/&gt;
new Doctrine_Pager(Doctrine_Query::create()&lt;del&gt;&amp;gt;select(&apos;z.&lt;b&gt;,s.&lt;/b&gt;,o.*,u.jmeno as Vlo&#382;il,k.nazev_cs as Kategorie&apos;)&lt;/del&gt;&amp;gt;from(&apos;ShopZbozi z,z.Obrazek o,z.Soubor s,z.Uzivatel u,z.ShopKategorie k&apos;)&lt;del&gt;&amp;gt;orderby(&apos;z.nazev_cs ASC&apos;),$this&lt;/del&gt;&amp;gt;page,$this-&amp;gt;perpage);&lt;/p&gt;

&lt;p&gt;2. I fetch a row to edit independently on the list above    (in contrast to the first working example this $object is fetched with EMPTY RELATION OBJECTS, which causes inserting empty new rows when calling -&amp;gt;replace())&lt;br/&gt;
$object = Doctrine::getTable(&apos;ShopZbozi&apos;)-&amp;gt;find(123);&lt;/p&gt;

&lt;p&gt;3. edit properties of the object...&lt;/p&gt;

&lt;p&gt;4. $object-&amp;gt;replace(); &lt;br/&gt;
-&amp;gt; the $object has all the related object fetched as it was defined in the list in Pager - like it was used as a template for getTable and when -&amp;gt;replace() - new empty related objects are inserted in DB.&lt;/p&gt;


&lt;p&gt;I&apos;ve been using Doctrine for I guess 2 years now and I believe this bug/strange behavior has always been there.&lt;br/&gt;
Maybe I&apos;m wrong and it is not a bug, but the behavior is strange and it took me really long to find where the problem is and I still don&apos;t know how to use pager without influencing the later queries.&lt;br/&gt;
Thanx John Mathew&lt;/p&gt;</description>
                <environment>Debian testing squeeze 32 bit.</environment>
            <key id="10544">DC-312</key>
            <summary>Doctrine_Pager query &quot;influences&quot; Doctrine::getTable() query</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="seiffs">Jan Matousek</reporter>
                        <labels>
                    </labels>
                <created>Wed, 2 Dec 2009 10:19:08 +0000</created>
                <updated>Wed, 2 Dec 2009 10:20:19 +0000</updated>
                                    <version>1.2.0</version>
                                                <component>Pager</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-188] Pager breaks when HAVING clause references existing table column</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-188</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Pager breaks when HAVING clause references any existing table column.&lt;/p&gt;

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

&lt;p&gt;        $q = Doctrine_Query::create()&lt;br/&gt;
             -&amp;gt;select(&quot;u.id, u.first_name, u.last_name, u.is_active&quot;)&lt;br/&gt;
             -&amp;gt;addSelect(&apos;COUNT(u.id) as rolecount&apos;)&lt;br/&gt;
             -&amp;gt;from(&apos;User u&apos;)&lt;br/&gt;
             -&amp;gt;leftJoin(&apos;u.Roles r&apos;)&lt;br/&gt;
             -&amp;gt;groupBy(&apos;u.id&apos;)&lt;br/&gt;
             -&amp;gt;having(&quot;rolecount &amp;gt; 2 and u.is_active = 1&quot;);&lt;/p&gt;

&lt;p&gt;Execution of query by itself works fine (eg via execute(), fetch...)&lt;/p&gt;

&lt;p&gt;When putting this query in a Doctrine_Pager, error outputs:&lt;/p&gt;

&lt;p&gt;        $pager = new Doctrine_Pager(&lt;br/&gt;
              $q,&lt;br/&gt;
              $currentPage, &lt;br/&gt;
              $resultsPerPage &lt;br/&gt;
        );&lt;/p&gt;

&lt;p&gt;        $pager-&amp;gt;execute();&lt;/p&gt;


&lt;p&gt;Error Received:&lt;br/&gt;
SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;42S22&amp;#93;&lt;/span&gt;: Column not found: 1054 Unknown column &apos;u.is_active&apos; in &apos;having clause&apos;&lt;/p&gt;</description>
                <environment>Local: Windows/Cygwin/XAMPP&lt;br/&gt;
Stage &amp;amp; Prod:  CentOS&lt;br/&gt;
Apache / MySQL&lt;br/&gt;
Framework:  Zend&lt;br/&gt;
</environment>
            <key id="10340">DC-188</key>
            <summary>Pager breaks when HAVING clause references existing table column</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="benbac">Benedict Bacayon</reporter>
                        <labels>
                    </labels>
                <created>Wed, 4 Nov 2009 21:50:18 +0000</created>
                <updated>Tue, 20 Jul 2010 01:14:31 +0000</updated>
                                    <version>1.1.5</version>
                                                <component>Pager</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="13615" author="ryan" created="Tue, 20 Jul 2010 01:12:54 +0000"  >&lt;p&gt;a quick fix for this is to enclose the field in parentheses when selecting it, then use an alias to reference it inside the having clause. eg &lt;/p&gt;

&lt;p&gt;$q = Doctrine_Query::create()&lt;br/&gt;
-&amp;gt;select(&quot;u.id, u.first_name, u.last_name, (u.is_active) u_is_active&quot;)&lt;br/&gt;
-&amp;gt;addSelect(&apos;COUNT(u.id) as rolecount&apos;)&lt;br/&gt;
-&amp;gt;from(&apos;User u&apos;)&lt;br/&gt;
-&amp;gt;leftJoin(&apos;u.Roles r&apos;)&lt;br/&gt;
-&amp;gt;groupBy(&apos;u.id&apos;)&lt;br/&gt;
-&amp;gt;having(&quot;rolecount &amp;gt; 2 and u_is_active = 1&quot;);&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<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>

<item>
            <title>[DC-692] Can not create a subquery in where</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-692</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Hi All&lt;/p&gt;

&lt;p&gt;I can not figure out how to make a subquery work in doctrine. I get the subquery to look fine in DQL but when doctrine converts the DQL to SQL the subquery is automatically removed.&lt;/p&gt;

&lt;p&gt;Here is an example:&lt;br/&gt;
This PHP:&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;$q = Doctrine_Query::create(); 
$q-&amp;gt;from(&apos;Customer Customer&apos;); 
$q-&amp;gt;addWhere(&apos; Customer.id in (SELECT Customer.id as customer_id FROM Customer Customer)&apos;); 
$q-&amp;gt;addSelect(&apos;Customer.id&apos;); 
$q-&amp;gt;addSelect(&apos;Customer.id as customer_id&apos;);
$q-&amp;gt;limit(20); 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Creates this 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 Customer.id, Customer.id as customer_id FROM Customer Customer WHERE Customer.id in (SELECT Customer.id as customer_id FROM Customer Customer) LIMIT 20
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Which creates this broken 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 p.id AS p__id, p.id AS p__0 FROM product_customers p WHERE (p.id in ()) LIMIT 20
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Notice that the subquery has been replaced with just &quot;()&quot;.&lt;/p&gt;

&lt;p&gt;Is there something wrong with my execution, does doctrine just not support subqueries, or is there a bug here?&lt;/p&gt;

&lt;p&gt;Thanks much in advance.&lt;/p&gt;

&lt;p&gt;Sincerely&lt;/p&gt;

&lt;p&gt;Will Ferrer&lt;/p&gt;</description>
                <environment>XP Xamp</environment>
            <key id="11387">DC-692</key>
            <summary>Can not create a subquery in where</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="willf1976">will ferrer</reporter>
                        <labels>
                    </labels>
                <created>Tue, 18 May 2010 21:42:53 +0000</created>
                <updated>Wed, 19 May 2010 00:18:41 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="12993" author="willf1976" created="Wed, 19 May 2010 00:18:41 +0000"  >&lt;p&gt;I have found a way around my problem (looked through the code to figure out how it worked) &amp;#8211; seems that if I put &apos;SQL:&apos; in front of my sub query, and use SQL instead of DQL in the sub query like so:&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;$q = Doctrine_Query::create(); 
$q-&amp;gt;from(&apos;Customer Customer&apos;); 
$q-&amp;gt;addWhere(&apos; Customer.id in (SQL:SELECT p.id AS p__0 FROM product_customers p)&apos;); 
$q-&amp;gt;addSelect(&apos;Customer.id&apos;); 
$q-&amp;gt;addSelect(&apos;Customer.id as customer_id&apos;); 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The correct sql is made:&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.id AS p__id, p.id AS p__0 FROM product_customers p WHERE (p.id in (SELECT p.id AS p__0 FROM product_customers p)) LIMIT 20
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I am not still not sure what is up with trying to use the DQL instead. Looking through the code I see that on line 842 of Doctrine_Query my DQL subquery was being passed to the function $this-&amp;gt;createSubquery()-&amp;gt;parseDqlQuery($trimmed) like so:&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; $q = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;createSubquery()-&amp;gt;parseDqlQuery($trimmed);
$trimmed = $q-&amp;gt;getSqlQuery();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;$trimmed was coming back as false here which is why my subquery wasn&apos;t working.&lt;/p&gt;

&lt;p&gt;Hope that is helpful.&lt;/p&gt;

&lt;p&gt;Best Regards&lt;/p&gt;

&lt;p&gt;Will Ferrer&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-680] HYDRATE_ARRAY causes timeout with no fields selected</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-680</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Calling HYDRATE_ARRAY on a query with&lt;/p&gt;

&lt;p&gt;a) No values selected&lt;br/&gt;
b) select(&apos;*&apos;)&lt;br/&gt;
c) select(&apos;Table.*&apos;)&lt;/p&gt;

&lt;p&gt;causes the entire query object to be loaded, rather than just returning an array of all values. If a limit(1) is used, the correct result is returned. But as soon as it becomes a collection, the entire query object is returned.&lt;/p&gt;

&lt;p&gt;Code to produce problem..&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;$query = Doctrine_Query::create()
        -&amp;gt;from(&apos;Order ord&apos;)
        -&amp;gt;limit(2)
        -&amp;gt;execute(array(), Doctrine_Core::HYDRATE_ARRAY);
        
        print_r($query);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment>Windows 7, Ubuntu 9.10 (Linux), PHP 5.2.10, Zend Framework 1.10</environment>
            <key id="11355">DC-680</key>
            <summary>HYDRATE_ARRAY causes timeout with no fields selected</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="davidma7685">David Ash</reporter>
                        <labels>
                    </labels>
                <created>Thu, 13 May 2010 14:42:20 +0000</created>
                <updated>Thu, 13 May 2010 14:42:20 +0000</updated>
                                    <version>1.2.1</version>
                <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-651] [PATCH] Doctrine_Record::option(&apos;orderBy&apos;, ...) of join&apos;s right side being applied to refTable in m2m relationship</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-651</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When using the &lt;tt&gt;Doctrine_Record::option(&apos;orderBy&apos;, ...)&lt;/tt&gt; feature on a table definition, where that table is the target of a many-to-many join, the specified orderBy columns are applied to the relation table&apos;s alias. So for example, given the following definitions:&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 User &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;uid&apos;, &apos;integer&apos;, &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, array(&apos;primary&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;));
    $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;option(&apos;orderBy&apos;, &apos;uid&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;hasMany(&apos;Group as groups&apos;, array(&apos;refClass&apos; =&amp;gt; &apos;UserGroup&apos;, &apos;local&apos; =&amp;gt; &apos;user_uid&apos;, &apos;foreign&apos; =&amp;gt; &apos;group_id&apos;));
  }
}

class Group &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;gid&apos;, &apos;integer&apos;, &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, array(&apos;primary&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;));
  }

  &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;hasMany(&apos;User as users&apos;, array(&apos;refClass&apos; =&amp;gt; &apos;UserGroup&apos;, &apos;local&apos; =&amp;gt; &apos;group_gid&apos;, &apos;foreign&apos; =&amp;gt; &apos;user_id&apos;));
  }
}

class UserGroup &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;user_uid&apos;, &apos;integer&apos;, &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, array(&apos;primary&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;));
    $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;group_gid&apos;, &apos;integer&apos;, &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, array(&apos;primary&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;));
  }

  &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;User as user&apos;, array(&apos;local&apos; =&amp;gt; &apos;user_uid&apos;, &apos;foreign&apos; =&amp;gt; &apos;uid&apos;));
    $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasOne(&apos;Group as group&apos;, array(&apos;local&apos; =&amp;gt; &apos;group_gid&apos;, &apos;foreign&apos; =&amp;gt; &apos;gid&apos;));
  }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;the following queries:&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;$query = Doctrine_Query::create()
  -&amp;gt;select(&apos;u.*&apos;)
  -&amp;gt;from(&apos;User u&apos;)
  -&amp;gt;leftJoin(&apos;u.groups g WITH g.gid=?&apos;, 1);
echo $query-&amp;gt;getSqlQuery() . &lt;span class=&quot;code-quote&quot;&gt;&quot;\n&quot;&lt;/span&gt;;

$query = Doctrine_Query::create()
  -&amp;gt;select(&apos;g.*&apos;)
  -&amp;gt;from(&apos;Group g&apos;)
  -&amp;gt;leftJoin(&apos;g.users u WITH u.uid=?&apos;, 1);
echo $query-&amp;gt;getSqlQuery() . &lt;span class=&quot;code-quote&quot;&gt;&quot;\n&quot;&lt;/span&gt;;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;will output the following:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;SELECT u.uid AS u__uid FROM user u LEFT JOIN user_group u2 ON (u.uid = u2.user_uid) LEFT JOIN group g ON g.gid = u2.group_id AND (g.gid = ?) ORDER BY u.uid&lt;br/&gt;
SELECT g.gid AS g__gid FROM group g LEFT JOIN user_group u2 ON (g.gid = u2.group_gid) LEFT JOIN user u ON u.uid = u2.user_id AND (u.uid = ?) ORDER BY u.uid, u2.uid&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;The &lt;tt&gt;orderBy&lt;/tt&gt; &lt;tt&gt;option()&lt;/tt&gt; call is applied to the &lt;tt&gt;User&lt;/tt&gt; definition. The SQL for the first query is correct (where &lt;tt&gt;User&lt;/tt&gt; is on the left side of the join). The SQL for the second query (where &lt;tt&gt;User&lt;/tt&gt; is on the right-most side of the join), however, is obviously incorrect (&lt;tt&gt;UserGroup&lt;/tt&gt; doesn&apos;t even have a &lt;tt&gt;uid&lt;/tt&gt; column). Basically, &lt;tt&gt;User&lt;/tt&gt;&apos;s &lt;tt&gt;orderBy&lt;/tt&gt; option is being applied to both the &lt;tt&gt;User&lt;/tt&gt; table and its respective reference table, &lt;tt&gt;UserGroup&lt;/tt&gt;, when it is the target of a join.&lt;/p&gt;

&lt;p&gt;After digging through the source for a while, I believe I&apos;ve come up with a patch for this issue (which should be checked by someone more knowledgeable of Doctrine&apos;s internals). Basically, in the &lt;tt&gt;Doctrine_Query::buildSqlQuery()&lt;/tt&gt; function, a call is made to &lt;tt&gt;Doctrine_Relation::getOrderByStatement()&lt;/tt&gt; with the reference table (&lt;tt&gt;UserGroup&lt;/tt&gt;)&apos;s alias (&lt;tt&gt;u2&lt;/tt&gt;), which in turn makes a call to &lt;tt&gt;Doctrine_Table::getOrderByStatement()&lt;/tt&gt; on the referenced table (&lt;tt&gt;User&lt;/tt&gt;), filling in the &lt;tt&gt;ORDER BY&lt;/tt&gt; clause with &lt;tt&gt;User&lt;/tt&gt; columns using &lt;tt&gt;UserGroup&lt;/tt&gt;&apos;s alias. My solution was to reorder the logic so that the test for a reference class is made before the initial call to &lt;tt&gt;getOrderByStatement()&lt;/tt&gt; is made. It seems to work against my test case and the test cases in the repository. I&apos;ll post my patch momentarily.&lt;/p&gt;

&lt;p&gt;This bug was first mentioned in the comments in &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-313&quot; title=&quot;Ordering m2m relationship with column from related table (with orderBy option)&quot;&gt;DC-313&lt;/a&gt;, but the original ticket comes across as more of a feature request for the &lt;tt&gt;hasMany()&lt;/tt&gt; &lt;tt&gt;orderBy&lt;/tt&gt; feature.&lt;/p&gt;</description>
                <environment>CentOS 5.4&lt;br/&gt;
PHP 5.3.2&lt;br/&gt;
MySQL 5.1.44, for unknown-linux-gnu (x86_64)</environment>
            <key id="11270">DC-651</key>
            <summary>[PATCH] Doctrine_Record::option(&apos;orderBy&apos;, ...) of join&apos;s right side being applied to refTable in m2m relationship</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="suhock">suhock</reporter>
                        <labels>
                    </labels>
                <created>Mon, 26 Apr 2010 12:22:21 +0000</created>
                <updated>Wed, 31 Aug 2011 12:43:09 +0000</updated>
                                    <version>1.2.2</version>
                <version>1.2.3</version>
                                <fixVersion>1.2.2</fixVersion>
                <fixVersion>1.2.3</fixVersion>
                <fixVersion>1.2.4</fixVersion>
                                <component>Query</component>
                <component>Relations</component>
                        <due></due>
                    <votes>2</votes>
                        <watches>4</watches>
                        <comments>
                    <comment id="12750" author="suhock" created="Mon, 26 Apr 2010 12:45:12 +0000"  >&lt;p&gt;attached a test case for this bug&lt;/p&gt;</comment>
                    <comment id="12751" author="suhock" created="Mon, 26 Apr 2010 13:01:03 +0000"  >&lt;p&gt;patch against /branches/1.2 HEAD (should also work apply to 1.2.2 tag)&lt;/p&gt;</comment>
                    <comment id="14179" author="dordille" created="Mon, 30 Aug 2010 17:22:44 +0000"  >&lt;p&gt;I can confirm this as an issue.  However I don&apos;t think the above patch adequately fixes the problem it seems like with it an order by is still added for the ref column however the relation alias is lost.&lt;/p&gt;

&lt;p&gt;My query with the patch became&lt;br/&gt;
SELECT g.gid AS g__gid FROM group g LEFT JOIN user_group u2 ON (g.gid = u2.group_gid) LEFT JOIN user u ON u.uid = u2.user_id AND (u.uid = ?) ORDER BY u.uid, uid &lt;/p&gt;

&lt;p&gt;I made an another patch that prevents this extra order by clause from being added and have attached it.&lt;/p&gt;
</comment>
                    <comment id="14428" author="suhock" created="Tue, 21 Sep 2010 08:53:25 +0000"  >&lt;p&gt;I tried out the new patch (Query_orderby_relation.diff), but it provides a reversed diff (patching goes from a patched version to the original). After applying it manually, it fails the provided test case and several additional test cases from the repository.&lt;/p&gt;

&lt;p&gt;The original patch DOES pass the provided test case, when applied against 1.2.2, 1.2.3, or the 1.2 branch from the repository. It does not pass, however, Doctrine_Query_Orderby_TestCase. As the previous poster mentioned, it fails to resolve aliases in instances where the &apos;orderBy&apos; option is specified in a relation definition.&lt;/p&gt;

&lt;p&gt;I deleted the original patch and am providing a revised patch (Ticket_DC651.patch) against branch 1.2 HEAD (also works with 1.2.3), which fixes this issue. It passes all working test cases, including Doctrine_Query_Orderby_TestCase and DC651TestCase.&lt;/p&gt;</comment>
                    <comment id="16406" author="deraujoj" created="Wed, 31 Aug 2011 12:43:08 +0000"  >&lt;p&gt;I had this issue recently on a application I&apos;m working on as described the oderBy option was applied on the joined table on a column that even doesn&apos;t exist in it. I used the DC651 patch provided and it solved the issue, so far I haven&apos;t seen any side effect to it. &lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10585" name="DC651TestCase.php" size="3335" author="suhock" created="Mon, 26 Apr 2010 12:45:12 +0000" />
                    <attachment id="10751" name="Query_orderBy_relation.diff" size="1122" author="dordille" created="Mon, 30 Aug 2010 17:22:56 +0000" />
                    <attachment id="10806" name="Ticket_DC651.patch" size="1448" author="suhock" created="Tue, 21 Sep 2010 08:53:25 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-637] Many-to-many: Using Association Class (refclass) property in query adds leftJoin</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-637</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When trying to use a refclass property - i.e. normalization table column - in a query, an unnecessary join is added to the query created, which is then used to &quot;access&quot; the property.&lt;/p&gt;

&lt;p&gt;This issue has already been discussed back in May 2008 but still seems to persist.&lt;br/&gt;
Please see the google group discussion &lt;a href=&quot;http://groups.google.com/group/doctrine-user/browse_thread/thread/c655832a450ccd1a/9cb6eca6ae1c3dee&quot; class=&quot;external-link&quot;&gt;http://groups.google.com/group/doctrine-user/browse_thread/thread/c655832a450ccd1a/9cb6eca6ae1c3dee&lt;/a&gt; for example + comments.&lt;/p&gt;

&lt;p&gt;Unfortunately it is hardly possible to write a test case for this, as working SQL is generated, but the query is just not right (test case basically would have to assert the query string, wich does not make much sense).&lt;br/&gt;
Another way to test if it does &quot;what it should&quot;, could be to assert contents of $q-&amp;gt;getTableAliasMap() - but does not seem ideal either.&lt;/p&gt;

&lt;p&gt;John Wage commented on this issue &lt;br/&gt;
&quot;Can you create a ticket for this with a failing test case? I believe this&lt;br/&gt;
should be possible and we should investigate a fix for it. &lt;br/&gt;
Thanks, Jon &quot;&lt;br/&gt;
&lt;a href=&quot;http://groups.google.com/group/doctrine-user/browse_thread/thread/c655832a450ccd1a/9cb6eca6ae1c3dee#msg_c73934a38515cadb&quot; class=&quot;external-link&quot;&gt;http://groups.google.com/group/doctrine-user/browse_thread/thread/c655832a450ccd1a/9cb6eca6ae1c3dee#msg_c73934a38515cadb&lt;/a&gt;&lt;/p&gt;</description>
                <environment>PHP 5.3.2 (cli) (built: Mar  4 2010 22:12:20)&lt;br/&gt;
mysql 5.1.45&lt;br/&gt;
centOS</environment>
            <key id="11246">DC-637</key>
            <summary>Many-to-many: Using Association Class (refclass) property in query adds leftJoin</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="grass">Pablo Grass</reporter>
                        <labels>
                    </labels>
                <created>Tue, 20 Apr 2010 06:31:54 +0000</created>
                <updated>Tue, 20 Apr 2010 06:39:21 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                                <attachments>
                    <attachment id="10581" name="example.php" size="1782" author="grass" created="Tue, 20 Apr 2010 06:31:54 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-625] Doctrine_Query throws exception for custom hydrator that extends stock hydrator</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-625</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;I have a custom hydrator that extends Doctrine_Hydrator_ScalarDriver, for the sole purpose of simplifying the column keys (by passing false as the 3rd parameter on _gatherRowData):&lt;/p&gt;

&lt;p&gt;class Doctrine_Hydrator_AssocDriver extends Doctrine_Hydrator_ScalarDriver&lt;br/&gt;
{&lt;br/&gt;
    public function hydrateResultSet($stmt)&lt;br/&gt;
    {&lt;br/&gt;
        $cache = array();&lt;br/&gt;
        $result = array();&lt;/p&gt;

&lt;p&gt;        while ($data = $stmt-&amp;gt;fetch(Doctrine_Core::FETCH_ASSOC)) &lt;/p&gt;
{
            $result[] = $this-&amp;gt;_gatherRowData($data, $cache, false);
        }

&lt;p&gt;        return $result;&lt;br/&gt;
    }&lt;br/&gt;
}&lt;/p&gt;


&lt;p&gt;The processPendingFields method in Doctrine_Query is unnecessarily throwing a Doctrine_Query_Exception at line 465.  This can be resolved by skipping hydration methods that extend None, Scalar and SingleScalar.&lt;/p&gt;

&lt;p&gt;A diff of the changes is attached.&lt;/p&gt;</description>
                <environment>Windows Vista, Apache 2.2, PHP 5.3, MySQL 5.1</environment>
            <key id="11198">DC-625</key>
            <summary>Doctrine_Query throws exception for custom hydrator that extends stock hydrator</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="jaredmellentine">Jared Mellentine</reporter>
                        <labels>
                    </labels>
                <created>Fri, 9 Apr 2010 17:33:17 +0000</created>
                <updated>Tue, 20 Apr 2010 16:22:39 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                                <attachments>
                    <attachment id="10564" name="Query.diff" size="1171" author="jaredmellentine" created="Fri, 9 Apr 2010 17:33:17 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-608] Limit and Offset breaks query with multiple non-join FROM statements</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-608</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;blockquote&gt;
&lt;p&gt;$query = $query-&amp;gt;select(&apos;sf_guard_permission.id,&lt;br/&gt;
      cms_section_translation.slug||\&apos; \&apos;||SUBSTRING(&quot;name&quot;, POSITION(\&apos;@\&apos; in &quot;name&quot;) + 1) as name,&lt;br/&gt;
      sf_guard_permission.description,&lt;br/&gt;
      sf_guard_permission.created_at, sf_guard_permission.updated_at&apos;);&lt;br/&gt;
    $query = $query-&amp;gt;from(&apos;sfGuardPermission sf_guard_permission&apos;);&lt;br/&gt;
    $query = $query-&amp;gt;addfrom(&apos;CmsSection cms_section&apos;);&lt;br/&gt;
    $query = $query-&amp;gt;innerJoin(&apos;cms_section.WithCmsSectionTranslation cms_section_translation&apos;);&lt;br/&gt;
    $query = $query-&amp;gt;where(&apos;cast(SUBSTRING(&quot;name&quot;, 1, POSITION(\&apos;@\&apos; in &quot;name&quot;) - 1) as integer) = cms_section.id&apos;);&lt;br/&gt;
    $query = limit(20);&lt;br/&gt;
    $query = offset(1);&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Generated:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SELECT s.id AS s_&lt;em&gt;id, s.description AS s&lt;/em&gt;&lt;em&gt;description, s.created_at AS  s&lt;/em&gt;&lt;em&gt;created_at, s.updated_at AS s&lt;/em&gt;&lt;em&gt;updated_at, c2.slug||&apos;  &apos;||SUBSTR(&quot;name&quot;, POSITION(&apos;@&apos; in &quot;name&quot;) + 1) AS c2&lt;/em&gt;_0 FROM  sf_guard_permission s, cms_section c INNER JOIN cms_section_translation  c2 ON c.id = c2.sec_id WHERE s.id IN (SELECT doctrine_subquery_alias.id  FROM (SELECT DISTINCT s2.id, c3.deleted_at FROM sf_guard_permission s2  cms_section c3 INNER JOIN cms_section_translation c4 ON c3.id =  c4.sec_id WHERE cast(SUBSTR(&quot;name&quot;, 1, POSITION(&apos;@&apos; in &quot;name&quot;) - 1) as  integer) = c3.id ORDER BY c3.deleted_at DESC LIMIT 20) AS  doctrine_subquery_alias) AND (cast(SUBSTR(&quot;name&quot;, 1, POSITION(&apos;@&apos; in  &quot;name&quot;) - 1) as integer) = c.id) ORDER BY c.deleted_at DESC&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Notice:&lt;br/&gt;
SELECT DISTINCT s2.id, c3.deleted_at FROM sf_guard_permission s2 &lt;font color=&quot;red&quot;&gt; comma that is missing &lt;/font&gt; cms_section c3&lt;/p&gt;</description>
                <environment></environment>
            <key id="11152">DC-608</key>
            <summary>Limit and Offset breaks query with multiple non-join FROM statements</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="sid.gbf">Sid GBF</reporter>
                        <labels>
                    </labels>
                <created>Tue, 30 Mar 2010 13:38:28 +0000</created>
                <updated>Tue, 30 Mar 2010 13:38:28 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                    <attachment id="10526" name="query.diff" size="552" author="sid.gbf" created="Tue, 30 Mar 2010 13:38:28 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-610] Chaining innerjoins can only be made uni-directional; order matters</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-610</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;The following code fails&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;This doesn&apos;t work&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;Doctrine_Query::create()
	-&amp;gt;select(&apos;Table t1&apos;)
	-&amp;gt;innerJoin(&apos;f1.Foreign2 f2 WITH f1.field = 2&apos;)
	-&amp;gt;innerJoin(&apos;t1.Foreign1 f1&apos;)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Doctrine seems only to be happy when we change the order of the inner joins&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;This works&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;Doctrine_Query::create()
	-&amp;gt;select(&apos;Table t1&apos;)
	-&amp;gt;innerJoin(&apos;t1.Foreign1 f1&apos;)
	-&amp;gt;innerJoin(&apos;f1.Foreign2 f2 WITH f1.field = 2&apos;)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment>I&amp;#39;ve witnessed the problem in Doctrine 1.2.2 and 1.2.1</environment>
            <key id="11155">DC-610</key>
            <summary>Chaining innerjoins can only be made uni-directional; order matters</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="exceptione">Exception e</reporter>
                        <labels>
                    </labels>
                <created>Tue, 30 Mar 2010 17:07:53 +0000</created>
                <updated>Fri, 31 Dec 2010 17:18:07 +0000</updated>
                                    <version>1.2.1</version>
                <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="12521" author="exceptione" created="Tue, 30 Mar 2010 17:09:16 +0000"  >&lt;p&gt;fixed typo&lt;/p&gt;</comment>
                    <comment id="15078" author="dquintard" created="Fri, 31 Dec 2010 17:17:05 +0000"  >&lt;p&gt;What about this issue.&lt;br/&gt;
I&apos;ve got the same:&lt;/p&gt;

&lt;p&gt;$q2 = Doctrine_Query::create()&lt;br/&gt;
			-&amp;gt;select(&apos;*&apos;)&lt;br/&gt;
			-&amp;gt;from(&apos;Model_TForfaitType ft&apos;)&lt;br/&gt;
			-&amp;gt;innerJoin(&apos;ft.TServiceForfait sf&apos;);&lt;br/&gt;
		echo $q2-&amp;gt;getSqlQuery();&lt;br/&gt;
		$results = $q2-&amp;gt;fetchArray();&lt;br/&gt;
		echo &quot;results:&quot;.count($results).&quot;&amp;lt;br&amp;gt;&quot;; =&amp;gt; 3 results&lt;/p&gt;

&lt;p&gt;		$q3 = Doctrine_Query::create()&lt;br/&gt;
			-&amp;gt;select(&apos;*&apos;)&lt;br/&gt;
			-&amp;gt;from(&apos;Model_TServiceForfait sf&apos;)&lt;br/&gt;
			-&amp;gt;innerJoin(&apos;sf.TForfaitType ft&apos;);&lt;br/&gt;
		echo $q3-&amp;gt;getSqlQuery();		&lt;br/&gt;
		$results = $q3-&amp;gt;fetchArray();&lt;br/&gt;
		echo &quot;results:&quot;.count($results).&quot;&amp;lt;br&amp;gt;&quot;; =&amp;gt; 16 results&lt;/p&gt;

&lt;p&gt;		$q4 = Doctrine_Query::create()&lt;br/&gt;
			-&amp;gt;select(&apos;*&apos;)&lt;br/&gt;
			-&amp;gt;from(&apos;Model_TServiceForfait,Model_TForfaitType&apos;);&lt;br/&gt;
		echo $q4-&amp;gt;getSqlQuery();		&lt;br/&gt;
		$results = $q4-&amp;gt;fetchArray();&lt;br/&gt;
		echo &quot;results:&quot;.count($results).&quot;&amp;lt;br&amp;gt;&quot;; =&amp;gt; 16 results&lt;/p&gt;

&lt;p&gt;Moreover i tried with Doctrine 1.3 and this problem is not resolved.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-606] [Oracle] Query on M:M with relation name doesn&apos;t work</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-606</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;My schema:&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;---
Actuality:
  connection:         web
  tableName:          actuality
  actAs:
    softDelete:       ~
    Timestampable:    ~
    Sluggable:
      fields:         [name]
      builder:        [tool, slugify]
      indexName:      actuality_sluggable
      canUpdate:      &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
  columns:
    id:
      type:           integer(4)
      primary:        &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      unsigned:       &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      sequence:       actuality
    created_at:
      type:           timestamp
    updated_at:
      type:           timestamp
    published_at:
      type:           timestamp
      notnull:        &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    unpublished_at:
      type:           timestamp
    name:
      type:           string(255)
      notnull:        &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    description_short:
      type:           string(1000)
      notnull:        &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    description:
      type:           clob
      notnull:        &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    is_professional:
      type:           &lt;span class=&quot;code-object&quot;&gt;boolean&lt;/span&gt;
      &lt;span class=&quot;code-keyword&quot;&gt;default&lt;/span&gt;:        &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
  relations:
    Categories:
      class: ActualityCategory
      local: actuality_id
      foreign: actuality_category_id
      refClass: ActualityActualityCategory
      foreignAlias: Actualities
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And my query:&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;&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function retrieveCloud($is_professional, $limit = 20)
  {
    &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;createQuery(&apos;ac&apos;)
    -&amp;gt;leftJoin(&apos;ac.Actualities a2&apos;)
    -&amp;gt;where(&apos;ac.id IN (SELECT aac.actuality_category_id FROM Actuality a LEFTJOIN a.ActualityActualityCategory aac WHERE a.published_at &amp;lt; ? AND a.is_professional = ?)&apos;, array(date(&apos;Y-m-d H:i:s&apos;), $is_professional))
    -&amp;gt;orderBy(&apos;ac.name&apos;)
    -&amp;gt;limit($limit)
    -&amp;gt;execute();
  }
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I have this error: Doctrine_Connection_Oracle_Exception&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;ORA-01008: not all variables bound : SELECT a.id AS a__id, a.created_at AS a__created_at, a.updated_at AS a__updated_at, a.name AS a__name, a.deleted_at AS a__deleted_at, a.slug AS a__slug, a2.id AS a2__id, a2.created_at AS a2__created_at, a2.updated_at AS a2__updated_at, a2.published_at AS a2__published_at, a2.unpublished_at AS a2__unpublished_at, a2.name AS a2__name, a2.description_short AS a2__description_short, a2.description AS a2__description, a2.is_professional AS a2__is_professional, a2.deleted_at AS a2__deleted_at, a2.slug AS a2__slug FROM actuality_category a LEFT JOIN actuality_actuality_category a3 ON (a.id = a3.actuality_category_id) LEFT JOIN actuality a2 ON a2.id = a3.actuality_id AND (a2.deleted_at IS NULL) WHERE a.id IN (SELECT a4.id FROM ( SELECT DISTINCT a4.id FROM actuality_category a4 LEFT JOIN actuality_actuality_category a6 ON (a4.id = a6.actuality_category_id) LEFT JOIN actuality a5 ON a5.id = a6.actuality_id AND (a5.deleted_at IS NULL) WHERE a4.id IN (SELECT a8.actuality_category_id AS a5__actuality_category_id FROM actuality a7 LEFT JOIN actuality_actuality_category a8 ON a7.id = a8.actuality_id WHERE (a7.published_at &amp;lt; :oci_b_var_1 AND a7.is_professional = :oci_b_var_2)) AND (a4.deleted_at IS NULL) ORDER BY a4.name ) a4 WHERE ROWNUM &amp;lt;= 20) AND (a.id IN (SELECT a5.actuality_category_id AS a5__actuality_category_id FROM actuality a4 LEFT JOIN actuality_actuality_category a5 ON a4.id = a5.actuality_id WHERE (a4.published_at &amp;lt; :oci_b_var_3 AND a4.is_professional = :oci_b_var_4)) AND (a.deleted_at IS NULL)) ORDER BY a.name
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment></environment>
            <key id="11147">DC-606</key>
            <summary>[Oracle] Query on M:M with relation name doesn&apos;t work</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="garfield-fr">Bertrand Zuchuat</reporter>
                        <labels>
                    </labels>
                <created>Mon, 29 Mar 2010 04:20:23 +0000</created>
                <updated>Mon, 29 Mar 2010 04:20:23 +0000</updated>
                                    <version>1.2.1</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-601] When using a join and giving an alias to each select column the hyrdrator only returns one row.</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-601</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Hi All &lt;br/&gt;
I am running into a strange problem using Doctrine-1.2.2-- I have a  multi row result set but only the first row of it is returned in the hyrdated array that is generated. &lt;br/&gt;
I have tracked this down in the code to get a basic idea of whats going on &amp;#8211; it seems that the $id variable in the hydrateResultSet function in Doctrine_Hydrator_Graph isn&apos;t being populated properly with data about the fields that are returning from my query. The _gatherRowData function seems to never detect that one of my columns is an identifier (&quot;if ($cache&lt;span class=&quot;error&quot;&gt;&amp;#91;$key&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;isIdentifier&amp;#39;&amp;#93;&lt;/span&gt;) &lt;/p&gt;
{&quot; doesn&apos;t return true ever so the next line of code: &quot;$id[$dqlAlias] .= &apos;|&apos; . $value;&quot; doesn&apos;t run). 
I think this is the problem but I don&apos;t totally understand how the mapping process is taking place in this function so can&apos;t be absolutely sure. 

This hydration problem goes away if I don&apos;t use left joins in my query, or if I use a query where not every field I am requesting is assigned an alias (at least one of the fields doesn&apos;t use the &apos;as&apos; syntax). 
For instance this php: 
{code}
&lt;p&gt;$q = Doctrine_Query::create(); &lt;br/&gt;
$q-&amp;gt;from(&apos;Customer Customer&apos;); &lt;br/&gt;
$q-&amp;gt;leftJoin(&apos;Customer.Zip Zip&apos;); &lt;br/&gt;
$q-&amp;gt;addSelect(&apos;Customer.firstname as first_name&apos;); &lt;br/&gt;
$q-&amp;gt;addSelect(&apos;Customer.postalcode as postalcode&apos;); &lt;br/&gt;
$q-&amp;gt;setHydrationMode(Doctrine::HYDRATE_ARRAY); &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;Generates &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; DQL: 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;SELECT Customer.firstname as first_name, Customer.postalcode as postalcode FROM Customer Customer LEFT JOIN Customer.Zip Zip&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;And &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; SQL:
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;SELECT c.firstname AS c_&lt;em&gt;0, c.postalcode AS c&lt;/em&gt;_1 FROM customers c LEFT JOIN zips z ON c.postalcode = z.postalcode&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;Which results in &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; after hyrdration: 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;array(&apos;0&apos;=&amp;gt;array(&apos;first_name&apos;=&amp;gt;&apos;Armando&apos;, &apos;postalcode&apos;=&amp;gt;&apos;00659&apos;)) &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;
However the following code hydrates just fine: 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;$q = Doctrine_Query::create(); &lt;br/&gt;
$q-&amp;gt;from(&apos;Customer Customer&apos;); &lt;br/&gt;
$q-&amp;gt;addSelect(&apos;Customer.firstname as first_name&apos;); &lt;br/&gt;
$q-&amp;gt;setHydrationMode(Doctrine::HYDRATE_ARRAY); &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;As does &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; code: 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;$q = Doctrine_Query::create(); &lt;br/&gt;
$q-&amp;gt;from(&apos;Customer Customer&apos;); &lt;br/&gt;
$q-&amp;gt;leftJoin(&apos;Customer.Zip Zip&apos;); &lt;br/&gt;
$q-&amp;gt;addSelect(&apos;Customer.firstname&apos;); &lt;br/&gt;
$q-&amp;gt;addSelect(&apos;Customer.postalcode as postalcode&apos;); &lt;br/&gt;
$q-&amp;gt;setHydrationMode(Doctrine::HYDRATE_ARRAY); &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;
Here is the yaml &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; the sample data I am testing on: 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt; detect_relations: false&lt;br/&gt;
 package: Example&lt;br/&gt;
 options:&lt;br/&gt;
   type: INNODB&lt;br/&gt;
   charset: utf8&lt;br/&gt;
 Customer:&lt;br/&gt;
   tableName: customers&lt;br/&gt;
   columns:&lt;br/&gt;
     customer_id:&lt;br/&gt;
       type: integer(4)&lt;br/&gt;
       primary: true&lt;br/&gt;
       notnull: true&lt;br/&gt;
       autoincrement: true&lt;br/&gt;
     firstname:&lt;br/&gt;
       type: string(45)&lt;br/&gt;
     lastname:&lt;br/&gt;
       type: string(45)&lt;br/&gt;
     streetaddress:&lt;br/&gt;
       type: string(45)&lt;br/&gt;
     city:&lt;br/&gt;
       type: string(45)&lt;br/&gt;
     state:&lt;br/&gt;
       type: string(45)&lt;br/&gt;
     postalcode:&lt;br/&gt;
       type: string(45)&lt;br/&gt;
   relations:&lt;br/&gt;
     Order:&lt;br/&gt;
       type: many&lt;br/&gt;
       local: customer_id&lt;br/&gt;
       foreign: customer_id&lt;br/&gt;
     Zip:&lt;br/&gt;
       type: one&lt;br/&gt;
       local: postalcode&lt;br/&gt;
       foreign: postalcode&lt;br/&gt;
   options:&lt;br/&gt;
     type: InnoDB&lt;br/&gt;
 Zip:&lt;br/&gt;
   connection: default_schema&lt;br/&gt;
   tableName: zips&lt;br/&gt;
   columns:&lt;br/&gt;
     postalcode:&lt;br/&gt;
       type: varchar(30)&lt;br/&gt;
       primary: true&lt;br/&gt;
     latitude: &apos;float(10,6)&apos;&lt;br/&gt;
     longitude: &apos;float(10,6)&apos;&lt;br/&gt;
     city: string(50)&lt;br/&gt;
     state: string(50)&lt;br/&gt;
     country: string(50)&lt;br/&gt;
     type: string(50)&lt;br/&gt;
   relations:&lt;br/&gt;
     Customer:&lt;br/&gt;
       type: many&lt;br/&gt;
       local: postalcode&lt;br/&gt;
       foreign: postalcode&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;&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Perhaps there is something simple I am overlooking. To get around this I am just always selecting the primary key from my main table in every query.&lt;/p&gt;

&lt;p&gt;Thanks in advance for any advice.&lt;br/&gt;
Will Ferrer&lt;/p&gt;</description>
                <environment>XP Xamp</environment>
            <key id="11139">DC-601</key>
            <summary>When using a join and giving an alias to each select column the hyrdrator only returns one row.</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="willf1976">will ferrer</reporter>
                        <labels>
                    </labels>
                <created>Thu, 25 Mar 2010 19:32:28 +0000</created>
                <updated>Mon, 2 Aug 2010 02:45:07 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                <component>Relations</component>
                        <due></due>
                    <votes>2</votes>
                        <watches>3</watches>
                        <comments>
                    <comment id="12564" author="willf1976" created="Sat, 3 Apr 2010 18:13:13 +0000"  >&lt;p&gt;This problem also exists in 1.2.2 so I have updated the post to reflect this.&lt;/p&gt;</comment>
                    <comment id="12582" author="naag" created="Tue, 6 Apr 2010 08:30:00 +0000"  >&lt;p&gt;I experienced the same problem with Doctrine 1.2 (r7329). I also fixed this by adding the primary key of the table I select from to the select list.&lt;/p&gt;</comment>
                    <comment id="12603" author="willf1976" created="Wed, 7 Apr 2010 20:20:21 +0000"  >&lt;p&gt;Hi Peter&lt;/p&gt;

&lt;p&gt;Thats how I am currently working around the bug as well but hopefully it will get rectified in a later version of doctrine.&lt;/p&gt;

&lt;p&gt;Thanks for the comment.&lt;/p&gt;

&lt;p&gt;Will&lt;/p&gt;</comment>
                    <comment id="13139" author="somedoun" created="Tue, 8 Jun 2010 09:08:54 +0000"  >&lt;p&gt;Hi all,&lt;/p&gt;

&lt;p&gt;I&apos;m new to doctrine and since yesterday, I&apos;m experiencing exactly the same behavior.&lt;br/&gt;
Any news about this subject ? Is there a doctrine version where the pb is solved ? &lt;br/&gt;
Help !&lt;/p&gt;

&lt;p&gt;Regards,&lt;br/&gt;
Doun&lt;/p&gt;</comment>
                    <comment id="13239" author="willf1976" created="Tue, 8 Jun 2010 19:13:11 +0000"  >&lt;p&gt;Hi Sam&lt;/p&gt;

&lt;p&gt;Currently I am working around this bug by always adding the primary key of the table to the select (like peter also mentions above).&lt;/p&gt;

&lt;p&gt;It is a work around for the problem but so far it has been reliable for me.&lt;/p&gt;

&lt;p&gt;I hope that helps until there is a patch for it.&lt;/p&gt;

&lt;p&gt;Will Ferrer&lt;/p&gt;</comment>
                    <comment id="13246" author="somedoun" created="Wed, 9 Jun 2010 05:18:14 +0000"  >&lt;p&gt;Hi Will&lt;/p&gt;

&lt;p&gt;I&apos;ll do so.&lt;br/&gt;
Thank you VM.&lt;/p&gt;

&lt;p&gt;Sam Doun&lt;/p&gt;</comment>
                    <comment id="13756" author="shuchi" created="Mon, 2 Aug 2010 02:26:10 +0000"  >&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;Has there been any patch release for the same? &lt;br/&gt;
We just upgraded from Doctrine 1.1 to 1.2 and our project now crashes.&lt;/p&gt;

&lt;p&gt;For DQL - &lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;function getServiceDetails($merchantId,$merchantServiceId) {
    $q = Doctrine_Query::create()
        -&amp;gt;select(&apos;b.*, m.name as merchant_service_name,payment_mode.name as payment_mode_name,payment_mode.id as paymentMode,p.id as paymentModeOption &apos;)
        -&amp;gt;from(&apos;ServicePaymentModeOption b&apos;)
        -&amp;gt;leftJoin(&quot;b.MerchantService m&quot;)
        -&amp;gt;leftJoin(&quot;m.Merchant merchant&quot;)
        -&amp;gt;leftJoin(&quot;b.PaymentModeOption p&quot;)
        -&amp;gt;leftJoin(&quot;p.PaymentMode payment_mode&quot;)
        -&amp;gt;where(&quot;merchant.id=?&quot;,$merchantId)
        -&amp;gt;andWhere(&quot;b.merchant_service_id=?&quot;,$merchantServiceId)
        -&amp;gt;groupBy(&apos;p.name&apos;);

    return $res = $q-&amp;gt;execute(array(),Doctrine::HYDRATE_ARRAY);
  }  
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;Result with Doctrine 1.1 is&lt;/b&gt;&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;Array
(
    [0] =&amp;gt; Array
        (
            [id] =&amp;gt; 1
            [merchant_service_id] =&amp;gt; 1
            [payment_mode_option_id] =&amp;gt; 1
            [created_at] =&amp;gt;
            [updated_at] =&amp;gt;
            [deleted] =&amp;gt;
            [created_by] =&amp;gt;
            [updated_by] =&amp;gt;
            [merchant_service_name] =&amp;gt; NIS Passport
            [merchant_name] =&amp;gt; NIS
            [payment_mode_option_name] =&amp;gt; Bank
            [payment_mode_name] =&amp;gt; Bank
            [paymentMode] =&amp;gt; 1
            [paymentModeOption] =&amp;gt; 1
            [MerchantService] =&amp;gt; Array
                (
                    [merchant_service_name] =&amp;gt; NIS Passport
                    [Merchant] =&amp;gt; Array
                        (
                            [merchant_name] =&amp;gt; NIS
                        )

                )

            [PaymentModeOption] =&amp;gt; Array
                (
                    [payment_mode_option_name] =&amp;gt; Bank
                    [paymentModeOption] =&amp;gt; 1
                    [PaymentMode] =&amp;gt; Array
                        (
                            [payment_mode_name] =&amp;gt; Bank
                            [paymentMode] =&amp;gt; 1
                        )

                )

        )
)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;Result with Doctrine 1.2 is&lt;/b&gt;&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;Array
(
    [0] =&amp;gt; Array
        (
            [id] =&amp;gt; 1
            [merchant_service_id] =&amp;gt; 1
            [payment_mode_option_id] =&amp;gt; 1
            [created_at] =&amp;gt;
            [updated_at] =&amp;gt;
            [deleted_at] =&amp;gt;
            [created_by] =&amp;gt;
            [updated_by] =&amp;gt;
            [merchant_service_name] =&amp;gt; NIS Passport
            [merchant_name] =&amp;gt; NIS
            [payment_mode_option_name] =&amp;gt; Bank
            [payment_mode_name] =&amp;gt; Bank
            [paymentMode] =&amp;gt; 1
            [paymentModeOption] =&amp;gt; 1
        )
)

&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We have used Hydration for the result set at lot of places. Please suggest if there could be a fix without going about revising everything that has been coded.&lt;/p&gt;

&lt;p&gt;Looking forward to a quick response.&lt;/p&gt;





</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-600] Query Cache causes exception when using array parameter and IN in a where clause</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-600</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Following the documentation, I&apos;m using an IN condition in a where clause on a Doctrine_Query with Query cache enabled (APC).  Syntax:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;$values = array(1, 2, 3, 4);&lt;/p&gt;

&lt;p&gt;$q = Doctrine_Query::create()&lt;del&gt;&amp;gt;from(&apos;SomeModel s&apos;)&lt;/del&gt;&amp;gt;where(&apos;s.column IN ?&apos;, array($values));&lt;/p&gt;

&lt;p&gt;$results = $q-&amp;gt;execute();&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;The first time this query is run, all is fine, and any subsequent runs will be fine as well, UNLESS the values array changes length, like so:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;$values = array(1, 2, 3, 4, 5);&lt;/p&gt;

&lt;p&gt;$q = Doctrine_Query::create()&lt;del&gt;&amp;gt;from(&apos;SomeModel s&apos;)&lt;/del&gt;&amp;gt;where(&apos;s.column IN ?&apos;, array($values));&lt;/p&gt;

&lt;p&gt;$results = $q-&amp;gt;execute();&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;With the query cache enabled, this will throw a PDO &quot;Invalid Parameter Count&quot; exception, because it appears that Doctrine uses the cached query which only has 4 placeholders, but the passed parameters now has a count of 5.&lt;/p&gt;

&lt;p&gt;A change in the length of the parameters array in this situation should cause Doctrine to insert a new entry into the query cache for this query.&lt;/p&gt;

&lt;p&gt;Let me know if you need more information regarding this, if I find time I can try to put together a Test case.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;</description>
                <environment>PHP 5.2.11 Linux, Mysql 5.0.x</environment>
            <key id="11135">DC-600</key>
            <summary>Query Cache causes exception when using array parameter and IN in a where clause</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="jklehr">Jay Klehr</reporter>
                        <labels>
                    </labels>
                <created>Thu, 25 Mar 2010 14:38:22 +0000</created>
                <updated>Wed, 21 Jul 2010 09:07:08 +0000</updated>
                                    <version>1.2.1</version>
                <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="12517" author="jklehr" created="Tue, 30 Mar 2010 15:06:03 +0000"  >&lt;p&gt;Failing test case exhibiting this bug.&lt;/p&gt;</comment>
                    <comment id="12518" author="jklehr" created="Tue, 30 Mar 2010 15:09:41 +0000"  >&lt;p&gt;I&apos;ve attached a TestCase that I put together that shows this bug.&lt;/p&gt;

&lt;p&gt;Turns out that when using the sqlite adapter, the exception isn&apos;t thrown, so I had to look at the profiler in order to show that the query fetched from the cache has the wrong parameter count.&lt;/p&gt;

&lt;p&gt;I also tested this with the &quot;whereIn()&quot; method instead of just &quot;where()&quot;.  whereIn works correctly (but isn&apos;t as flexible as where, so I don&apos;t believe it&apos;s an acceptable replacement in all situations).&lt;/p&gt;</comment>
                    <comment id="12519" author="jklehr" created="Tue, 30 Mar 2010 15:12:14 +0000"  >&lt;p&gt;fixing my quoted blocks&lt;/p&gt;</comment>
                    <comment id="12520" author="jklehr" created="Tue, 30 Mar 2010 15:19:28 +0000"  >&lt;p&gt;Updated test case.  I discovered that sqlite DOES throw an exception in the array&apos;s length grows in the second query so added another test to my test case to exhibit this.&lt;/p&gt;</comment>
                    <comment id="13633" author="commi.m" created="Wed, 21 Jul 2010 08:36:15 +0000"  >&lt;p&gt;Hi, this bug just hit me hard, and made a quick fix:&lt;/p&gt;

&lt;p&gt;in the Query/Abstract.php&lt;/p&gt;

&lt;p&gt;the function calculateQueryCacheHash was augmented with the param-count:&lt;/p&gt;

&lt;p&gt;    public function calculateQueryCacheHash($params = array())&lt;/p&gt;
    {
        $dql = $this-&amp;gt;getDql();
        /// quickfox by  Till Seifert
        $hash = md5($dql . &apos;|&apos; . count($this-&amp;gt;getFlattenedParams($params)) . &apos;|&apos; . var_export($this-&amp;gt;_pendingJoinConditions, true) . &apos;DOCTRINE_QUERY_CACHE_SALT&apos;);
        return $hash;
    }



&lt;p&gt;and in protected function _execute($params) the params are passed:&lt;/p&gt;

&lt;p&gt;Line:927&lt;br/&gt;
++                 $hash = $this-&amp;gt;calculateQueryCacheHash($dqlParams);&lt;/p&gt;



&lt;p&gt;cann anyone comment on if this could be horribly wrong? for know this fixes this bug for me.&lt;/p&gt;

&lt;p&gt;[EDIT: posted code as attachment, for better readability)&lt;/p&gt;</comment>
                    <comment id="13634" author="commi.m" created="Wed, 21 Jul 2010 08:39:37 +0000"  >&lt;p&gt;proposed fix. not a patch, sorry.&lt;/p&gt;

&lt;p&gt;it&apos;s also faulty: it runs getFlattenedParams twice, and it fails when you have more than 1 &quot;x IN Array&quot; condition. If the global number or queryparams stays the same, no new cache-entry is created, so you wold have somehow incorporate the individual param-parts-sizes in the cache-hash, not just the number of params.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10528" name="DC600TestCase.php" size="7523" author="jklehr" created="Tue, 30 Mar 2010 15:19:28 +0000" />
                    <attachment id="10702" name="quickfix.txt" size="410" author="commi.m" created="Wed, 21 Jul 2010 08:39:37 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-595] Array hydration fails when sorting DESC</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-595</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Wrong array hydration results.&lt;/p&gt;

&lt;p&gt;Running toArray() on non hydrated collection&lt;br/&gt;
produces different results than using array hydrator.&lt;/p&gt;


&lt;p&gt;Case1. &lt;br/&gt;
Sorting ASC (works)&lt;/p&gt;

&lt;p&gt;$reputationHydrated = Doctrine_Query::create()&lt;br/&gt;
-&amp;gt;from(&apos;User_Model_UserReputation ur&apos;)&lt;br/&gt;
-&amp;gt;leftJoin(&apos;ur.User u&apos;)&lt;br/&gt;
-&amp;gt;leftJoin(&apos;ur.Thread t&apos;)&lt;br/&gt;
-&amp;gt;leftJoin(&apos;t.ForumEntry fe&apos;)&lt;br/&gt;
-&amp;gt;where(&apos;u.id = ?&apos;, 1)&lt;br/&gt;
-&amp;gt;orderBy(&apos;ur.event ASC)&lt;br/&gt;
-&amp;gt;execute(null, Doctrine_Core::HYDRATE_ARRAY);&lt;/p&gt;

&lt;p&gt;$reputation = Doctrine_Query::create()&lt;br/&gt;
-&amp;gt;from(&apos;User_Model_UserReputation ur&apos;)&lt;br/&gt;
-&amp;gt;leftJoin(&apos;ur.User u&apos;)&lt;br/&gt;
-&amp;gt;leftJoin(&apos;ur.Thread t&apos;)&lt;br/&gt;
-&amp;gt;leftJoin(&apos;t.ForumEntry fe&apos;)&lt;br/&gt;
-&amp;gt;where(&apos;u.id = ?&apos;, 1)&lt;br/&gt;
-&amp;gt;orderBy(&apos;ur.event ASC)&lt;br/&gt;
-&amp;gt;execute();&lt;/p&gt;

&lt;p&gt;$reputationToArray = $reputation-&amp;gt;toArray();&lt;/p&gt;

&lt;p&gt;die($reputationToArray === $reputationHydrated); // true, as expected&lt;/p&gt;


&lt;p&gt;Case 2. &lt;br/&gt;
Sorting DESC (does not work)&lt;/p&gt;

&lt;p&gt;$reputationHydrated = Doctrine_Query::create()&lt;br/&gt;
-&amp;gt;from(&apos;User_Model_UserReputation ur&apos;)&lt;br/&gt;
-&amp;gt;leftJoin(&apos;ur.User u&apos;)&lt;br/&gt;
-&amp;gt;leftJoin(&apos;ur.Thread t&apos;)&lt;br/&gt;
-&amp;gt;leftJoin(&apos;t.ForumEntry fe&apos;)&lt;br/&gt;
-&amp;gt;where(&apos;u.id = ?&apos;, 1)&lt;br/&gt;
-&amp;gt;orderBy(&apos;ur.event DESC)&lt;br/&gt;
-&amp;gt;execute(null, Doctrine_Core::HYDRATE_ARRAY);&lt;/p&gt;

&lt;p&gt;$reputation = Doctrine_Query::create()&lt;br/&gt;
-&amp;gt;from(&apos;User_Model_UserReputation ur&apos;)&lt;br/&gt;
-&amp;gt;leftJoin(&apos;ur.User u&apos;)&lt;br/&gt;
-&amp;gt;leftJoin(&apos;ur.Thread t&apos;)&lt;br/&gt;
-&amp;gt;leftJoin(&apos;t.ForumEntry fe&apos;)&lt;br/&gt;
-&amp;gt;where(&apos;u.id = ?&apos;, 1)&lt;br/&gt;
-&amp;gt;orderBy(&apos;ur.event DESC)&lt;br/&gt;
-&amp;gt;execute();&lt;/p&gt;

&lt;p&gt;$reputationToArray = $reputation-&amp;gt;toArray();&lt;/p&gt;

&lt;p&gt;die($reputationToArray === $reputationHydrated); // false, should be true&lt;/p&gt;

&lt;p&gt;Other hydrators do hydrate as expected.&lt;/p&gt;

&lt;p&gt;Seems that something is wrong in Doctrine_Hydrator_Graph.&lt;/p&gt;</description>
                <environment>Windows, Ubuntu, PostgreSQL,</environment>
            <key id="11112">DC-595</key>
            <summary>Array hydration fails when sorting DESC</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="admirau">admirau</reporter>
                        <labels>
                    </labels>
                <created>Tue, 23 Mar 2010 05:12:57 +0000</created>
                <updated>Tue, 23 Mar 2010 06:12:53 +0000</updated>
                                    <version>1.2.1</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="12436" author="admirau" created="Tue, 23 Mar 2010 06:12:53 +0000"  >&lt;p&gt;Changed one condition in Graph.php, and it works.&lt;br/&gt;
Here is a patch:&lt;/p&gt;

&lt;p&gt;&amp;#8212; Doctrine/Hydrator/Graph.php&lt;br/&gt;
+++ Doctrine/Hydrator/Graph-new.php&lt;br/&gt;
@@ -212,7 +212,7 @@&lt;br/&gt;
                         $indexExists = isset($identifierMap&lt;span class=&quot;error&quot;&gt;&amp;#91;$path&amp;#93;&lt;/span&gt;[$id&lt;span class=&quot;error&quot;&gt;&amp;#91;$parent&amp;#93;&lt;/span&gt;][$id&lt;span class=&quot;error&quot;&gt;&amp;#91;$dqlAlias&amp;#93;&lt;/span&gt;]);&lt;br/&gt;
                         $index = $indexExists ? $identifierMap&lt;span class=&quot;error&quot;&gt;&amp;#91;$path&amp;#93;&lt;/span&gt;[$id&lt;span class=&quot;error&quot;&gt;&amp;#91;$parent&amp;#93;&lt;/span&gt;][$id&lt;span class=&quot;error&quot;&gt;&amp;#91;$dqlAlias&amp;#93;&lt;/span&gt;] : false;&lt;br/&gt;
                         $indexIsValid = $index !== false ? isset($prev&lt;span class=&quot;error&quot;&gt;&amp;#91;$parent&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;$relationAlias&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;$index&amp;#93;&lt;/span&gt;) : false;&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;if ( $indexExists || ! $indexIsValid) {&lt;br/&gt;
\ No newline at end of file&lt;br/&gt;
+                        if ( ! $indexExists || ! $indexIsValid) {&lt;br/&gt;
\ No newline at end of file&lt;br/&gt;
                             $element = $this-&amp;gt;getElement($data, $componentName);&lt;br/&gt;
                             $event-&amp;gt;set(&apos;data&apos;, $element);&lt;br/&gt;
                             $listeners&lt;span class=&quot;error&quot;&gt;&amp;#91;$componentName&amp;#93;&lt;/span&gt;-&amp;gt;postHydrate($event);&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Plase check if this does not breaks something else.&lt;br/&gt;
Tests are passing.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-581] ORACLE: Missing fields on subquery with Many:Many</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-581</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;I use this schema:&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;---
Actuality:
  connection:         web
  tableName:          actuality
  actAs:
    softDelete:       ~
    Timestampable:    ~
    Sluggable:
      fields:         [name]
      indexName:      actuality_sluggable
      canUpdate:      &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
  columns:
    id:
      type:           integer(4)
      primary:        &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      unsigned:       &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      sequence:       actuality
    created_at:
      type:           timestamp
    updated_at:
      type:           timestamp
    published_at:
      type:           timestamp
      notnull:        &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    unpublished_at:
      type:           timestamp
    name:
      type:           string(255)
      notnull:        &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    description_short:
      type:           string(1000)
      notnull:        &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    description:
      type:           clob
      notnull:        &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    is_professional:
      type:           &lt;span class=&quot;code-object&quot;&gt;boolean&lt;/span&gt;
      &lt;span class=&quot;code-keyword&quot;&gt;default&lt;/span&gt;:        &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
  relations:
    Categories:
      class: ActualityCategory
      local: actuality_id
      foreign: actuality_category_id
      refClass: ActualityActualityCategory
      foreignAlias: Actualities


ActualityActualityCategory:
  connection:         web
  tableName:          actuality_actuality_category
  options:
    symfony:
      form:   &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;
      filter: &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;
  columns:
    actuality_id:
      type:           integer(4)
      primary:        &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      unsigned:       &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    actuality_category_id:
      type:           integer(2)
      primary:        &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      unsigned:       &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
  relations:
    Actuality:
      onDelete:       CASCADE
    

ActualityCategory:
  connection:         web
  tableName:          actuality_category
  actAs:
    softDelete:       ~
    Timestampable:    ~
    Sluggable:
      fields:         [name]
      indexName:      actualityc_sluggable
      canUpdate:      &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
  columns:
    id:
      type:           integer(2)
      primary:        &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      unsigned:       &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      sequence:       actualitycategory
    created_at:
      type:           timestamp
    updated_at:
      type:           timestamp
    name:
      type:           string(60)
      notnull:        &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Function in my model Actuality&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;&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function retrieveActive($is_authenticated = &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;)
{
  $q = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;createQuery(&apos;a&apos;)
  -&amp;gt;leftJoin(&apos;a.Categories c&apos;)
  -&amp;gt;orderBy(&apos;a.published_at DESC&apos;);
  
  &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (!$is_authenticated)
  {
    $q-&amp;gt;where(&apos;a.is_professional = ?&apos;, &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;);
  }
  
  &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; $q;
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;with that, i receive the message &quot;Doctrine_Connection_Oracle_Exception&quot; because Oracle is strict and in the subselect, the field published_at is missing in select. This is the query generate by doctrine:&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 a.id AS a__id, a.published_at AS a__published_at, a.name AS a__name, a.description_short AS a__description_short, a.slug AS a__slug, a2.id AS a2__id, a2.name AS a2__name FROM actuality a LEFT JOIN actuality_actuality_category a3 ON (a.id = a3.actuality_id) LEFT JOIN actuality_category a2 ON a2.id = a3.actuality_category_id WHERE a.id IN (SELECT a4.id FROM ( SELECT DISTINCT a4.id FROM actuality a4 LEFT JOIN actuality_actuality_category a6 ON (a4.id = a6.actuality_id) LEFT JOIN actuality_category a5 ON a5.id = a6.actuality_category_id WHERE a4.is_professional = 0 ORDER BY a4.published_at DESC ) a4 WHERE ROWNUM &amp;lt;= 5) AND (a.is_professional = 0) ORDER BY a.published_at DESC
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If i execute this query and add the field published_at in subquery, this is work.&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 a.id AS a__id, a.published_at AS a__published_at, a.name AS a__name, a.description_short AS a__description_short, a.slug AS a__slug, a2.id AS a2__id, a2.name AS a2__name FROM actuality a LEFT JOIN actuality_actuality_category a3 ON (a.id = a3.actuality_id) LEFT JOIN actuality_category a2 ON a2.id = a3.actuality_category_id WHERE a.id IN (SELECT a4.id FROM ( SELECT DISTINCT a4.id, a4.published_at  FROM actuality a4 LEFT JOIN actuality_actuality_category a6 ON (a4.id = a6.actuality_id) LEFT JOIN actuality_category a5 ON a5.id = a6.actuality_category_id WHERE a4.is_professional = 0 ORDER BY a4.published_at DESC ) a4 WHERE ROWNUM &amp;lt;= 5) AND (a.is_professional = 0) ORDER BY a.published_at DESC
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Thanks for your help.&lt;/p&gt;</description>
                <environment></environment>
            <key id="11077">DC-581</key>
            <summary>ORACLE: Missing fields on subquery with Many:Many</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="garfield-fr">Bertrand Zuchuat</reporter>
                        <labels>
                    </labels>
                <created>Thu, 18 Mar 2010 03:59:20 +0000</created>
                <updated>Thu, 18 Mar 2010 06:09:27 +0000</updated>
                                    <version>1.2.1</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="12318" author="garfield-fr" created="Thu, 18 Mar 2010 05:10:06 +0000"  >&lt;p&gt;I specify another thing. I use this with a pager.&lt;/p&gt;</comment>
                    <comment id="12321" author="garfield-fr" created="Thu, 18 Mar 2010 06:09:27 +0000"  >&lt;p&gt;I create this testcase to find the bug but with that, the test is OK.&lt;/p&gt;

&lt;p&gt;I execute the same code with symfony/doctrine but the query isn&apos;t the same. Why ????&lt;/p&gt;

&lt;p&gt;Extract from symfony exception (Doctrine_Connection-&amp;gt;execute)&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
a.id AS a__id, a.published_at AS a__published_at, a.name AS a__name, a.description_short AS a__description_short,
a.slug AS a__slug, a2.id AS a2__id, a2.name AS a2__name
FROM actuality a
LEFT JOIN actuality_actuality_category a3 ON (a.id = a3.actuality_id)
LEFT JOIN actuality_category a2 ON a2.id = a3.actuality_category_id WHERE a.id
IN (SELECT a4.id FROM ( SELECT DISTINCT a4.id FROM actuality a4 LEFT JOIN actuality_actuality_category a6 ON (a4.id = a6.actuality_id)
LEFT JOIN actuality_category a5 ON a5.id = a6.actuality_category_id
WHERE a4.is_professional = ? ORDER BY a4.published_at DESC ) a4 WHERE ROWNUM &amp;lt;= 5) AND (a.is_professional = ?) ORDER BY a.published_at DESC
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10490" name="DC581TestCase.php" size="6859" author="garfield-fr" created="Thu, 18 Mar 2010 06:06:40 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-575] Select distinct  limit problem</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-575</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;1)Code&lt;br/&gt;
Doctrine_Query::create ()&lt;br/&gt;
-&amp;gt;select ( &quot;u.user_id,mr.message_id,mr.message_senddate,mr.message_title,mr.message_content,mr.message_alias,mr.message_categoryid,&quot; )&lt;br/&gt;
-&amp;gt;from ( &quot;user u&quot; )&lt;br/&gt;
-&amp;gt;leftJoin ( &quot;u.messages mr ON u.user_id = mr.message_sender&quot; )&lt;br/&gt;
-&amp;gt;where ( &quot;u.user_id = ?&quot;, 2 )  &lt;br/&gt;
-&amp;gt;limit(1)&lt;br/&gt;
-&amp;gt;fetchArray ();&lt;/p&gt;

&lt;p&gt;This code must return only one result but it returns all results in which user_id is 2 in the database&lt;/p&gt;

&lt;p&gt;If i looked it in Symfony Debug bar, i saw that;&lt;/p&gt;

&lt;p&gt;2)Symfony debug toolbar values: &lt;/p&gt;

&lt;p&gt;#Query A&lt;br/&gt;
SELECT DISTINCT u2.user_id FROM users u2 LEFT JOIN messages m2 ON (u2.user_id = m2.message_sender) WHERE u2.user_id = 2 LIMIT 1&lt;/p&gt;

&lt;p&gt;#Query B &lt;br/&gt;
SELECT u.user_id AS u_user_id, m.message_id AS mmessage_id, m.message_senddate AS mmessage_senddate, m.message_title AS mmessage_title, m.message_content AS mmessage_content, m.message_alias AS mmessage_alias, m.message_categoryid AS m_message_categoryid FROM users u LEFT JOIN messages m ON (u.user_id = m.message_sender) WHERE u.user_id IN (&apos;2&apos;) AND (u.user_id = 2)&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;And if i test this code in MYSQL query browser i got a result like that;&lt;/p&gt;

&lt;p&gt;SELECT u.user_id AS u_user_id, m.message_id AS mmessage_id, m.message_senddate AS mmessage_senddate, m.message_title AS mmessage_title, m.message_content AS mmessage_content, m.message_alias AS mmessage_alias, m.message_categoryid AS m_message_categoryid&lt;br/&gt;
FROM users u&lt;br/&gt;
LEFT JOIN messages m ON ( u.user_id = m.message_sender )&lt;br/&gt;
WHERE u.user_id&lt;br/&gt;
IN (&lt;br/&gt;
&apos;2&apos;&lt;br/&gt;
)&lt;br/&gt;
AND (&lt;br/&gt;
u.user_id =2&lt;br/&gt;
)&lt;br/&gt;
LIMIT 0 , 30&lt;/p&gt;

&lt;p&gt;If i changed SQL code like below and put the limit at end, the problem solved:&lt;/p&gt;

&lt;p&gt;#Query A&lt;br/&gt;
SELECT DISTINCT u2.user_id FROM users u2 LEFT JOIN messages m2 ON (u2.user_id = m2.message_sender) WHERE u2.user_id = 2&lt;/p&gt;

&lt;p&gt;#Query B&lt;br/&gt;
SELECT u.user_id AS u_user_id, m.message_id AS mmessage_id, m.message_senddate AS mmessage_senddate, m.message_title AS mmessage_title, m.message_content AS mmessage_content, m.message_alias AS mmessage_alias, m.message_categoryid AS m_message_categoryid FROM users u LEFT JOIN messages m ON (u.user_id = m.message_sender) WHERE u.user_id IN (&apos;2&apos;) AND (u.user_id = 2)   LIMIT 1&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;But doctrine&apos;s   limit(1)  metod is Select Distinct &lt;/p&gt;

&lt;p&gt;The query  which starts with ... is at query A but it needs to be at the end of query B&lt;/p&gt;</description>
                <environment>php 5.3.0, mysql 5.1.36, symfony 1.4.3</environment>
            <key id="11061">DC-575</key>
            <summary>Select distinct  limit problem</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="feykintosh">O.</reporter>
                        <labels>
                    </labels>
                <created>Tue, 16 Mar 2010 05:19:42 +0000</created>
                <updated>Wed, 30 Jun 2010 02:57:45 +0000</updated>
                                    <version>1.2.1</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="12272" author="feykintosh" created="Tue, 16 Mar 2010 05:34:16 +0000"  >&lt;p&gt;My schema file.&lt;/p&gt;</comment>
                    <comment id="12295" author="jwage" created="Tue, 16 Mar 2010 15:20:40 +0000"  >&lt;p&gt;It is hard to understand your issue description. Can you make a clear failing Doctrine test case for us to look at? Thanks, Jon&lt;/p&gt;</comment>
                    <comment id="12301" author="feykintosh" created="Wed, 17 Mar 2010 03:57:44 +0000"  >&lt;p&gt;Adding problem screencast: &lt;br/&gt;
&lt;a href=&quot;http://www.screencast-o-matic.com/watch/c6ebiN1qS&quot; class=&quot;external-link&quot;&gt;http://www.screencast-o-matic.com/watch/c6ebiN1qS&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="12302" author="feykintosh" created="Wed, 17 Mar 2010 04:18:39 +0000"  >&lt;p&gt;I found the source of the problem:&lt;br/&gt;
lib\vendor\doctrine\Doctrine\Query.php   in getSqlQuery()  function.&lt;/p&gt;

&lt;p&gt;$limitSubquery  values are default TRUE, but FALSE have to be here.. (to me)&lt;br/&gt;
How can we define the value of the DQL $limitSubquery?&lt;/p&gt;</comment>
                    <comment id="13462" author="willf1976" created="Wed, 30 Jun 2010 02:57:45 +0000"  >&lt;p&gt;Hi O&lt;/p&gt;

&lt;p&gt;I made a patch which will allow you to turn off the limit subquery. If you would like to check it out here is the bug it is posted on:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-701&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/jira/browse/DC-701&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope that helps.&lt;/p&gt;

&lt;p&gt;Will&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10478" name="schema.yml" size="1026" author="feykintosh" created="Tue, 16 Mar 2010 05:34:16 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-554] Distinct query does not work</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-554</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt; $limit = 10;&lt;br/&gt;
 $q = &apos;Me&apos;;&lt;br/&gt;
 $field = &apos;contractor&apos;;&lt;/p&gt;

&lt;p&gt; $q = Doctrine_Query::create()&lt;br/&gt;
          -&amp;gt;select(sprintf(&apos;DISTINCT PublicContract.%s&apos;, $field))&lt;br/&gt;
          -&amp;gt;from(&apos;PublicContract&apos;)&lt;br/&gt;
          -&amp;gt;where(sprintf(&apos;PublicContract.%s LIKE ?&apos;, $field), sprintf(&apos;%%%s%%&apos;, $q))&lt;br/&gt;
          -&amp;gt;limit($limit);&lt;/p&gt;

&lt;p&gt;The QUERY is WRONG:&lt;/p&gt;

&lt;p&gt;// SELECT DISTINCT p.id AS p_&lt;em&gt;id, p.contractor AS p&lt;/em&gt;_contractor FROM public_contract p WHERE (p.contractor LIKE ?) LIMIT 10 - (%Me%)&lt;/p&gt;

&lt;p&gt;I can simply GROUP BY the contractor field, because DISTINCT can be considered as a special case of GROUP BY - and have the results I want:&lt;/p&gt;

&lt;p&gt; $q = Doctrine_Query::create()&lt;br/&gt;
          -&amp;gt;select(sprintf(&apos;PublicContract.%s&apos;, $field))&lt;br/&gt;
          -&amp;gt;from(&apos;PublicContract&apos;)&lt;br/&gt;
          -&amp;gt;where(sprintf(&apos;PublicContract.%s LIKE ?&apos;, $field), sprintf(&apos;%%%s%%&apos;, $q))&lt;br/&gt;
         -&amp;gt;groupBy(sprintf(&apos;PublicContract.%s&apos;, $field))&lt;br/&gt;
          -&amp;gt;limit($limit);&lt;/p&gt;</description>
                <environment></environment>
            <key id="11009">DC-554</key>
            <summary>Distinct query does not work</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="mishal">Mishal</reporter>
                        <labels>
                    </labels>
                <created>Tue, 9 Mar 2010 03:50:36 +0000</created>
                <updated>Mon, 15 Mar 2010 16:11:04 +0000</updated>
                                    <version>1.2.1</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="12229" author="jwage" created="Mon, 15 Mar 2010 16:11:04 +0000"  >&lt;p&gt;Test case or patch?&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-544] Doctrine_Pager bug with Oracle. getNumResults doesn&apos;t return the correct number of records</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-544</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;The function getNumResults() doesn&apos;t work correctly.&lt;/p&gt;

&lt;p&gt;This is my model class&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 ReviewListTable &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Table
{
 &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function getAvailable()
 {
   &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;createQuery()
   -&amp;gt;select(&apos;DISTINCT(to_char(file_date, \&apos;YYYY-MM-DD\&apos;)) fdate&apos;)
   -&amp;gt;orderBy(&apos;fdate DESC&apos;);
 }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If i execute this fonction, the number of record is 31. If i use the Pager, the result is 5744 records&lt;/p&gt;

&lt;p&gt;Controler:&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;$&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;pager = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Doctrine_Pager(
                           Doctrine_Core::getTable(&apos;ReviewList&apos;)-&amp;gt;getAvailable(),
                           $request-&amp;gt;getParameter(&apos;page&apos;, 1),
                           20);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;


&lt;p&gt;View:&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;$rs = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;pager-&amp;gt;execute();
echo $pager-&amp;gt;getNumResults();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment></environment>
            <key id="10993">DC-544</key>
            <summary>Doctrine_Pager bug with Oracle. getNumResults doesn&apos;t return the correct number of records</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="garfield-fr">Bertrand Zuchuat</reporter>
                        <labels>
                    </labels>
                <created>Thu, 4 Mar 2010 04:29:53 +0000</created>
                <updated>Thu, 18 Mar 2010 08:02:39 +0000</updated>
                                    <version>1.2.1</version>
                                                <component>Pager</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="12235" author="jwage" created="Mon, 15 Mar 2010 16:20:49 +0000"  >&lt;p&gt;Hmm. I don&apos;t quite understand. Can you make a test case?&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10492" name="DC544TestCase.php" size="4092" author="garfield-fr" created="Thu, 18 Mar 2010 08:02:39 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-499] Doctrine_Query_Set incorrectly rewrites expressions</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-499</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;First up Doctrine_Query_Set should extend Doctrine_Query_Condition so that the parseLiteralValue method is available in _processPossibleAggExpression().&lt;/p&gt;

&lt;p&gt;However I am not sure what this method is really supposed to do. It seems to do some reordering of clauses, but in my case it actually drops off some parts of my expression:&lt;br/&gt;
            Doctrine_Query::create()&lt;br/&gt;
                -&amp;gt;update(&apos;Document&apos;)&lt;br/&gt;
                -&amp;gt;set(&apos;clause_ordering&apos;, &quot;IF(clause_ordering IS NULL, &apos;$id&apos;, CONCAT(clause_ordering, &apos;,$id&apos;))&quot;)&lt;br/&gt;
                -&amp;gt;where(&apos;id = ?&apos;, $document_id)&lt;br/&gt;
                -&amp;gt;execute();&lt;/p&gt;

&lt;p&gt;Results in &quot;UPDATE document SET clause_ordering = IF(clause_ordering IS NULL, &apos;67&apos;, CONCAT(clause_ordering)) WHERE (id = ?)&quot;&lt;/p&gt;

&lt;p&gt;And not as expected &quot;UPDATE document SET clause_ordering = IF(clause_ordering IS NULL, &apos;67&apos;, CONCAT(clause_ordering, &apos;,67&apos;)) WHERE (id = ?)&quot;&lt;/p&gt;

&lt;p&gt;Adding a space after IF and CONCAT fixes the issue, but is obviously a hack to get around the regexp in _processPossibleAggExpression()&lt;/p&gt;</description>
                <environment></environment>
            <key id="10890">DC-499</key>
            <summary>Doctrine_Query_Set incorrectly rewrites expressions</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="lsmith">Lukas Kahwe</reporter>
                        <labels>
                    </labels>
                <created>Sun, 14 Feb 2010 11:27:55 +0000</created>
                <updated>Fri, 4 Feb 2011 13:38:04 +0000</updated>
                                    <version>1.2.1</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="13371" author="raphox" created="Sat, 19 Jun 2010 15:23:57 +0000"  >&lt;p&gt;Guilherme,&lt;br/&gt;
Como eu sei que voc&#234; fala portuguese e I dont speek english, vou falar em portugu&#234;s mesmo. Qualquer coisa voc&#234; traduz.&lt;/p&gt;

&lt;p&gt;Implementei uma solu&#231;&#227;o meio nebulosa aqui: &lt;a href=&quot;http://pastie.org/1011675&quot; class=&quot;external-link&quot;&gt;http://pastie.org/1011675&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;O que esta pegando &#233; a express&#227;o regular. Ela n&#227;o esta aceitando muito bem quando existe na &quot;$hasAggExpression&quot; argumentos separados por v&#237;rgula.&lt;br/&gt;
O meu teste foi um pouco diferente do que o criado pelo Lukas. Veja:&lt;/p&gt;

&lt;p&gt;-&amp;gt;set(&apos;p.tempo_atual&apos;, &apos;IFNULL(p.tempo_atual, p.lance_tempo) - 1&apos;)&lt;/p&gt;

&lt;p&gt;Na implementa&#231;&#227;o atual ele descarto o segundo argumento do IFNULL(). N&#227;o tenho certeza se minha proposta de implementa&#231;&#227;o &#233; correta. n&#227;o entendi muito bem o funcionamento do preg_match_all. Ao meu ver ele sempre retornaria apenas a posicao 0, mas foi uitlizado um foreach, n&#227;o entendi o pq. Ent&#227;o como esta com foreach eu deixei e coloquei uma &apos;glue&apos; vari&#225;vel para o implode no final.&lt;/p&gt;</comment>
                    <comment id="15229" author="overond" created="Fri, 4 Feb 2011 13:38:04 +0000"  >&lt;p&gt;Tem como ignorar esta verifica&#231;&#227;o? Pq o que esta acontecendo e que se eu digitar numa frase, exemplo, &quot; teste( 89,0%), &quot;  o doctrine pensa que &#233; uma express&#227;o, como evitar isto?&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-828] MSSQL - ORDER BY on text columns throws mssql error 306 [+patch]</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-828</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;ul&gt;
	&lt;li&gt;Table: foo (id:integer, title:text)&lt;/li&gt;
	&lt;li&gt;Created Query: SELECT &lt;span class=&quot;error&quot;&gt;&amp;#91;id&amp;#93;&lt;/span&gt;, &lt;span class=&quot;error&quot;&gt;&amp;#91;title&amp;#93;&lt;/span&gt; FROM &lt;span class=&quot;error&quot;&gt;&amp;#91;foo&amp;#93;&lt;/span&gt; ORDER BY &lt;span class=&quot;error&quot;&gt;&amp;#91;title&amp;#93;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Throws:&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;Server: Msg 306, Level 16, State 2, Line 1
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE &lt;span class=&quot;code-keyword&quot;&gt;operator&lt;/span&gt;.
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Solution:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Created Query: SELECT &lt;span class=&quot;error&quot;&gt;&amp;#91;id&amp;#93;&lt;/span&gt;, &lt;span class=&quot;error&quot;&gt;&amp;#91;title&amp;#93;&lt;/span&gt; FROM &lt;span class=&quot;error&quot;&gt;&amp;#91;foo&amp;#93;&lt;/span&gt; ORDER BY CAST(&lt;span class=&quot;error&quot;&gt;&amp;#91;title&amp;#93;&lt;/span&gt; AS VARCHAR(8000))&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;References:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/aa276838(v=SQL.80).aspx&quot; class=&quot;external-link&quot;&gt;http://msdn.microsoft.com/en-us/library/aa276838(v=SQL.80).aspx&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/cc645611.aspx&quot; class=&quot;external-link&quot;&gt;http://msdn.microsoft.com/en-us/library/cc645611.aspx&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Patch will be supplied soon ...&lt;/p&gt;</description>
                <environment></environment>
            <key id="11774">DC-828</key>
            <summary>MSSQL - ORDER BY on text columns throws mssql error 306 [+patch]</summary>
                <type id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/improvement.png">Improvement</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="enrico">Enrico Stahn</reporter>
                        <labels>
                    </labels>
                <created>Mon, 16 Aug 2010 07:36:30 +0000</created>
                <updated>Thu, 2 Sep 2010 08:02:33 +0000</updated>
                                    <version>1.2.2</version>
                                <fixVersion>1.2.4</fixVersion>
                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="14021" author="enrico" created="Fri, 20 Aug 2010 14:44:03 +0000"  >&lt;p&gt;&lt;a href=&quot;http://github.com/estahn/doctrine1/compare/DC-828&quot; class=&quot;external-link&quot;&gt;http://github.com/estahn/doctrine1/compare/DC-828&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://github.com/estahn/doctrine1/tree/DC-828&quot; class=&quot;external-link&quot;&gt;http://github.com/estahn/doctrine1/tree/DC-828&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I guess we need more TestCases for the SubQuery stuff.&lt;/p&gt;</comment>
                    <comment id="14234" author="enrico" created="Thu, 2 Sep 2010 08:02:33 +0000"  >&lt;p&gt;I made a mistake with github, the updated branch can be found at&lt;br/&gt;
&lt;a href=&quot;http://github.com/estahn/doctrine1/tree/DC-828-2&quot; class=&quot;external-link&quot;&gt;http://github.com/estahn/doctrine1/tree/DC-828-2&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-809] Doctrine_Query_Abstract::set() Does not handle boolean values correctly.</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-809</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When passing booleans to the set() function on an update DQL query object, the value false is not handled correctly and end up in a corrupted query.&lt;/p&gt;

&lt;p&gt;Test schema:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;schema.yml&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;Test:
  columns:
    bool:
      type: &lt;span class=&quot;code-object&quot;&gt;boolean&lt;/span&gt;
      &lt;span class=&quot;code-keyword&quot;&gt;default&lt;/span&gt;: &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;
      notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Steps to reproduce:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;code.php&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;Doctrine_Query::create()-&amp;gt;update(&apos;Test&apos;)
                        -&amp;gt;set(&apos;bool&apos;, &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;)
                        -&amp;gt;execute()
                        -&amp;gt;getSqlQuery();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Result Query:&lt;br/&gt;
&lt;em&gt;&apos;UPDATE test SET bool = &apos;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Expected Query:&lt;br/&gt;
&lt;em&gt;&apos;UPDATE test SET bool = false&apos;&lt;/em&gt;&lt;/p&gt;


&lt;p&gt;See attached patch file for a &lt;b&gt;possible&lt;/b&gt; solution. (I don&apos;t have deep know of Doctrine internals...)&lt;/p&gt;</description>
                <environment></environment>
            <key id="11727">DC-809</key>
            <summary>Doctrine_Query_Abstract::set() Does not handle boolean values correctly.</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="mars105">Alexandre Ravey</reporter>
                        <labels>
                    </labels>
                <created>Thu, 5 Aug 2010 08:18:42 +0000</created>
                <updated>Thu, 5 Aug 2010 08:18:42 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                                <attachments>
                    <attachment id="10721" name="Abstract.patch" size="437" author="mars105" created="Thu, 5 Aug 2010 08:18:42 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-799] Doctrine_Query::parseFunctionExpression() produces unexpected results if the expression contains a function</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-799</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When &lt;em&gt;Doctrine_Query::parseFunctionExpression()&lt;/em&gt; is called with the following parameter and &lt;em&gt;$this-&amp;gt;_conn-&amp;gt;expression&lt;/em&gt; is of type &lt;em&gt;Doctrine_Expression_MySql&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;$expr = &quot;DATE_FORMAT(datefield,&apos;%Y-%m-%d&apos;),someotherfield&quot;&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;The expected result from Doctrine_Query::parseFunctionExpressoin() would be&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;DATE_FORMAT(l.datefield,&apos;%Y-%m-%d&apos;),l.someotherfield&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;However, the actual result is&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;DATE_FORMAT(l.datefield,&apos;%Y-%m-%d&apos;),someotherfiel&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;Note the missing leading &quot;l.&quot; and the last character (&quot;d&quot;) on &quot;someotherfield&quot;.&lt;br/&gt;
Obviously this leads to fatal errors.&lt;/p&gt;

&lt;p&gt;This example is a result of calling addGroupby(&quot;DATE_FORMAT(datefield,&apos;%Y-%m-%d&apos;),someotherfield&quot;) on a Doctrine_Query object.&lt;/p&gt;</description>
                <environment>Mac OS X, LINUX</environment>
            <key id="11686">DC-799</key>
            <summary>Doctrine_Query::parseFunctionExpression() produces unexpected results if the expression contains a function</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="hglattergotz">Henning Glatter-Gotz</reporter>
                        <labels>
                    </labels>
                <created>Tue, 27 Jul 2010 16:42:17 +0000</created>
                <updated>Tue, 27 Jul 2010 16:42:17 +0000</updated>
                                    <version>1.2.2</version>
                                <fixVersion>1.2.2</fixVersion>
                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-792] Doctrine query with the Oracle SOUNDEX function</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-792</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Hi all,&lt;br/&gt;
We create a doctrine query with the Oracle SOUNDEX function.&lt;br/&gt;
The Dql generated work fine when we run it on Oracle&lt;br/&gt;
 on the development envirenment an error is thrown  (Unknown function soundex)&lt;br/&gt;
this is the Dql generated:&lt;br/&gt;
SELECT * FROM ACTOR A WHERE A.bocompanyid = 32 AND soundex(actor_fname || &apos; &apos; || actor_name) = soundex(&apos;EEEE&apos;)&lt;/p&gt;

&lt;p&gt;related to :&lt;br/&gt;
$q = $this-&amp;gt;createQuery(&apos;A&apos;)-&amp;gt;select(&apos;*&apos;)&lt;br/&gt;
-&amp;gt;where(&apos;A.bocompanyid = ?&apos;, $companyId)&lt;br/&gt;
-&amp;gt;andWhere(&quot;soundex(actor_fname || &apos; &apos; || actor_name) = soundex (&apos;&quot; .$actorName.&quot;&apos;)&quot;);&lt;/p&gt;</description>
                <environment>Ubuntu, oracle 11g, symfony 1.4.3</environment>
            <key id="11634">DC-792</key>
            <summary>Doctrine query with the Oracle SOUNDEX function</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="ghaliano">Ahmed GHALI</reporter>
                        <labels>
                    </labels>
                <created>Fri, 16 Jul 2010 10:52:57 +0000</created>
                <updated>Fri, 16 Jul 2010 10:52:57 +0000</updated>
                                                                    <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-787] Join &amp; On override</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-787</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Users &amp;amp; Books are linked by CompoUsersBooks. So, It&apos;s a m:m relationship.&lt;/p&gt;

&lt;p&gt;Here, a crazy DQL query to fetch users &amp;amp; specifics books.&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;code&amp;#93;&lt;/span&gt;&lt;br/&gt;
$query	= Doctrine_Query::create ()&lt;br/&gt;
	-&amp;gt;select (&quot;users.&lt;b&gt;, books.&lt;/b&gt;&quot;)&lt;br/&gt;
	-&amp;gt;from (&quot;Users users&quot;)&lt;br/&gt;
	-&amp;gt;leftJoin (&quot;users.alternateBooks alternateBooks&quot;)&lt;br/&gt;
	-&amp;gt;leftJoin (&quot;users.books books ON books.id_book = alternateBooks.id_book&quot;);&lt;br/&gt;
&lt;span class=&quot;error&quot;&gt;&amp;#91;/code&amp;#93;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;The SQL query&lt;br/&gt;
&lt;span class=&quot;error&quot;&gt;&amp;#91;code&amp;#93;&lt;/span&gt;&lt;br/&gt;
SELECT `s`.`id_show`            AS `s__id_show`&lt;br/&gt;
FROM   `users` `u`&lt;br/&gt;
       LEFT JOIN `compo_users_books` `c1`&lt;br/&gt;
         ON ( `u`.`id_user` = `c2`.`id_user` )&lt;br/&gt;
       LEFT JOIN `books` `b1`&lt;br/&gt;
         ON `c1`.`id_book` = `b1`.`id_book`&lt;br/&gt;
       LEFT JOIN `compo_users_books` `c2`&lt;br/&gt;
         ON `u`.`id_user` = `c2`.`id_user`&lt;br/&gt;
       LEFT JOIN `books` `b2`&lt;br/&gt;
         ON `b1`.`id_book` = `b2`.`id_book`&lt;br/&gt;
&lt;span class=&quot;error&quot;&gt;&amp;#91;/code&amp;#93;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;As you can see, &lt;br/&gt;
The SQL query is correctly build.&lt;br/&gt;
But, this SQL Query isn&apos;t optimized at all.&lt;br/&gt;
Because the following part of code isn&apos;t use :&lt;br/&gt;
&lt;span class=&quot;error&quot;&gt;&amp;#91;code&amp;#93;&lt;/span&gt;&lt;br/&gt;
       LEFT JOIN `compo_users_books` `c2`&lt;br/&gt;
         ON `u`.`id_user` = `c2`.`id_user`&lt;br/&gt;
&lt;span class=&quot;error&quot;&gt;&amp;#91;/code&amp;#93;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;And also, the left join is a cartesian product ! The number of row return is really big for nothing...&lt;/p&gt;

&lt;p&gt;That really sux because It&apos;s performance killer.&lt;/p&gt;</description>
                <environment></environment>
            <key id="11627">DC-787</key>
            <summary>Join &amp; On override</summary>
                <type id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/improvement.png">Improvement</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="armetiz">Thomas Tourlourat - Armetiz</reporter>
                        <labels>
                    </labels>
                <created>Thu, 15 Jul 2010 10:12:46 +0000</created>
                <updated>Thu, 15 Jul 2010 10:12:46 +0000</updated>
                                                                    <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-766] preQuery() and getConnection() - multiple connections</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-766</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When preQuery() hook is invoked, any calls to $this-&amp;gt;getConnection() in preQuery() body  is useless because it always returns the current connection instead of the connection bound with component that is being queried.&lt;/p&gt;

&lt;p&gt;I am using this hook to switch the connection to connection to master host for schema of the queried component , but cannot do this because the is no way to obtain information about which component this query uses and what would be bounded connection.&lt;br/&gt;
The connection is propely set by Doctrine but after the preQuery() hook is invoked, but when this finally happens i have no control over the execution of the query.&lt;/p&gt;</description>
                <environment></environment>
            <key id="11553">DC-766</key>
            <summary>preQuery() and getConnection() - multiple connections</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="maciek">Maciej Mazur</reporter>
                        <labels>
                    </labels>
                <created>Fri, 25 Jun 2010 05:04:47 +0000</created>
                <updated>Fri, 25 Jun 2010 05:04:47 +0000</updated>
                                    <version>1.2.0</version>
                <version>1.2.1</version>
                <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-759] MSSQL Server / ODBC: Cannot order by a column aggregate when a limit subquery is required.</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-759</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;It&apos;s not possible to use a column aggregate function and a limit subquery together with SQL Server; the logic that constructs the limit subquery is flawed, not recognising the presence of a function and assuming it to be a column. The resulting error occurs:&lt;/p&gt;

&lt;p&gt;SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;42S22&amp;#93;&lt;/span&gt;: Column not found: 207 &lt;span class=&quot;error&quot;&gt;&amp;#91;Microsoft&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;SQL Server Native Client 10.0&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;SQL Server&amp;#93;&lt;/span&gt;Invalid column name ...&lt;/p&gt;

&lt;p&gt;This can be observed when running the random sorting example from the manual against SQL Server through ODBC:&lt;br/&gt;
&lt;a href=&quot;http://www.doctrine-project.org/documentation/manual/1_2/hu/dql-doctrine-query-language:order-by-clause:using-random-order&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/documentation/manual/1_2/hu/dql-doctrine-query-language:order-by-clause:using-random-order&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In addition to the syntax error, it seems SQL Server requires that all aggregate functions that appear in the order by section of the query are declared (i.e. aliased) in the select section which is not currently happening.&lt;/p&gt;

&lt;p&gt;I also noticed what I &lt;b&gt;think&lt;/b&gt; is a bug in the ordering of results within the sub-select on line 214 of Doctrine_Connection_Mssql:&lt;br/&gt;
$query .= (stripos($sorts&lt;span class=&quot;error&quot;&gt;&amp;#91;$i&amp;#93;&lt;/span&gt;, &apos;asc&apos;) !== false) ? &apos;DESC&apos; : &apos;ASC&apos;;&lt;/p&gt;

&lt;p&gt;which appears to be sorting in the opposite order as to what was intended.&lt;/p&gt;

&lt;p&gt;I&apos;ve a fix and a test case which attempts to address these issues. I noticed two other open issues surrounding this section of code (#586 and #744)  - if this patch is accepted I think these issues will also be resolved.&lt;/p&gt;</description>
                <environment>Windows XP&lt;br/&gt;
Apache 2.2&lt;br/&gt;
PHP 5.3.2</environment>
            <key id="11538">DC-759</key>
            <summary>MSSQL Server / ODBC: Cannot order by a column aggregate when a limit subquery is required.</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="craigmarvelley">Craig Marvelley</reporter>
                        <labels>
                    </labels>
                <created>Tue, 22 Jun 2010 12:36:25 +0000</created>
                <updated>Tue, 22 Jun 2010 12:43:27 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="13400" author="craigmarvelley" created="Tue, 22 Jun 2010 12:41:22 +0000"  >&lt;p&gt;Uploaded patch and test case.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10676" name="DC759TestCase.php" size="2430" author="craigmarvelley" created="Tue, 22 Jun 2010 12:43:27 +0000" />
                    <attachment id="10674" name="doctrine_aggregate_function_order_patch.patch" size="2515" author="craigmarvelley" created="Tue, 22 Jun 2010 12:41:22 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-760] MSSQL Server: Support for RAND() in Doctrine_Expression_MSSQL</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-760</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Doctrine_Expression_MSSQL doesn&apos;t provide a method for handling SQL Server&apos;s RAND() method. I&apos;ve attached a patch to support it.&lt;/p&gt;</description>
                <environment>Windows XP&lt;br/&gt;
PHP 5.3.2</environment>
            <key id="11541">DC-760</key>
            <summary>MSSQL Server: Support for RAND() in Doctrine_Expression_MSSQL</summary>
                <type id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/improvement.png">Improvement</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="craigmarvelley">Craig Marvelley</reporter>
                        <labels>
                    </labels>
                <created>Thu, 24 Jun 2010 05:40:34 +0000</created>
                <updated>Thu, 24 Jun 2010 05:40:34 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                    <attachment id="10677" name="doctrine_expression_mssql_rand.patch" size="485" author="craigmarvelley" created="Thu, 24 Jun 2010 05:40:34 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-757] In SQL query, field name is not replaced with real column name in right part of join condition</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-757</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Hi,&lt;br/&gt;
I&apos;m blocked on a bad issue &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/sad.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;

&lt;p&gt;I have a schema that uses fields aliases:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;schema.yml&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-none&quot;&gt;User:

Phonenumber:
  columns:
    theuser:
      name: colprefix_user_id as user_id   #note the column alias
      type: integer
    thenumber:
      name: colprefix_number as number
      type: string(20)
  relations:
    User:
      local: user_id
      foreign: id
      foreignAlias: Phonenumbers
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now if I make the following 2 DQL queries, the first &quot;plain&quot; and the second with redefining the ON clause, then print 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;$q1 = Doctrine_Query::create()
    -&amp;gt;from(&apos;User u&apos;)
    -&amp;gt;innerJoin(&apos;u.Phonenumbers p&apos;);

$q2 = Doctrine_Query::create()
    -&amp;gt;from(&apos;User u&apos;)
    -&amp;gt;innerJoin(&apos;u.Phonenumbers p ON u.id = p.user_id&apos;);

echo $q1-&amp;gt;getSqlQuery() . &lt;span class=&quot;code-quote&quot;&gt;&quot;\n&quot;&lt;/span&gt;;
echo $q2-&amp;gt;getSqlQuery() . &lt;span class=&quot;code-quote&quot;&gt;&quot;\n&quot;&lt;/span&gt;;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;I get (lines formatted a little):&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;SELECT u.id AS u__id, p.id AS p__id, p.colprefix_user_id AS p__colprefix_user_id, p.colprefix_number AS p__colprefix_number
        FROM user u INNER JOIN phonenumber p ON u.id = p.colprefix_user_id

SELECT u.id AS u__id, p.id AS p__id, p.colprefix_user_id AS p__colprefix_user_id, p.colprefix_number AS p__colprefix_number
        FROM user u INNER JOIN phonenumber p ON (u.id = p.user_id)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Note how, on the right end, p.user_id is &lt;b&gt;not&lt;/b&gt; replaced with p.colprefix_user_id in the 2nd query!&lt;br/&gt;
If I try to execute $q2 I get&lt;/p&gt;
&lt;div class=&quot;panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;panelContent&quot;&gt;
&lt;p&gt;Fatal error:  Uncaught exception &apos;Doctrine_Connection_Mysql_Exception&apos; with message &apos;SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;42S22&amp;#93;&lt;/span&gt;: Column not found: 1054 Unknown column &apos;p.user_id&apos; in &apos;on clause&apos;&apos; in /&lt;span class=&quot;error&quot;&gt;&amp;#91;...&amp;#93;&lt;/span&gt;/doctrine_test/lib/vendor/doctrine/Doctrine/Connection.php:1082&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This only happens for the &lt;em&gt;right&lt;/em&gt; member of the join condition. If i swap the fields 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;$q3 = Doctrine_Query::create()
    -&amp;gt;from(&apos;User u&apos;)
    -&amp;gt;innerJoin(&apos;u.Phonenumbers p ON p.user_id = u.id&apos;); &lt;span class=&quot;code-comment&quot;&gt;//swapped
&lt;/span&gt;
echo $q3-&amp;gt;getSqlQuery() . &lt;span class=&quot;code-quote&quot;&gt;&quot;\n&quot;&lt;/span&gt;;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;then we can see that the &lt;em&gt;left&lt;/em&gt; member is replaced well:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;SELECT u.id AS u__id, p.id AS p__id, p.colprefix_user_id AS p__colprefix_user_id, p.colprefix_number AS p__colprefix_number
        FROM user u INNER JOIN phonenumber p ON (p.colprefix_user_id = u.id)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;(This is only an example, there&apos;s no point redefining the ON clause here, but the same is occurring in the project I work on, in a WITH clause).&lt;/p&gt;

&lt;p&gt;I think the problem is in &lt;em&gt;Doctrine_Query_JoinCondition::load()&lt;/em&gt;, in which&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;the &lt;b&gt;left&lt;/b&gt; member of condition is directly parsed in a call to &lt;tt&gt;Doctrine_Query::parseClause()&lt;/tt&gt;;&lt;/li&gt;
	&lt;li&gt;whereas the &lt;b&gt;right&lt;/b&gt; member is checked if it&apos;s a subquery, and if not, is transformed into the result of &lt;tt&gt;Doctrine_Expression::getSql()&lt;/tt&gt; then passed to &lt;tt&gt;Doctrine_Query_JoinCondition::parseLiteralValue()&lt;/tt&gt; or &lt;tt&gt;Doctrine_Query::parseClause()&lt;/tt&gt; if it is an SQL function...&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;This can also produce weird results with SQL functions:&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;$q4 = Doctrine_Query::create()
    -&amp;gt;from(&apos;User u&apos;)
    -&amp;gt;innerJoin(&apos;u.Phonenumbers p WITH SUBSTRING(p.number,0,3) = \&apos;555\&apos;&apos;); &lt;span class=&quot;code-comment&quot;&gt;//left
&lt;/span&gt;
$q5 = Doctrine_Query::create()
    -&amp;gt;from(&apos;User u&apos;)
    -&amp;gt;innerJoin(&apos;u.Phonenumbers p WITH \&apos;555\&apos; = SUBSTRING(p.number,0,3)&apos;); &lt;span class=&quot;code-comment&quot;&gt;//right
&lt;/span&gt;
echo $q4-&amp;gt;getSqlQuery() . &lt;span class=&quot;code-quote&quot;&gt;&quot;\n&quot;&lt;/span&gt;;
echo $q5-&amp;gt;getSqlQuery() . &lt;span class=&quot;code-quote&quot;&gt;&quot;\n&quot;&lt;/span&gt;;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Output:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;SELECT u.id AS u__id, p.id AS p__id, p.colprefix_user_id AS p__colprefix_user_id, p.colprefix_number AS p__colprefix_number
        FROM user u INNER JOIN phonenumber p ON u.id = p.colprefix_user_id AND (SUBSTRING(p.colprefix_number FROM 0 FOR 3) = &apos;555&apos;)

SELECT u.id AS u__id, p.id AS p__id, p.colprefix_user_id AS p__colprefix_user_id, p.colprefix_number AS p__colprefix_number
        FROM user u INNER JOIN phonenumber p ON u.id = p.colprefix_user_id AND (&apos;555&apos; = SUBSTRING(p.colprefix_number FROM 0 FOR 3 FROM ))
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Now, the correct column name is always used, but in the 2nd case the &quot;SUBSTRING&quot; function looks like it has been parsed twice :/&lt;/p&gt;

&lt;p&gt;I think both members (left and right) of condition should be treated equally (but I have no fix for now... :s)&lt;/p&gt;

&lt;p&gt;Thank you &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/smile.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</description>
                <environment>Doctrine SVN 1.2 r7676</environment>
            <key id="11533">DC-757</key>
            <summary>In SQL query, field name is not replaced with real column name in right part of join condition</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="gx">Guilliam X</reporter>
                        <labels>
                    </labels>
                <created>Mon, 21 Jun 2010 08:42:20 +0000</created>
                <updated>Mon, 21 Jun 2010 10:04:06 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="13387" author="gx" created="Mon, 21 Jun 2010 10:04:06 +0000"  >&lt;p&gt;Waiting for better, I attach the patch I used;&lt;br/&gt;
but it&apos;s not a good one, as it only &quot;solves&quot; the field name problem but not the SUBSTRING one, and is more a patch than a fix... (sorry I don&apos;t feel to refactor Doctrine_Query_JoinCondition::load() :s)&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10672" name="DC757-patch_1.txt" size="792" author="gx" created="Mon, 21 Jun 2010 10:04:06 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-739] Pager returns incorrect page number when constructed on query with HAVING</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-739</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;//method returns those categories that have any products, it returns 3 records&lt;br/&gt;
public function getCategoriesWithProductsQuery()&lt;/p&gt;
 {
   $query = $this-&amp;gt;createQuery(&apos;z&apos;)-&amp;gt;select( &apos;z.*, COUNT(p.id) prod_number&apos; )
          -&amp;gt;leftJoin( &apos;z.AdvertiseProducts p&apos; )-&amp;gt;groupBy( &apos;z.id&apos; )-&amp;gt;having(&apos;prod_number &amp;gt; 0&apos;);

   return $query;
 }

&lt;p&gt;//but when i do count() on created pager it returns 8 records (which is equal to categories in my database):&lt;/p&gt;

&lt;p&gt;$doctrinePager = $this-&amp;gt;getServiceContainer()&lt;br/&gt;
-&amp;gt;setParameter(&apos;doctrine_pager.model&apos;, &apos;ZwCategory&apos;)&lt;br/&gt;
-&amp;gt;getService(&apos;doctrine_pager&apos;)&lt;br/&gt;
&lt;del&gt;&amp;gt;setMaxPerPage($this&lt;/del&gt;&amp;gt;maxPerPage)&lt;br/&gt;
-&amp;gt;setQuery($query)&lt;br/&gt;
&lt;del&gt;&amp;gt;setPage(null === $page ? $this&lt;/del&gt;&amp;gt;page : $page)&lt;br/&gt;
-&amp;gt;init();&lt;br/&gt;
var_dump(count($doctrinePager));&lt;/p&gt;

&lt;p&gt;//pager works, but it &quot;thinks&quot; that there are more pages than in reality. with maxPerPage = 2, it thinks that there are 4 pages, but looking at query result it //should be only 2 pages.&lt;/p&gt;</description>
                <environment>Ubuntu 9.10, &lt;br/&gt;
Apache/MySQL,&lt;br/&gt;
Framework: Symfony 1.4&lt;br/&gt;
</environment>
            <key id="11499">DC-739</key>
            <summary>Pager returns incorrect page number when constructed on query with HAVING</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="pawelbaranski">Pawe&#322; Bara&#324;ski</reporter>
                        <labels>
                    </labels>
                <created>Wed, 16 Jun 2010 03:14:11 +0000</created>
                <updated>Wed, 16 Jun 2010 03:16:39 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Pager</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-254] getLimitSubquery Not Including All Order By Parts</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-254</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;The getLimitSubquery function is only including the first orderby field and ignoring all remaining parts. The function also needs to be changed to include mssql and odbc.&lt;/p&gt;

&lt;p&gt;The diff&apos;s below provide corrections.&lt;/p&gt;

&lt;p&gt;Thanks,&lt;/p&gt;

&lt;p&gt;Mike&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;diff -r Doctrine-1.1.2\lib\Doctrine\Query.php Doctrine-1.1.2-Fixes\lib\Doctrine\Query.php
1367c1367
&amp;lt;         &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($driverName == &apos;pgsql&apos; || $driverName == &apos;oracle&apos; || $driverName == &apos;oci&apos;) {
---
&amp;gt;         &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($driverName == &apos;pgsql&apos; || $driverName == &apos;oracle&apos; || $driverName == &apos;oci&apos; || $driverName == &apos;mssql&apos; || $driverName == &apos;odbc&apos;) {
1371,1387c1371,1392
&amp;lt;                 $part_original = trim($e[0]);
&amp;lt;                 $callback = create_function(&apos;$e&apos;, &apos;&lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; trim($e, \&apos;[]`&quot;\&apos;);&apos;);
&amp;lt;                 $part = trim(implode(&apos;.&apos;, array_map($callback, explode(&apos;.&apos;, $part_original))));
&amp;lt; 
&amp;lt;                 &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (strpos($part, &apos;.&apos;) === &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;) {
&amp;lt;                     &lt;span class=&quot;code-keyword&quot;&gt;continue&lt;/span&gt;;
&amp;lt;                 }
&amp;lt; 
&amp;lt;                 &lt;span class=&quot;code-comment&quot;&gt;// don&apos;t add functions
&lt;/span&gt;&amp;lt;                 &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (strpos($part, &apos;(&apos;) !== &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;) {
&amp;lt;                     &lt;span class=&quot;code-keyword&quot;&gt;continue&lt;/span&gt;;
&amp;lt;                 }
&amp;lt; 
&amp;lt;                 &lt;span class=&quot;code-comment&quot;&gt;// don&apos;t add primarykey column (its already in the select clause)
&lt;/span&gt;&amp;lt;                 &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($part !== $primaryKey) {
&amp;lt;                     $subquery .= &apos;, &apos; . $part_original;
&amp;lt;                 }
---
&amp;gt; 
&amp;gt;                 foreach ($e as $f) {
&amp;gt;                     &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($f == 0 || $f % 2 == 0) {
&amp;gt;                         $part_original = trim($f);
&amp;gt;                         $callback = create_function(&apos;$e&apos;, &apos;&lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; trim($e, \&apos;[]`&quot;\&apos;);&apos;);
&amp;gt;                         $part = trim(implode(&apos;.&apos;, array_map($callback, explode(&apos;.&apos;, $part_original))));
&amp;gt; 
&amp;gt;                         &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (strpos($part, &apos;.&apos;) === &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;) {
&amp;gt;                             &lt;span class=&quot;code-keyword&quot;&gt;continue&lt;/span&gt;;
&amp;gt;                         }
&amp;gt; 
&amp;gt;                         &lt;span class=&quot;code-comment&quot;&gt;// don&apos;t add functions
&lt;/span&gt;&amp;gt;                         &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (strpos($part, &apos;(&apos;) !== &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;) {
&amp;gt;                             &lt;span class=&quot;code-keyword&quot;&gt;continue&lt;/span&gt;;
&amp;gt;                         }
&amp;gt; 
&amp;gt;                         &lt;span class=&quot;code-comment&quot;&gt;// don&apos;t add primarykey column (its already in the select clause)
&lt;/span&gt;&amp;gt;                         &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($part !== $primaryKey) {
&amp;gt;                             $subquery .= &apos;, &apos; . $part_original;
&amp;gt;                         }
&amp;gt;                     }
&amp;gt;                 }

&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment></environment>
            <key id="10450">DC-254</key>
            <summary>getLimitSubquery Not Including All Order By Parts</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="guilhermeblanco">Guilherme Blanco</assignee>
                                <reporter username="gensisns">Michael Card</reporter>
                        <labels>
                    </labels>
                <created>Wed, 18 Nov 2009 15:58:12 +0000</created>
                <updated>Sun, 27 Feb 2011 18:39:08 +0000</updated>
                                    <version>1.2.0-BETA3</version>
                                <fixVersion>1.2.0-RC1</fixVersion>
                                <component>Query</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="11276" author="gensisns" created="Tue, 22 Dec 2009 20:41:01 +0000"  >&lt;p&gt;Additonal fix for this issue, was missing dblib originally.&lt;/p&gt;

&lt;p&gt;Mike&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;
diff -r Doctrine-1.1.2\lib\Doctrine\Query.php Doctrine-1.1.2-Fixes\lib\Doctrine\Query.php
1367c1367
&amp;lt; &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($driverName == &apos;pgsql&apos; || $driverName == &apos;oracle&apos; || $driverName == &apos;oci&apos; || $driverName == &apos;mssql&apos; || $driverName == &apos;odbc&apos;) {
&#8212;
&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($driverName == &apos;pgsql&apos; || $driverName == &apos;oracle&apos; || $driverName == &apos;oci&apos; || $driverName == &apos;mssql&apos; || $driverName == &apos;odbc&apos; || $driverName == &apos;dblib&apos;) {

&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                    <comment id="15403" author="andrej.pavlovic" created="Sun, 27 Feb 2011 18:39:08 +0000"  >&lt;p&gt;Come on guys, please include this fix into 1.2.4...&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-896] MySQL Limit implementation leads to incorrect results if the original where clause contains an &quot;OR&quot; operator</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-896</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;If adding the Where In clause for the subquery &quot;limit&quot; implementation, the original where clause needs to be isolated with parenthesis.  In my sample where clause the first character is in fact an opening parenthesis and the last character is in fact a closing parenthesis, however, there are a bunch of conditions and parenthesis between them as well that may contain &quot;OR&quot; operators.  When this is combined with the Where In clause generated by the Pager tool&apos;s &quot;limit&quot; implementation for MySQL it leads to incorrect results.  &lt;/p&gt;

&lt;p&gt;Here is my &quot;Before&quot; Where condition:&lt;/p&gt;

&lt;p&gt;WHERE c.id  IN (&apos;25&apos;, &apos;31&apos;, &apos;6&apos;, &apos;28&apos;, &apos;30&apos;, &apos;16&apos;, &apos;32&apos;, &apos;26&apos;, &apos;22&apos;, &apos;14&apos;) AND (a2.data_item_id = ? AND a2.value = ?) AND (a3.data_item_id = ? AND a3.value = ?) OR (a4.data_item_id = ? AND a4.value = ?) AND (a5.data_item_id = ? AND a5.value = ?)&lt;/p&gt;

&lt;p&gt;And the &quot;After&quot; Where condition&lt;br/&gt;
WHERE c.id  IN (&apos;25&apos;, &apos;31&apos;, &apos;6&apos;, &apos;28&apos;, &apos;30&apos;, &apos;16&apos;, &apos;32&apos;, &apos;26&apos;, &apos;22&apos;, &apos;14&apos;) AND ((a2.data_item_id = ? AND a2.value = ?) AND (a3.data_item_id = ? AND a3.value = ?) OR (a4.data_item_id = ? AND a4.value = ?) AND (a5.data_item_id = ? AND a5.value = ?))&lt;/p&gt;

&lt;p&gt;Fix:&lt;/p&gt;

&lt;p&gt;Line 1305 in Query.php:&lt;br/&gt;
$where = ($where == &apos;&apos; || (substr($where, 0, 1) === &apos;(&apos; &amp;amp;&amp;amp; substr($where, -1) === &apos;)&apos;))&lt;br/&gt;
        ? $where : &apos;(&apos; . $where . &apos;)&apos;;&lt;/p&gt;

&lt;p&gt;I ended up just adding the following just after the above statement in the code:&lt;br/&gt;
if (!empty($limitSubquerySql) &amp;amp;&amp;amp; !empty($where)) &lt;/p&gt;
        { $where = &apos;(&apos; . $where . &apos;)&apos;; } </description>
                <environment>Doctrine + MySQL</environment>
            <key id="12022">DC-896</key>
            <summary>MySQL Limit implementation leads to incorrect results if the original where clause contains an &quot;OR&quot; operator</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="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="datacraftpakele">James Pakele</reporter>
                        <labels>
                    </labels>
                <created>Wed, 20 Oct 2010 08:59:51 +0000</created>
                <updated>Wed, 20 Oct 2010 08:59:51 +0000</updated>
                                                                    <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-855] Notify via Exception when a feature is specifically not supported for compatability</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-855</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;For situations like with &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-646&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/jira/browse/DC-646&lt;/a&gt; would it be possible to look at throwing an exception with an explanation of why it does not work, rather than simply let the query fail because of intentionally incorrect query generation?&lt;/p&gt;

&lt;p&gt;Granted, the fix is relatively simple (just select and delete the results, instead), but if I don&apos;t know why the wrong query is being made, I don&apos;t know to change my approach rather than simply assume I&apos;m doing something wrong.&lt;/p&gt;</description>
                <environment>N/A</environment>
            <key id="11873">DC-855</key>
            <summary>Notify via Exception when a feature is specifically not supported for compatability</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="guilhermeblanco">Guilherme Blanco</assignee>
                                <reporter username="jmather">Jacob Mather</reporter>
                        <labels>
                    </labels>
                <created>Thu, 2 Sep 2010 10:30:13 +0000</created>
                <updated>Thu, 2 Sep 2010 10:30:13 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-1016] Set method in update query ignores &apos;false&apos; if passed as boolean</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-1016</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;I had to define this function:&lt;/p&gt;

&lt;p&gt;public function deactivate($segment_id)&lt;/p&gt;
    {
        $query = $this-&amp;gt;createQuery()
                -&amp;gt;update(&apos;Segment s&apos;)
                -&amp;gt;set(&apos;s.is_active &apos;, false) //not working
//              -&amp;gt;set(&apos;s.is_active &apos;, (int)false) //works ok
//              -&amp;gt;set(&apos;s.is_active &apos;, true) //works ok
                -&amp;gt;where(&apos;s.id = ?&apos;, $segment_id);
//        var_dump($query-&amp;gt;getSqlQuery());die;
        return $query-&amp;gt;execute();
    }

&lt;p&gt;Problem is that when setting a column using boolean false you get invalid SQL query like this:&lt;br/&gt;
UPDATE segment SET is_active  =  WHERE (id = ?)&lt;/p&gt;

&lt;p&gt;Workaround is to do it like this: set(&apos;s.is_active &apos;, (int)false) , but since setting the same column with boolean true works, false should work too.&lt;/p&gt;</description>
                <environment>Symfony 1.4.11 , Ubuntu 11, PHP 5.3</environment>
            <key id="12788">DC-1016</key>
            <summary>Set method in update query ignores &apos;false&apos; if passed as boolean</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="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="pawelbaranski">Pawe&#322; Bara&#324;ski</reporter>
                        <labels>
                    </labels>
                <created>Tue, 5 Jul 2011 10:23:33 +0000</created>
                <updated>Tue, 5 Jul 2011 10:23:33 +0000</updated>
                                    <version>1.2.4</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-1003] _processWhereIn does not allow the use of named query parameters</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-1003</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When writing a query such as &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;$query = $query-&amp;gt;where(&apos;entity.myValue = :value&apos;, array(&apos;:value&apos;=&amp;gt;5));&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;you are unable to then&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;$query = $query-&amp;gt;whereIn(&apos;entity.otherValue&apos;, array(&apos;:otherValues&apos;=&amp;gt;array(1,2,3)));&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Doctrine complains that you may not mix positional and named query parameters.&lt;/p&gt;

&lt;p&gt;The attached patch fixes this by checking if the key of the passed in parameter is non numeric and if so setting the &quot;value&quot; of the parameter place holder to the value of the key.&lt;/p&gt;</description>
                <environment>karmic, php 5.2.10, apache2</environment>
            <key id="12615">DC-1003</key>
            <summary>_processWhereIn does not allow the use of named query parameters</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="guilhermeblanco">Guilherme Blanco</assignee>
                                <reporter username="alex.pilon">alex pilon</reporter>
                        <labels>
                    </labels>
                <created>Thu, 5 May 2011 21:22:56 +0000</created>
                <updated>Fri, 6 May 2011 00:06:42 +0000</updated>
                                                    <fixVersion>1.2.4</fixVersion>
                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="15809" author="alex.pilon" created="Thu, 5 May 2011 21:59:01 +0000"  >&lt;p&gt;I discovered an issue with the above patch. I am working on a better version.&lt;/p&gt;</comment>
                    <comment id="15810" author="alex.pilon" created="Fri, 6 May 2011 00:06:42 +0000"  >&lt;p&gt;Here is a second version.. it is a little bit sloppy. Is there a resource I can find on here that will help me to improve code quality/unit test this?&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10987" name="_processWhereIn-named-parameter-v2.patch" size="884" author="alex.pilon" created="Fri, 6 May 2011 00:06:42 +0000" />
                    <attachment id="10986" name="_processWhereIn-named-parameter.patch" size="581" author="alex.pilon" created="Thu, 5 May 2011 21:22:56 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-964] Alias name error when using interval(MySQL)</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-964</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;I&apos;m using Doctrine with Symfony and i have some troubles when i&apos;m using the mysql command: interval. Here&apos;s a detailed explanation:&lt;br/&gt;
Part of the schema:&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-xml&quot;&gt;User:
  columns:
    name: { type: string(255), notnull: true }
    nick: { type: string(255), notnull: true, unique: true }
    email: { type: string(255), notnull: true, unique: true }
    password: { type: string(40), notnull: true }

VirtualConferenceRoom:
  columns:
    adminId: { type: integer, notnull: true }
    name: { type: string(255), notnull: true }
    startDate: { type: timestamp, notnull: true }
    duration: { type: integer, notnull: true }
  relations:
    Admin:
      class: User
      foreign: id
      local: adminId

VirtualConferenceRoomUser:
  columns:
    virtualConferenceRoomId: { type: integer, notnull: true }
    userId: { type: integer, notnull: true }
  relations:
    VirtualConferenceRoom:
      class: VirtualConferenceRoom
      foreign: id
      local: virtualConferenceRoomId
    User:
      class: User
      foreign: id
      local: userId
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;I&apos;ve generated my model with symfony&apos;s built in command(symfony doctrine:build --model --sql)&lt;br/&gt;
When I try to get the conference rooms which are in progress at the moment I try it 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;&lt;span class=&quot;code-comment&quot;&gt;// In the project/lib/model/doctrine/VirtualConferenceRoomTable.class.php which is &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; from Doctrine_Table
&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function getRoomsInProgressByUserId($userId)
{
    &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; Doctrine_Query::create()
                -&amp;gt;select(&apos;vcr.*&apos;)
                -&amp;gt;from(&apos;VirtualConferenceRoom vcr&apos;)
                -&amp;gt;innerJoin(&apos;vcr.VirtualConferenceRoomUser vcru&apos;)
                -&amp;gt;where(&apos;(vcr.StartDate &amp;lt; now()) and (vcr.StartDate + interval vcr.Duration minute &amp;gt; now()) and vcru.UserId = ?&apos;, array($userId))
                -&amp;gt;execute();
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;When I try to run my app I get an error message: &quot;SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;42S22&amp;#93;&lt;/span&gt;: Column not found: 1054 Unknown column &apos;vcr.Duration&apos; in &apos;where clause&apos;&quot;&lt;br/&gt;
The generated sql command is: &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-quote&quot;&gt;&quot; &lt;span class=&quot;code-keyword&quot;&gt;SELECT&lt;/span&gt; v.id AS v__id, v.userid AS v__userid, v.name AS v__name, v.startdate AS v__startdate, v.duration AS v__duration &lt;span class=&quot;code-keyword&quot;&gt;FROM&lt;/span&gt; virtual_conference_room v INNER JOIN virtual_conference_room_user v2 ON v.id = v2.virtualconferenceroomid &lt;span class=&quot;code-keyword&quot;&gt;WHERE&lt;/span&gt; (v.startdate &amp;lt; NOW() AND v.startdate + interval vcr.Duration minute &amp;gt; NOW() AND v2.userid = ?) - (2)&quot;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The problem is the vcr.Duration section. If I change my function from:&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;-&amp;gt;where(&apos;(vcr.StartDate &amp;lt; now()) and (vcr.StartDate + interval vcr.Duration minute &amp;gt; now()) and vcru.UserId = ?&apos;, array($userId))
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;to:&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;-&amp;gt;where(&apos;(vcr.StartDate &amp;lt; now()) and (vcr.StartDate + interval v.Duration minute &amp;gt; now()) and vcru.UserId = ?&apos;, array($userId))
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;it works perfectly. &lt;/p&gt;

&lt;p&gt;I hope my report is useful and clear and i can help you to improve this great ORM &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/smile.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;
Best wishes: Tibor Erd&#233;sz &amp;lt;erdeszt@gmail.com&amp;gt;&lt;/p&gt;</description>
                <environment>PHP Version 5.3.3-1ubuntu9.3; Apache/2.2.16 (Ubuntu); MySQL: 5.1.41; Symfony 1.4; Doctrine 1.2.3 (Revision: 7490)</environment>
            <key id="12352">DC-964</key>
            <summary>Alias name error when using interval(MySQL)</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="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="erdeszt">Tibor Erd&#233;sz</reporter>
                        <labels>
                    </labels>
                <created>Thu, 3 Feb 2011 07:29:35 +0000</created>
                <updated>Thu, 3 Feb 2011 07:37:28 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="15221" author="erdeszt" created="Thu, 3 Feb 2011 07:34:38 +0000"  >&lt;p&gt;Just figured out that I can use &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;&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt; notations and I fixed my report. &lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-943] Memory leaks in find* magic methods owing to failure to free queries</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-943</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;The following methods on Doctrine_Table create Doctrine_Query objects that are never free()d:&lt;br/&gt;
  findAll()&lt;br/&gt;
  findBySql()&lt;br/&gt;
  findByDql()&lt;br/&gt;
  findBy()&lt;br/&gt;
  findOneBy() &lt;/p&gt;</description>
                <environment></environment>
            <key id="12188">DC-943</key>
            <summary>Memory leaks in find* magic methods owing to failure to free queries</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="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="garpini">Garpini</reporter>
                        <labels>
                    </labels>
                <created>Fri, 3 Dec 2010 08:39:53 +0000</created>
                <updated>Fri, 3 Dec 2010 10:30:42 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="14896" author="garpini" created="Fri, 3 Dec 2010 10:30:42 +0000"  >&lt;p&gt;The attachment contains a patch that addresses the memory leak by free()ing the query objects generated before returning the results of the query.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10882" name="doctrine_query_patch.patch" size="1568" author="garpini" created="Fri, 3 Dec 2010 10:30:42 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-354] Using BETWEEN operator with MySQL fails</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-354</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When running this bit of code the query fails with the error &quot;Unknown aggregate alias: interval&quot;, and calling $q-&amp;gt;getSql() doesn&apos;t return anything.&lt;/p&gt;

&lt;p&gt;{{$q = Doctrine_Query::create()&lt;br/&gt;
  ...&lt;br/&gt;
  -&amp;gt;where(&apos;u.birthday BETWEEN date_sub(now(), interval 7 day) AND NOW()&apos;);}}&lt;/p&gt;

&lt;p&gt;I&apos;ve tried different variations in the where() clause with no luck. I am using all the other MySQL functions in another query here:&lt;br/&gt;
&lt;tt&gt;$q-&amp;gt;where(&apos;date(birthday) = date_sub(curdate(), interval 1 day)&apos;)&lt;/tt&gt;&lt;br/&gt;
so I don&apos;t believe that they are the problem.&lt;/p&gt;

&lt;p&gt;I would expect the BETWEEN operator to be recognized and work appropriately.&lt;/p&gt;</description>
                <environment>PHP 5.2.10&lt;br/&gt;
MySQL 5.1.37</environment>
            <key id="10604">DC-354</key>
            <summary>Using BETWEEN operator with MySQL fails</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="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="matt">Matt McKeon</reporter>
                        <labels>
                    </labels>
                <created>Fri, 11 Dec 2009 13:38:09 +0000</created>
                <updated>Tue, 8 Jun 2010 16:34:36 +0000</updated>
                                    <version>1.1.4</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="13208" author="jwage" created="Tue, 8 Jun 2010 16:34:36 +0000"  >&lt;p&gt;BETWEEN is mysql specific, no?&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-811] calculateQueryCacheHash causes a fatal error when used in combination with output buffering</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-811</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When using output buffering in combination with a doctrine caching driver. var_export causes a fatal error as described here:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://marc.info/?l=phpdoc&amp;amp;m=114122422804066&quot; class=&quot;external-link&quot;&gt;http://marc.info/?l=phpdoc&amp;amp;m=114122422804066&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://php.net/manual/en/function.var-export.php&quot; class=&quot;external-link&quot;&gt;http://php.net/manual/en/function.var-export.php&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the proposed patch.&lt;/p&gt;</description>
                <environment></environment>
            <key id="11732">DC-811</key>
            <summary>calculateQueryCacheHash causes a fatal error when used in combination with output buffering</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="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="carlalexander">Carl Alexander</reporter>
                        <labels>
                    </labels>
                <created>Fri, 6 Aug 2010 14:44:59 +0000</created>
                <updated>Tue, 24 Aug 2010 12:49:21 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="14056" author="jwage" created="Tue, 24 Aug 2010 12:49:21 +0000"  >&lt;p&gt;This seems to break the test suite in several places so it cannot be applied. If you can provide a patch that passes the test suite we can discuss applying the patch.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10723" name="query_abstract.patch" size="540" author="carlalexander" created="Fri, 6 Aug 2010 14:44:59 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-796] Correct way to count all files from a table ?</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-796</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;If I execute this to get the amount of records in a table I get the correct result, but it takes too long and consumes a lot of resources as if I get all the fields from table:&lt;/p&gt;

&lt;p&gt;Doctrine::getTable(&apos;Recurso&apos;)&lt;del&gt;&amp;gt;findAll()&lt;/del&gt;&amp;gt;count(); &lt;/p&gt;

&lt;p&gt;Am I doing it wrong?, The only other option I&apos;ve found is to use DSQL and execute a query like &quot;SELECT count&lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/star_yellow.gif&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt; from recurso&quot;.&lt;/p&gt;

&lt;p&gt;Thank you in advance.&lt;/p&gt;

&lt;p&gt;Pablo.&lt;/p&gt;</description>
                <environment>Debian Lenny / MySQL 5.1</environment>
            <key id="11675">DC-796</key>
            <summary>Correct way to count all files from a table ?</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="guilhermeblanco">Guilherme Blanco</assignee>
                                <reporter username="pgmateos">Pablo Mateos</reporter>
                        <labels>
                    </labels>
                <created>Thu, 22 Jul 2010 11:22:28 +0000</created>
                <updated>Thu, 22 Jul 2010 11:57:36 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-771] fetchOne return boolean</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-771</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Doctrine_Query::fetchOne could return false..&lt;/p&gt;

&lt;p&gt;It a &quot;get&quot; function, so the function should return &quot;null&quot; or an &quot;object&quot;, but a boolean isn&apos;t a good value..&lt;/p&gt;</description>
                <environment></environment>
            <key id="11567">DC-771</key>
            <summary>fetchOne return boolean</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="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="armetiz">Thomas Tourlourat - Armetiz</reporter>
                        <labels>
                    </labels>
                <created>Tue, 29 Jun 2010 07:10:00 +0000</created>
                <updated>Tue, 29 Jun 2010 07:10:00 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>