From 27356225dd938d108f4158c56e711b4bfefffc13 Mon Sep 17 00:00:00 2001 From: jwage Date: Mon, 24 Aug 2009 18:33:59 +0000 Subject: [PATCH] [2.0] Updating YAML driver with missing elements from XML driver. --- lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php | 5 ++++- .../ORM/Mapping/Driver/YamlDriver.php | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php index fc3a7942f..1faf760da 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php @@ -67,7 +67,7 @@ class XmlDriver extends AbstractFileDriver // Evaluate if (isset($xmlRoot->{'unique-constraints'})) { foreach ($xmlRoot->{'unique-constraints'}->{'unique-constraint'} as $unique) { - $metadata->primaryTable['uniqueConstraints'][] = explode(',', $index['columns']); + $metadata->primaryTable['uniqueConstraints'][] = explode(',', $unique['columns']); } } @@ -173,6 +173,9 @@ class XmlDriver extends AbstractFileDriver $joinColumns[] = $this->_getJoinColumnMapping($manyToOneElement->{'join-column'}); } else if (isset($manyToOneElement->{'join-columns'})) { foreach ($manyToOneElement->{'join-columns'}->{'join-column'} as $joinColumnElement) { + if (!isset($joinColumnElement['name'])) { + $joinColumnElement['name'] = $name; + } $joinColumns[] = $this->_getJoinColumnMapping($joinColumnElement); } } else { diff --git a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php index 1de744ad5..ae90b57c8 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php @@ -57,6 +57,21 @@ class YamlDriver extends AbstractFileDriver $metadata->setInheritanceType($element['inheritanceType']); } + // Evaluate indexes + if (isset($element['indexes'])) { + foreach ($element['indexes'] as $index) { + $metadata->primaryTable['indexes'][$index['name']] = array('fields' => + explode(',', $index['columns'])); + } + } + + // Evaluate uniqueConstraints + if (isset($element['uniqueConstraints'])) { + foreach ($element['uniqueConstraints'] as $unique) { + $metadata->primaryTable['uniqueConstraints'][] = explode(',', $unique['columns']); + } + } + // Evaluate fields if (isset($element['fields'])) { foreach ($element['fields'] as $name => $fieldMapping) { @@ -70,6 +85,12 @@ class YamlDriver extends AbstractFileDriver if (isset($fieldMapping['length'])) { $mapping['length'] = $fieldMapping['length']; } + if (isset($fieldMapping['precision'])) { + $mapping['precision'] = $fieldMapping['precision']; + } + if (isset($fieldMapping['scale'])) { + $mapping['scale'] = $fieldMapping['scale']; + } if (isset($fieldMapping['version']) && $fieldMapping['version']) { $metadata->setVersionMapping($mapping); }