Query builder count_all_results breaking change on group by statements |
Hi CI Forum,
I'm just copying what I've typed into the GH issue tracker on https://github.com/bcit-ci/CodeIgniter/issues/4842 I've just upgraded from CI 3.0.4 all the way to 3.1.0 with all the intermediary upgrade steps taken. There is a specific query which works previously and breaks now (MySQL) when using count_all_results function. In 3.0.4 , count_all_results compiled into the following query which works: Code: SELECT COUNT(*) AS numrows Code: SELECT COUNT(*) AS numrows FROM Code: Error Code: 1060. Duplicate column name 'item_id' Notice the difference is in the new version it creates a subquery, the reason for this is the change in count_all_results function : In 3.0.4 - DB_query_builder.php , line 1382 Code: $result = ($this->qb_distinct === TRUE OR ! empty($this->qb_orderby)) In 3.1.0 - DB_query_builder.php , line 1398 Code: $result = ($this->qb_distinct === TRUE OR ! empty($this->qb_groupby)) So there is a new condition which checks for group by statements, and the condition is met (unlike the previous version). A workaround currently we use is to revert that particular IF statement only to not check for group by statement. |
Messages In This Thread |
Query builder count_all_results breaking change on group by statements - by prastha - 10-13-2016, 10:14 PM
RE: Query builder count_all_results breaking change on group by statements - by ciadmin - 10-14-2016, 12:05 AM
|