1
0
mirror of synced 2024-12-13 14:56:01 +03:00

column alias support for DQL HAVING part

This commit is contained in:
zYne 2007-01-23 16:40:46 +00:00
parent d77ffb28c9
commit b6e8c40067
2 changed files with 26 additions and 1 deletions

View File

@ -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 {

View File

@ -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
{