From e7f64afb24fa6c61658a81133e188016df7eb6b2 Mon Sep 17 00:00:00 2001 From: phuson Date: Sat, 27 Oct 2007 11:09:13 +0000 Subject: [PATCH] Check for duplicates between custom alias relations and auto-generated relations. --- lib/Doctrine/Import/Schema.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/Import/Schema.php b/lib/Doctrine/Import/Schema.php index f5ccb5a05..12850671a 100644 --- a/lib/Doctrine/Import/Schema.php +++ b/lib/Doctrine/Import/Schema.php @@ -210,7 +210,19 @@ class Doctrine_Import_Schema */ public function getRelations($properties) { - return isset($this->_relations[$properties['className']]) ? $this->_relations[$properties['className']]:array(); + $all_relations = isset($this->_relations[$properties['className']]) ? $this->_relations[$properties['className']]:array(); + + // This is for checking for duplicates between alias-relations and a auto-generated relations to ensure the result set of unique relations + $exist_relations = array(); + $unique_relations = array(); + foreach ($all_relations as $relation) { + if (!in_array($relation['class'], $exist_relations)) { + $exist_relations[] = $relation['class']; + $unique_relations = array_merge($unique_relations, array($relation['alias'] => $relation)); + } + } + + return $unique_relations; } /**