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)
|
||||
{
|
||||
//$s = microtime(true);
|
||||
|
||||
$this->_tableAliases = $tableAliases;
|
||||
|
||||
if ($hydrationMode == Doctrine::HYDRATE_NONE) {
|
||||
@ -284,7 +283,7 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
|
||||
protected function _gatherRowData(&$data, &$cache, &$id, &$nonemptyComponents)
|
||||
{
|
||||
$rowData = array();
|
||||
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
// Parse each column name only once. Cache the results.
|
||||
if ( ! isset($cache[$key])) {
|
||||
|
@ -481,7 +481,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
|
||||
public function processPendingFields($componentAlias)
|
||||
{
|
||||
$tableAlias = $this->getTableAlias($componentAlias);
|
||||
$table = $this->_queryComponents[$componentAlias]['table'];
|
||||
$table = $this->_queryComponents[$componentAlias]['table'];
|
||||
|
||||
if ( ! isset($this->_pendingFields[$componentAlias])) {
|
||||
return;
|
||||
@ -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'])) {
|
||||
|
@ -910,7 +910,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
|
||||
* @return Doctrine_Record
|
||||
*/
|
||||
public function set($fieldName, $value, $load = true)
|
||||
{
|
||||
{
|
||||
if (isset($this->_data[$fieldName])) {
|
||||
if ($value instanceof Doctrine_Record) {
|
||||
$type = $this->_table->getTypeOf($fieldName);
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user