From a47e5663828d54852ff67251acef8bdab0c331c8 Mon Sep 17 00:00:00 2001 From: Guilherme Blanco Date: Sat, 3 Mar 2012 13:05:11 -0500 Subject: [PATCH] [DDC-1667] Removed implicit obligation to define an Index and UniqueConstraint name. It is optional, but Annotations Driver was broken if not defined. --- .../ORM/Mapping/Driver/AnnotationDriver.php | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index 0b1ec83cb..79b9edc23 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -176,17 +176,25 @@ class AnnotationDriver implements Driver if ($tableAnnot->indexes !== null) { foreach ($tableAnnot->indexes as $indexAnnot) { - $primaryTable['indexes'][$indexAnnot->name] = array( - 'columns' => $indexAnnot->columns - ); + $index = array('columns' => $indexAnnot->columns); + + if ( ! empty($indexAnnot->name)) { + $primaryTable['indexes'][$indexAnnot->name] = $index; + } else { + $primaryTable['indexes'][] = $index; + } } } if ($tableAnnot->uniqueConstraints !== null) { - foreach ($tableAnnot->uniqueConstraints as $uniqueConstraint) { - $primaryTable['uniqueConstraints'][$uniqueConstraint->name] = array( - 'columns' => $uniqueConstraint->columns - ); + foreach ($tableAnnot->uniqueConstraints as $uniqueConstraintAnnot) { + $uniqueConstraint = array('columns' => $uniqueConstraintAnnot->columns); + + if ( ! empty($uniqueConstraintAnnot->name)) { + $primaryTable['uniqueConstraints'][$uniqueConstraintAnnot->name] = $uniqueConstraint; + } else { + $primaryTable['uniqueConstraints'][] = $uniqueConstraint; + } } }