<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Sat May 25 17:18:56 UTC 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/si/jira.issueviews:issue-xml/DC-188/DC-188.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://www.doctrine-project.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.7</version>
        <build-number>850</build-number>
        <build-date>21-02-2013</build-date>
    </build-info>

<item>
            <title>[DC-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>
</channel>
</rss>