fixed joincondition tests.
This commit is contained in:
parent
a6e84aeed1
commit
62860d5191
@ -61,7 +61,6 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
|
|||||||
public function hydrateResultSet($stmt, $tableAliases, $hydrationMode = null)
|
public function hydrateResultSet($stmt, $tableAliases, $hydrationMode = null)
|
||||||
{
|
{
|
||||||
//$s = microtime(true);
|
//$s = microtime(true);
|
||||||
|
|
||||||
$this->_tableAliases = $tableAliases;
|
$this->_tableAliases = $tableAliases;
|
||||||
|
|
||||||
if ($hydrationMode == Doctrine::HYDRATE_NONE) {
|
if ($hydrationMode == Doctrine::HYDRATE_NONE) {
|
||||||
|
@ -1610,8 +1610,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
|
|||||||
$this->_pendingJoinConditions[$componentAlias] = $joinCondition;
|
$this->_pendingJoinConditions[$componentAlias] = $joinCondition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($loadFields) {
|
|
||||||
|
|
||||||
|
if ($loadFields) {
|
||||||
$restoreState = false;
|
$restoreState = false;
|
||||||
// load fields if necessary
|
// load fields if necessary
|
||||||
if ($loadFields && empty($this->_dqlParts['select'])) {
|
if ($loadFields && empty($this->_dqlParts['select'])) {
|
||||||
|
@ -54,20 +54,22 @@ class Doctrine_Query_JoinCondition2_TestCase extends Doctrine_UnitTestCase
|
|||||||
|
|
||||||
$groups->save();
|
$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[0] = $groups[0];
|
||||||
$zYne->Group[1] = $groups[1];
|
$zYne->Group[1] = $groups[1];
|
||||||
$zYne->save();
|
$zYne->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testJoinCondifitionsRawLeftJoins()
|
public function testJoinConditionsRawLeftJoins()
|
||||||
{
|
{
|
||||||
$q = Doctrine_Query::create();
|
$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();
|
$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 = 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();
|
$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 = 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();
|
$rs = $q->execute();
|
||||||
|
|
||||||
@ -146,9 +152,11 @@ class Doctrine_Query_JoinCondition2_TestCase extends Doctrine_UnitTestCase
|
|||||||
{
|
{
|
||||||
$q = new Doctrine_Query($this->connection);
|
$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();
|
$rs = $q->execute();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user