1
0
mirror of synced 2025-01-30 20:11:49 +03:00

Bug fix : Composite delete with aliases, Bug fix : DQL column aggregation inheritance to ANSI SQL compliant

This commit is contained in:
doctrine 2006-06-18 22:45:54 +00:00
parent 04ca92b094
commit 1fd421d09e
5 changed files with 15 additions and 8 deletions

View File

@ -381,19 +381,24 @@ class Doctrine_Query extends Doctrine_Access {
$str = "";
$c = array();
$index = 0;
foreach($array as $tname => $maps) {
$a = array();
foreach($maps as $map) {
$b = array();
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($a)) $c[] = implode(" || ",$a);
if( ! empty($a)) $c[] = implode(" AND ",$a);
$index++;
}
$str .= implode(" || ",$c);
$str .= implode(" AND ",$c);
$this->addWhere($str);
$this->inheritanceApplied = true;

View File

@ -855,7 +855,7 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
switch($fk->getType()):
case Doctrine_Relation::ONE_COMPOSITE:
case Doctrine_Relation::MANY_COMPOSITE:
$obj = $record->get($fk->getTable()->getComponentName());
$obj = $record->get($record->getTable()->getAlias($fk->getTable()->getComponentName()));
$obj->delete();
break;
endswitch;

View File

@ -86,8 +86,9 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
$this->session->flush();
$users = $query->query("FROM User-b WHERE User.Group.name = 'Action Actors'");
$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->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'");
$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->assertEqual($users->count(),1);
@ -112,7 +113,6 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
$this->assertEqual($count, $this->dbh->count());
}
public function testNestedManyToManyRelations() {
$task = new Task();
$task->name = "T1";
@ -973,5 +973,6 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
//$this->assertTrue(isset($values['max']));
}
}
?>

View File

@ -50,9 +50,10 @@ $test->addTestCase(new Doctrine_PessimisticLockingTestCase());
$test->addTestCase(new Doctrine_ViewTestCase());
$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
$test->addTestCase(new Doctrine_QueryTestCase());
$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());