Commit 6c42ff92 authored by zYne's avatar zYne

--no commit message

--no commit message
parent e3cc0351
...@@ -68,8 +68,9 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -68,8 +68,9 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
$q->select('u.id, p.*')->from('User u, u.Phonenumber p')->limit(5); $q->select('u.id, p.*')->from('User u, u.Phonenumber p')->limit(5);
$sql = $q->getQuery(); $sql = $q->getQuery();
$this->assertEqual($q->getQuery(), $this->assertEqual($q->getQuery(),
'SELECT e.id AS e__id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 WHERE (e2.type = 0) LIMIT 5) AND (e.type = 0)'); 'SELECT e.id AS e__id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 LEFT JOIN phonenumber p2 ON e2.id = p2.entity_id WHERE (e2.type = 0) LIMIT 5) AND (e.type = 0)');
$users = $q->execute(); $users = $q->execute();
$count = $this->dbh->count(); $count = $this->dbh->count();
...@@ -165,7 +166,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -165,7 +166,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($count, $this->dbh->count()); $this->assertEqual($count, $this->dbh->count());
$this->assertEqual($q->getQuery(), $this->assertEqual($q->getQuery(),
'SELECT e.id AS e__id, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 WHERE e2.name = ? AND (e2.type = 0) LIMIT 5) AND e.name = ? AND (e.type = 0)'); 'SELECT e.id AS e__id, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 LEFT JOIN phonenumber p2 ON e2.id = p2.entity_id WHERE e2.name = ? AND (e2.type = 0) LIMIT 5) AND e.name = ? AND (e.type = 0)');
$q = new Doctrine_Query(); $q = new Doctrine_Query();
$q->select('u.id, p.id')->from('User u LEFT JOIN u.Phonenumber p'); $q->select('u.id, p.id')->from('User u LEFT JOIN u.Phonenumber p');
...@@ -181,7 +182,10 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -181,7 +182,10 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($count, $this->dbh->count()); $this->assertEqual($count, $this->dbh->count());
$this->assertEqual($q->getQuery(), $this->assertEqual($q->getQuery(),
"SELECT e.id AS e__id, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 WHERE (e2.name LIKE ? OR e2.name LIKE ?) AND (e2.type = 0) LIMIT 5) AND (e.name LIKE ? OR e.name LIKE ?) AND (e.type = 0)"); "SELECT e.id AS e__id, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON"
. " e.id = p.entity_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 LEFT JOIN phonenumber p2"
. " ON e2.id = p2.entity_id WHERE (e2.name LIKE ? OR e2.name LIKE ?) AND (e2.type = 0) LIMIT 5) AND "
. "(e.name LIKE ? OR e.name LIKE ?) AND (e.type = 0)");
} }
public function testConnectionFlushing() public function testConnectionFlushing()
...@@ -278,7 +282,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -278,7 +282,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
$this->connection->flush(); $this->connection->flush();
$q = new Doctrine_Query(); $q = new Doctrine_Query();
$q->from("Photo")->where("Photo.Tag.id = ?")->orderby("Photo.id DESC")->limit(100); $q->from('Photo')->where('Photo.Tag.id = ?')->orderby('Photo.id DESC')->limit(100);
$photos = $q->execute(array(1)); $photos = $q->execute(array(1));
$this->assertEqual($photos->count(), 3); $this->assertEqual($photos->count(), 3);
...@@ -286,5 +290,15 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -286,5 +290,15 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
"SELECT p.id AS p__id, p.name AS p__name FROM photo p LEFT JOIN phototag p2 ON p.id = p2.photo_id LEFT JOIN tag t ON t.id = p2.tag_id WHERE p.id IN (SELECT DISTINCT p3.id FROM photo p3 LEFT JOIN phototag p4 ON p3.id = p4.photo_id LEFT JOIN tag t2 ON t2.id = p4.tag_id WHERE t2.id = ? ORDER BY p3.id DESC LIMIT 100) AND t.id = ? ORDER BY p.id DESC"); "SELECT p.id AS p__id, p.name AS p__name FROM photo p LEFT JOIN phototag p2 ON p.id = p2.photo_id LEFT JOIN tag t ON t.id = p2.tag_id WHERE p.id IN (SELECT DISTINCT p3.id FROM photo p3 LEFT JOIN phototag p4 ON p3.id = p4.photo_id LEFT JOIN tag t2 ON t2.id = p4.tag_id WHERE t2.id = ? ORDER BY p3.id DESC LIMIT 100) AND t.id = ? ORDER BY p.id DESC");
} }
public function testLimitNoticesOrderbyJoins()
{
$q = new Doctrine_Query();
$q->from('Photo p')
->leftJoin('p.Tag t')
->orderby('t.id DESC')->limit(10);
$this->assertEqual($q->getSql(), "SELECT p.id AS p__id, p.name AS p__name, t.id AS t__id, t.tag AS t__tag FROM photo p LEFT JOIN phototag p2 ON p.id = p2.photo_id LEFT JOIN tag t ON t.id = p2.tag_id WHERE p.id IN (SELECT DISTINCT p3.id FROM photo p3 LEFT JOIN phototag p4 ON p3.id = p4.photo_id LEFT JOIN tag t2 ON t2.id = p4.tag_id ORDER BY t2.id DESC LIMIT 10) ORDER BY t.id DESC");
}
} }
?> ?>
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