Ticket #2275 (closed defect: fixed)
Limit subquery keeps column alias of agg expr inside subquery
| Reported by: | guilhermeblanco | Owned by: | guilhermeblanco |
|---|---|---|---|
| Priority: | critical | Milestone: | 1.2.0 |
| Component: | Query/Hydration | Version: | 1.0.10 |
| Severity: | abc | Keywords: | limit subquery alias |
| Cc: | Has Test: | no | |
| Status: | Pending Core Response | Has Patch: | no |
Description
Issue was found in PHP 5.3.0, which contains bundled sqlite 3.6.15 library. MySQL 5.1.34 also has same checking which is not failing the test too.
It seems that order by is being included in subquery. Since its internal aliases do not contain the alias itself, query fails.
Small example exposes the issue:
Doctrine_Query_Subquery_TestCase : method testGetLimitSubqueryOrderBy2 failed on line 105 SQLSTATE[HY000]: General error: 1 no such column: a__0 SELECT e.id AS e__id, e.name AS e__name, COUNT(DISTINCT a.id) AS a__0 FROM entity e LEFT JOIN album a ON e.id = a.user_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 LEFT JOIN album a2 ON e2.id = a2.user_id WHERE (e2.type = 0) GROUP BY e2.id ORDER BY a__0 LIMIT 5) AND (e.type = 0) GROUP BY e.id ORDER BY a__0
The ORDER BY a0 inside subquery should not be there.
This is a critical issue and should be fixed ASAP. Making as blocker and assigning to me
Change History
Note: See
TracTickets for help on using
tickets.