Commit 07a710ef authored by zYne's avatar zYne

--no commit message

--no commit message
parent 760e598b
......@@ -855,6 +855,9 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
foreach ($this->parts['orderby'] as $part) {
$part = trim($part);
$e = Doctrine_Tokenizer::bracketExplode($part, ' ');
$part = trim($e[0]);
$aggregate = false;
foreach ($this->parts['select'] as $select) {
......
......@@ -38,7 +38,7 @@ class Doctrine_Query_MysqlSubquery_TestCase extends Doctrine_UnitTestCase
$this->conn = Doctrine_Manager::getInstance()->openConnection($this->dbh);
}
public function testGetLimitSubqueryWithOrderByOnAggregateValues()
public function testGetLimitSubquerSupportsOrderByWithAggregateValues()
{
$q = new Doctrine_Query();
$q->select('u.name, COUNT(DISTINCT a.id) num_albums');
......@@ -53,8 +53,22 @@ class Doctrine_Query_MysqlSubquery_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($this->dbh->pop(), 'SELECT DISTINCT e2.id, COUNT(DISTINCT a2.id) AS a2__0 FROM entity e2 LEFT JOIN album a2 ON e2.id = a2.user_id WHERE (e2.type = 0) GROUP BY e2.id ORDER BY a2__0 LIMIT 5');
}
public function testGetLimitSubquerySupportsOrderByWithAggregateValuesAndDescKeyword()
{
$q = new Doctrine_Query();
$q->select('u.name, COUNT(DISTINCT a.id) num_albums');
$q->from('User u, u.Album a');
$q->orderby('num_albums DESC, u.name');
$q->groupby('u.id');
$q->limit(5);
public function testGetLimitSubqueryWithOrderByOnAggregateValuesAndColumns()
$q->execute();
$this->dbh->pop();
$this->assertEqual($this->dbh->pop(), 'SELECT DISTINCT e2.id, COUNT(DISTINCT a2.id) AS a2__0 FROM entity e2 LEFT JOIN album a2 ON e2.id = a2.user_id WHERE (e2.type = 0) GROUP BY e2.id ORDER BY a2__0 DESC, e2.name LIMIT 5');
}
public function testGetLimitSubquerySupportsOrderByWithAggregateValuesAndColumns()
{
$q = new Doctrine_Query();
$q->select('u.name, COUNT(DISTINCT a.id) num_albums');
......
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