Commit b6e8c400 authored by zYne's avatar zYne

column alias support for DQL HAVING part

parent d77ffb28
......@@ -63,7 +63,8 @@ class Doctrine_Query_Having extends Doctrine_Query_Condition
$field = array_pop($a);
$reference = implode('.', $a);
$table = $this->query->load($reference, false);
$func = $this->query->getTableAlias($reference).".".$field;
$field = $table->getColumnName($field);
$func = $this->query->getTableAlias($reference) . '.' . $field;
return $func;
} else {
......
......@@ -75,6 +75,30 @@ class Doctrine_ColumnAlias_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($coll[0]->alias1, 'someone');
$this->assertEqual($coll[0]->alias2, 187);
}
public function testAliasesAreSupportedForDqlAggregateFunctions()
{
$q = new Doctrine_Query();
$q->select('MAX(c.alias1)')
->from('ColumnAliasTest c');
$coll = $q->execute();
$this->assertEqual($coll[0]->max, 'someone');
}
public function testAliasesAreSupportedForDqlHavingPart()
{
$q = new Doctrine_Query();
$q->select('c.alias1')
->from('ColumnAliasTest c')
->having('MAX(c.alias2) = 187')
->groupby('c.id');
$coll = $q->execute();
$this->assertEqual($coll[0]->alias1, 'someone');
}
}
class ColumnAliasTest extends Doctrine_Record
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment