1
0
mirror of synced 2025-01-18 06:21:40 +03:00

fixed joincondition tests.

This commit is contained in:
romanb 2008-01-11 13:53:30 +00:00
parent a6e84aeed1
commit 62860d5191
4 changed files with 24 additions and 17 deletions

View File

@ -61,7 +61,6 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
public function hydrateResultSet($stmt, $tableAliases, $hydrationMode = null)
{
//$s = microtime(true);
$this->_tableAliases = $tableAliases;
if ($hydrationMode == Doctrine::HYDRATE_NONE) {

View File

@ -1610,8 +1610,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
$this->_pendingJoinConditions[$componentAlias] = $joinCondition;
}
}
if ($loadFields) {
if ($loadFields) {
$restoreState = false;
// load fields if necessary
if ($loadFields && empty($this->_dqlParts['select'])) {

View File

@ -54,20 +54,22 @@ class Doctrine_Query_JoinCondition2_TestCase extends Doctrine_UnitTestCase
$groups->save();
$zYne = Doctrine_Query::create()->from('User u')->where('u.id = ?', 4)->fetchOne();
$zYne = Doctrine_Query::create()->from('User u')->where('u.name = ?', 'zYne')->fetchOne();
$zYne->Group[0] = $groups[0];
$zYne->Group[1] = $groups[1];
$zYne->save();
}
public function testJoinCondifitionsRawLeftJoins()
public function testJoinConditionsRawLeftJoins()
{
$q = Doctrine_Query::create();
$q->select('u.id')->from('User u')->leftJoin('u.Group g WITH g.id = 12')->where('u.id = 4');
$q->select('u.id, g.id')->from('User u')->leftJoin('u.Group g WITH g.name = ?', 'Developers')->where('u.name = ?', 'zYne');
$this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id FROM entity e LEFT JOIN groupuser g ON e.id = g.user_id LEFT JOIN entity e2 ON e2.id = g.group_id AND e2.id = 12 WHERE e.id = 4 AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))');
$this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e2.id AS e2__id FROM entity e LEFT JOIN groupuser g"
. " ON e.id = g.user_id LEFT JOIN entity e2 ON e2.id = g.group_id AND e2.name = ?"
. " WHERE e.name = ? AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
$rs = $q->execute();
@ -88,13 +90,15 @@ class Doctrine_Query_JoinCondition2_TestCase extends Doctrine_UnitTestCase
}
public function testJoinCondifitionsArgumentsLeftJoins()
public function testJoinConditionsArgumentsLeftJoins()
{
$q = new Doctrine_Query($this->connection);
$q->select('u.id')->from('User u')->leftJoin('u.Group g WITH g.id = ?', 12)->where('u.id = ?', 4);
$q->select('u.id, g.id')->from('User u')->leftJoin('u.Group g WITH g.id = ?', 12)->where('u.id = ?', 4);
$this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id FROM entity e LEFT JOIN groupuser g ON e.id = g.user_id LEFT JOIN entity e2 ON e2.id = g.group_id AND e2.id = ? WHERE e.id = ? AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))');
$this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e2.id AS e2__id FROM entity e"
. " LEFT JOIN groupuser g ON e.id = g.user_id LEFT JOIN entity e2 ON e2.id = g.group_id"
. " AND e2.id = ? WHERE e.id = ? AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
$rs = $q->execute();
@ -115,13 +119,15 @@ class Doctrine_Query_JoinCondition2_TestCase extends Doctrine_UnitTestCase
}
public function testJoinCondifitionsRawInnerJoins()
public function testJoinConditionsRawInnerJoins()
{
$q = new Doctrine_Query($this->connection);
$q->select('u.id')->from('User u')->innerJoin('u.Group g WITH g.id = 12')->where('u.id = 4');
$q->select('u.id, g.id')->from('User u')->innerJoin('u.Group g WITH g.id = 12')->where('u.id = 4');
$this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id FROM entity e INNER JOIN groupuser g ON e.id = g.user_id INNER JOIN entity e2 ON e2.id = g.group_id AND e2.id = 12 WHERE e.id = 4 AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))');
$this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e2.id AS e2__id FROM entity e"
. " INNER JOIN groupuser g ON e.id = g.user_id INNER JOIN entity e2 ON e2.id = g.group_id"
. " AND e2.id = 12 WHERE e.id = 4 AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
$rs = $q->execute();
@ -146,9 +152,11 @@ class Doctrine_Query_JoinCondition2_TestCase extends Doctrine_UnitTestCase
{
$q = new Doctrine_Query($this->connection);
$q->select('u.id')->from('User u')->innerJoin('u.Group g WITH g.id = ?', 12)->where('u.id = ?', 4);
$q->select('u.id, g.id')->from('User u')->innerJoin('u.Group g WITH g.id = ?', 12)->where('u.id = ?', 4);
$this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id FROM entity e INNER JOIN groupuser g ON e.id = g.user_id INNER JOIN entity e2 ON e2.id = g.group_id AND e2.id = ? WHERE e.id = ? AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))');
$this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e2.id AS e2__id FROM entity e"
. " INNER JOIN groupuser g ON e.id = g.user_id INNER JOIN entity e2 ON e2.id = g.group_id"
. " AND e2.id = ? WHERE e.id = ? AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
$rs = $q->execute();