Commit bf4429d6 authored by zYne's avatar zYne

--no commit message

--no commit message
parent b116d3ad
...@@ -47,6 +47,7 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase ...@@ -47,6 +47,7 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($users->count(), 7); $this->assertEqual($users->count(), 7);
$this->assertEqual($users[0]->name, 'Arnold Schwarzenegger'); $this->assertEqual($users[0]->name, 'Arnold Schwarzenegger');
} }
public function testSubqueryAllowsSelectingOfAnyField() public function testSubqueryAllowsSelectingOfAnyField()
{ {
$q = new Doctrine_Query(); $q = new Doctrine_Query();
...@@ -85,26 +86,27 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase ...@@ -85,26 +86,27 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase
} }
public function testGetLimitSubqueryOrderBy() public function testGetLimitSubqueryOrderBy2()
{ {
$query = new Doctrine_Query(); $q = new Doctrine_Query();
$query->select('u.*, COUNT(DISTINCT a.id) num_albums'); $q->select('u.name, COUNT(DISTINCT a.id) num_albums');
$query->from('User u, u.Album a'); $q->from('User u, u.Album a');
$query->orderby('num_albums'); $q->orderby('num_albums');
$q->groupby('u.id');
try { try {
// this causes getLimitSubquery() to be used, and it fails // this causes getLimitSubquery() to be used, and it fails
$query->limit(5); $q->limit(5);
$users = $query->execute(); $users = $q->execute();
$count = $users->count(); $count = $users->count();
} catch (Doctrine_Exception $e) { } catch (Doctrine_Exception $e) {
$this->fail(); $this->fail();
} }
$this->assertEqual($count, 1); $this->assertEqual($q->getSql(), 'SELECT e.id AS e__id, e.name AS e__name, COUNT(DISTINCT a.id) AS a__0 FROM entity e LEFT JOIN album a ON e.id = a.user_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 LEFT JOIN album a2 ON e2.id = a2.user_id WHERE (e2.type = 0) GROUP BY e2.id ORDER BY a__0 LIMIT 5) AND (e.type = 0) GROUP BY e.id ORDER BY a__0');
} }
} }
?> ?>
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