Details
Description
How to reproduce
$query->having('<aggregate_alias> <operator> <column_alias>').
Expected SQL:
... HAVING <internal_aggregate_alias> <operator> a<N>__<column_name>...
Produced SQL
... HAVING <internal_aggregate_alias> <operator> <column_alias> ... /* yes, the same <column_alias> as in ->having() call! */
I've prepared this "real-world example".
Please fix it someone since I'm forced to invent weird workarounds to emulate this behaviour.
Thanks in advance.
Doesn't work for me in Symfony 1.3.1, Doctrine 1.2.1
using this DQL:
Doctrine_Query::create()
->select('COUNT(s.status) as cn MIN(s.status) as minstat')
->from('LogisticOrder o')
->innerJoin('o.Status os')
->innerJoin('o.PickingRequests r')
->innerJoin('r.Status s')
->where('os.status=?', OrderStatusLog::$STATUS_PICKING)
->groupBy('r.order_id')
->having('minstat=? AND cn=1', array(512))
->getSqlQuery();
I get
SELECT COUNT(s4.status) AS s4__0 FROM sd_logisticorder s INNER JOIN sd_order_status_log s2 ON s.status_id = s2.id INNER JOIN sd_picking_request s3 ON s.id = s3.order_id INNER JOIN sd_picking_request_status s4 ON s3.id = s4.request_id WHERE (s2.status = ?) GROUP BY s3.order_id HAVING (minstat=? AND cn=1 )