Ticket #451 (closed defect: fixed)
->count() and CONCAT don't play nice
| Reported by: | Jay.Klehr | Owned by: | somebody |
|---|---|---|---|
| Priority: | major | Milestone: | 0.10.3 |
| Component: | Other | Version: | 0.10.0 |
| Severity: | Keywords: | ||
| Cc: | Has Test: | ||
| Status: | Has Patch: |
Description
I set up a query like so:
Doctrine_Query::create()->select("Thing.name, CONCAT(Thing.col, Thing.col2) something")->from('Thing');
Which does build the proper query when I print the query, however, when I do a ->count() on the query, Doctrine isn't removing the CONCAT bit from the SELECT, so I get a mysql error.
#1140 - Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
The SQL that Doctrine runs when I do the count() looks like the following:
SELECT COUNT(DISTINCT t.id) AS num_results, CONCAT(`t`.`col1`, `t`.`col2`) AS `t__0` FROM `things` `t`
Which is illegal without a GROUP BY. If I get rid of the CONCAT, and just select a column, Doctrine properly removes the column when executing the COUNT.
Change History
Note: See
TracTickets for help on using
tickets.