From dd71ec4b063db77a1cf9b4b3944cdb8c071e1c19 Mon Sep 17 00:00:00 2001 From: "Jonathan.Wage" Date: Tue, 9 Oct 2007 01:34:36 +0000 Subject: [PATCH] Fixes for composite keys giving error. --- lib/Doctrine/Data/Import.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/Data/Import.php b/lib/Doctrine/Data/Import.php index 127dd9268..4a18efc9d 100644 --- a/lib/Doctrine/Data/Import.php +++ b/lib/Doctrine/Data/Import.php @@ -121,7 +121,14 @@ class Doctrine_Data_Import extends Doctrine_Data } } - $obj->save(); + $identifier = is_array($obj->getTable()->getIdentifier()) ? $obj->getTable()->getIdentifier():array($obj->getTable()->getIdentifier()); + + // We only want to save the record if it is a single primary key. + // We can't save the composite primary key because neither of the foreign keys have been created yet + // We will satisfy these relationships later and save the record. + if (count($identifier) === 1) { + $obj->save(); + } $primaryKeys[$rowKey] = $obj->identifier(); }