Issues

ZF-11996: Invalid query is generated by DbAdapter for queries grouped by aliases

Issue Type: Bug Created: 2012-01-13T13:50:03.000+0000 Last Updated: 2012-01-13T13:52:02.000+0000 Status: Open Fix version(s): Reporter: Alexander Grimalovsky (flying) Assignee: Jurrien Stutterheim (norm2782) Tags: - Zend_Paginator

Related issues: Attachments: - DbSelect.patch

Description

Zend_Paginator_Adapter_DbSelect creates invalid SQL query for rows counting in a case if given query have GROUP BY clause with use of column alias instead of column itself. For example attempt to count rows for the following query:

<pre class="highlight">select a as some_column, b as other_column
from some_table 
where some_column='value'
group by some_column

will produce SQL query:

<pre class="highlight">select count(distinct some_column)
from some_table 
where some_column='value'

which will fail because there is no some_column column in table.

Comments

Posted by Alexander Grimalovsky (flying) on 2012-01-13T13:52:02.000+0000

Proposed fix for issue. It scans list of columns of original query for aliases for column from GROUP BY clause and replaces it with original column name if found.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts