From 1e1090700c3f8a059b44aa26895e27c20cbca000 Mon Sep 17 00:00:00 2001 From: "Jonathan.Wage" Date: Thu, 20 Sep 2007 19:18:05 +0000 Subject: [PATCH] Fixes to make schema importing work. --- lib/Doctrine/Import/Schema.php | 10 ++++++++++ tests/schema.yml | 20 +++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/Import/Schema.php b/lib/Doctrine/Import/Schema.php index 623b7e8b4..6d379da21 100644 --- a/lib/Doctrine/Import/Schema.php +++ b/lib/Doctrine/Import/Schema.php @@ -106,6 +106,7 @@ abstract class Doctrine_Import_Schema foreach ($array as $name => $properties) { $className = $properties['className']; $relations = $properties['relations']; + $columns = $properties['columns']; foreach ($relations as $alias => $relation) { $class = isset($relation['class']) ? $relation['class']:$alias; @@ -113,10 +114,17 @@ abstract class Doctrine_Import_Schema $relation['alias'] = $alias; $relation['class'] = $class; + if (isset($relation['type']) && $relation['type']) { + $relation['type'] = $relation['type'] === 'one' ? Doctrine_Relation::ONE:Doctrine_Relation::MANY; + } else { + $relation['type'] = Doctrine_Relation::ONE; + } + $this->relations[$className][$class] = $relation; } } + /* // Fix the other end of the relations foreach($this->relations as $className => $relations) { foreach ($relations AS $alias => $relation) { @@ -125,9 +133,11 @@ abstract class Doctrine_Import_Schema $newRelation['local'] = $relation['foreign']; $newRelation['class'] = $className; $newRelation['alias'] = $className; + $newRelation['type'] = $relation['type'] === Doctrine_Relation::ONE ? Doctrine_Relation::MANY:Doctrine_Relation::ONE; $this->relations[$relation['class']][$className] = $newRelation; } } + */ } } \ No newline at end of file diff --git a/tests/schema.yml b/tests/schema.yml index e86630ee1..2a0654a81 100644 --- a/tests/schema.yml +++ b/tests/schema.yml @@ -9,6 +9,13 @@ User: username: type: string length: 11 + relations: + Groups: + class: Group + refClass: UserGroup + local: user_id + foreign: group_id + type: many UserGroup: tableName: user_group @@ -17,16 +24,20 @@ UserGroup: user_id: type: int length: 11 + primary: true group_id: type: int length: 11 + primary: true relations: User: foreign: id local: user_id + type: one Group: foreign: id local: group_id + type: one Group: tableName: group @@ -37,4 +48,11 @@ Group: autoincrement: true name: type: string - length: 255 \ No newline at end of file + length: 255 + relations: + Users: + class: User + refClass: UserGroup + local: group_id + foreign: user_id + type: many \ No newline at end of file