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.
If this is a bug, it belongs on github and probably not here.
If it is a problem using the framework, then it belongs on here and *not* on github. If you are not sure if it is a bug, it is better to raise it here, for community input. It is not cool to cross-post, especially verbatim. |
Welcome Guest, Not a member yet? Register Sign In |