1
0
mirror of synced 2024-12-14 07:06:04 +03:00

Fix bug with updating assoc-id entities

This commit is contained in:
Benjamin Eberlei 2010-08-15 14:40:06 +02:00
parent e45c52b024
commit 5799e391c6
2 changed files with 55 additions and 6 deletions

View File

@ -303,9 +303,16 @@ class BasicEntityPersister
$where = array();
$id = $this->_em->getUnitOfWork()->getEntityIdentifier($entity);
foreach ($this->_class->identifier as $idField) {
$where[] = $this->_class->getQuotedColumnName($idField, $this->_platform);
$params[] = $id[$idField];
$types[] = $this->_class->fieldMappings[$idField]['type'];
if (isset($this->_class->associationMappings[$idField])) {
$targetMapping = $this->_em->getClassMetadata($this->_class->associationMappings[$idField]['targetEntity']);
$where[] = $this->_class->associationMappings[$idField]['joinColumns'][0]['name'];
$params[] = $id[$idField];
$types[] = $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type'];
} else {
$where[] = $this->_class->getQuotedColumnName($idField, $this->_platform);
$params[] = $id[$idField];
$types[] = $this->_class->fieldMappings[$idField]['type'];
}
}
if ($versioned) {

View File

@ -74,10 +74,19 @@ class DDC117Test extends \Doctrine\Tests\OrmFunctionalTestCase
$dql = "SELECT r, s FROM ".__NAMESPACE__."\DDC117Reference r JOIN r.source s WHERE s.title = ?1";
$dqlRef = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getSingleResult();
$this->assertType(__NAMESPACE__."\DDC117Reference", $mapRef);
$this->assertType(__NAMESPACE__."\DDC117Article", $mapRef->target());
$this->assertType(__NAMESPACE__."\DDC117Article", $mapRef->source());
$this->assertType(__NAMESPACE__."\DDC117Reference", $dqlRef);
$this->assertType(__NAMESPACE__."\DDC117Article", $dqlRef->target());
$this->assertType(__NAMESPACE__."\DDC117Article", $dqlRef->source());
$this->assertSame($dqlRef, $this->_em->find(__NAMESPACE__."\DDC117Reference", $idCriteria));
$dqlRef->setDescription("New Description!!");
$this->_em->flush();
$this->_em->clear();
$dql = "SELECT r, s FROM ".__NAMESPACE__."\DDC117Reference r JOIN r.source s WHERE s.title = ?1";
$dqlRef = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getSingleResult();
$this->assertEquals('New Description!!', $dqlRef->getDescription());
}
/**
@ -187,6 +196,14 @@ class DDC117Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->articleDetails = new DDC117ArticleDetails($this->article1, "Very long text");
$this->_em->persist($this->articleDetails);
$this->_em->flush();
$this->articleDetails->update("not so very long text!");
$this->_em->flush();
$this->_em->clear();
/* @var $article DDC117Article */
$article = $this->_em->find(get_class($this->article1), $this->article1->id());
$this->assertEquals('not so very long text!', $article->getText());
}
}
@ -246,6 +263,11 @@ class DDC117Article
{
$this->translations[] = new DDC117Translation($this, $language, $title);
}
public function getText()
{
return $this->details->getText();
}
}
/**
@ -266,8 +288,18 @@ class DDC117ArticleDetails
$this->article = $article;
$article->setDetails($this);
$this->update($text);
}
public function update($text)
{
$this->text = $text;
}
public function getText()
{
return $this->text;
}
}
/**
@ -315,6 +347,16 @@ class DDC117Reference
{
return $this->target;
}
public function setDescription($desc)
{
$this->description = $desc;
}
public function getDescription()
{
return $this->description;
}
}
/**