From 0a5a3bcdfeadf8369d1f3b8c7e62fc05306e10ff Mon Sep 17 00:00:00 2001 From: zYne Date: Sun, 7 Jan 2007 18:10:51 +0000 Subject: [PATCH] Aggregate relations now treated the same ways as composite relations on save operations --- lib/Doctrine/Connection/UnitOfWork.php | 27 +++++++++++++------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/Doctrine/Connection/UnitOfWork.php b/lib/Doctrine/Connection/UnitOfWork.php index 8fd580ada..f66c60e04 100644 --- a/lib/Doctrine/Connection/UnitOfWork.php +++ b/lib/Doctrine/Connection/UnitOfWork.php @@ -144,25 +144,24 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen $fk = $record->getTable()->getRelation($k); if ($fk instanceof Doctrine_Relation_ForeignKey || $fk instanceof Doctrine_Relation_LocalKey) { - if ($fk->isComposite()) { - $local = $fk->getLocal(); - $foreign = $fk->getForeign(); + $local = $fk->getLocal(); + $foreign = $fk->getForeign(); - if ($record->getTable()->hasPrimaryKey($fk->getLocal())) { - if ( ! $record->exists()) { - $saveLater[$k] = $fk; - } else { - $v->save(); - } + if ($record->getTable()->hasPrimaryKey($fk->getLocal())) { + if ( ! $record->exists()) { + $saveLater[$k] = $fk; } else { - // ONE-TO-ONE relationship - $obj = $record->get($fk->getTable()->getComponentName()); + $v->save(); + } + } else { + // ONE-TO-ONE relationship + $obj = $record->get($fk->getAlias()); - if ($obj->getState() != Doctrine_Record::STATE_TCLEAN) { - $obj->save(); - } + if ($obj->getState() != Doctrine_Record::STATE_TCLEAN) { + $obj->save(); } } + } elseif ($fk instanceof Doctrine_Relation_Association) { $v->save(); }