Bug fix : Composite delete with aliases, Bug fix : DQL column aggregation inheritance to ANSI SQL compliant
This commit is contained in:
parent
04ca92b094
commit
1fd421d09e
@ -381,19 +381,24 @@ class Doctrine_Query extends Doctrine_Access {
|
|||||||
$str = "";
|
$str = "";
|
||||||
$c = array();
|
$c = array();
|
||||||
|
|
||||||
|
$index = 0;
|
||||||
foreach($array as $tname => $maps) {
|
foreach($array as $tname => $maps) {
|
||||||
$a = array();
|
$a = array();
|
||||||
foreach($maps as $map) {
|
foreach($maps as $map) {
|
||||||
$b = array();
|
$b = array();
|
||||||
foreach($map as $field => $value) {
|
foreach($map as $field => $value) {
|
||||||
$b[] = $tname.".$field = $value"; //OR $tname.$field IS NULL";
|
if($index > 0)
|
||||||
|
$b[] = "(".$tname.".$field = $value OR $tname.$field IS NULL)";
|
||||||
|
else
|
||||||
|
$b[] = $tname.".$field = $value";
|
||||||
}
|
}
|
||||||
if( ! empty($b)) $a[] = implode(" AND ",$b);
|
if( ! empty($b)) $a[] = implode(" AND ",$b);
|
||||||
}
|
}
|
||||||
if( ! empty($a)) $c[] = implode(" || ",$a);
|
if( ! empty($a)) $c[] = implode(" AND ",$a);
|
||||||
|
$index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$str .= implode(" || ",$c);
|
$str .= implode(" AND ",$c);
|
||||||
|
|
||||||
$this->addWhere($str);
|
$this->addWhere($str);
|
||||||
$this->inheritanceApplied = true;
|
$this->inheritanceApplied = true;
|
||||||
|
@ -855,7 +855,7 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
|
|||||||
switch($fk->getType()):
|
switch($fk->getType()):
|
||||||
case Doctrine_Relation::ONE_COMPOSITE:
|
case Doctrine_Relation::ONE_COMPOSITE:
|
||||||
case Doctrine_Relation::MANY_COMPOSITE:
|
case Doctrine_Relation::MANY_COMPOSITE:
|
||||||
$obj = $record->get($fk->getTable()->getComponentName());
|
$obj = $record->get($record->getTable()->getAlias($fk->getTable()->getComponentName()));
|
||||||
$obj->delete();
|
$obj->delete();
|
||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
|
@ -86,8 +86,9 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
|||||||
$this->session->flush();
|
$this->session->flush();
|
||||||
|
|
||||||
$users = $query->query("FROM User-b WHERE User.Group.name = 'Action Actors'");
|
$users = $query->query("FROM User-b WHERE User.Group.name = 'Action Actors'");
|
||||||
|
|
||||||
$this->assertEqual(trim($query->getQuery()),
|
$this->assertEqual(trim($query->getQuery()),
|
||||||
"SELECT entity.id AS User__id FROM entity LEFT JOIN groupuser ON entity.id = groupuser.user_id LEFT JOIN entity AS entity2 ON entity2.id = groupuser.group_id WHERE (entity2.name = 'Action Actors') AND (entity.type = 0 || entity2.type = 1)");
|
"SELECT entity.id AS User__id FROM entity LEFT JOIN groupuser ON entity.id = groupuser.user_id LEFT JOIN entity AS entity2 ON entity2.id = groupuser.group_id WHERE (entity2.name = 'Action Actors') AND (entity.type = 0 AND (entity2.type = 1 OR entity2.type IS NULL))");
|
||||||
$this->assertTrue($users instanceof Doctrine_Collection);
|
$this->assertTrue($users instanceof Doctrine_Collection);
|
||||||
$this->assertEqual($users->count(),1);
|
$this->assertEqual($users->count(),1);
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
|||||||
$users = $query->query("FROM User-b WHERE User.Group.Phonenumber.phonenumber LIKE '123 123'");
|
$users = $query->query("FROM User-b WHERE User.Group.Phonenumber.phonenumber LIKE '123 123'");
|
||||||
|
|
||||||
$this->assertEqual(trim($query->getQuery()),
|
$this->assertEqual(trim($query->getQuery()),
|
||||||
"SELECT entity.id AS User__id FROM entity LEFT JOIN groupuser ON entity.id = groupuser.user_id LEFT JOIN entity AS entity2 ON entity2.id = groupuser.group_id LEFT JOIN phonenumber ON entity2.id = phonenumber.entity_id WHERE (phonenumber.phonenumber LIKE '123 123') AND (entity.type = 0 || entity2.type = 1)");
|
"SELECT entity.id AS User__id FROM entity LEFT JOIN groupuser ON entity.id = groupuser.user_id LEFT JOIN entity AS entity2 ON entity2.id = groupuser.group_id LEFT JOIN phonenumber ON entity2.id = phonenumber.entity_id WHERE (phonenumber.phonenumber LIKE '123 123') AND (entity.type = 0 AND (entity2.type = 1 OR entity2.type IS NULL))");
|
||||||
$this->assertTrue($users instanceof Doctrine_Collection);
|
$this->assertTrue($users instanceof Doctrine_Collection);
|
||||||
$this->assertEqual($users->count(),1);
|
$this->assertEqual($users->count(),1);
|
||||||
|
|
||||||
@ -112,7 +113,6 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
|||||||
$this->assertEqual($count, $this->dbh->count());
|
$this->assertEqual($count, $this->dbh->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testNestedManyToManyRelations() {
|
public function testNestedManyToManyRelations() {
|
||||||
$task = new Task();
|
$task = new Task();
|
||||||
$task->name = "T1";
|
$task->name = "T1";
|
||||||
@ -973,5 +973,6 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
|||||||
//$this->assertTrue(isset($values['max']));
|
//$this->assertTrue(isset($values['max']));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -50,9 +50,10 @@ $test->addTestCase(new Doctrine_PessimisticLockingTestCase());
|
|||||||
|
|
||||||
$test->addTestCase(new Doctrine_ViewTestCase());
|
$test->addTestCase(new Doctrine_ViewTestCase());
|
||||||
|
|
||||||
|
$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
|
||||||
|
|
||||||
$test->addTestCase(new Doctrine_QueryTestCase());
|
$test->addTestCase(new Doctrine_QueryTestCase());
|
||||||
|
|
||||||
$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
|
|
||||||
|
|
||||||
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
|
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
|
||||||
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
|
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user