column alias support for DQL HAVING part
This commit is contained in:
parent
d77ffb28c9
commit
b6e8c40067
@ -63,7 +63,8 @@ class Doctrine_Query_Having extends Doctrine_Query_Condition
|
|||||||
$field = array_pop($a);
|
$field = array_pop($a);
|
||||||
$reference = implode('.', $a);
|
$reference = implode('.', $a);
|
||||||
$table = $this->query->load($reference, false);
|
$table = $this->query->load($reference, false);
|
||||||
$func = $this->query->getTableAlias($reference).".".$field;
|
$field = $table->getColumnName($field);
|
||||||
|
$func = $this->query->getTableAlias($reference) . '.' . $field;
|
||||||
|
|
||||||
return $func;
|
return $func;
|
||||||
} else {
|
} else {
|
||||||
|
@ -75,6 +75,30 @@ class Doctrine_ColumnAlias_TestCase extends Doctrine_UnitTestCase
|
|||||||
$this->assertEqual($coll[0]->alias1, 'someone');
|
$this->assertEqual($coll[0]->alias1, 'someone');
|
||||||
$this->assertEqual($coll[0]->alias2, 187);
|
$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
|
class ColumnAliasTest extends Doctrine_Record
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user