Skip to content

Instantly share code, notes, and snippets.

@kdambekalns
Created March 14, 2012 11:17
Show Gist options
  • Save kdambekalns/2035839 to your computer and use it in GitHub Desktop.
Save kdambekalns/2035839 to your computer and use it in GitHub Desktop.
diff --git a/Classes/Persistence/Doctrine/Mapping/Driver/Flow3AnnotationDriver.php b/Classes/Persistence/Doctrine/Mapping/Driver/Flow3AnnotationDriver.php
index f91669a..cea545a 100644
--- a/Classes/Persistence/Doctrine/Mapping/Driver/Flow3AnnotationDriver.php
+++ b/Classes/Persistence/Doctrine/Mapping/Driver/Flow3AnnotationDriver.php
@@ -144,16 +144,10 @@ class Flow3AnnotationDriver implements \Doctrine\ORM\Mapping\Driver\Driver, \TYP
}
}
}
-
if (!isset($primaryTable['name'])) {
$className = $classSchema->getClassName();
$primaryTable['name'] = $this->inferTableNameFromClassName($className);
-# $idProperties = array_keys($classSchema->getIdentityProperties());
-# $primaryTable['uniqueConstraints']['flow3_identifier'] = array(
-# 'columns' => $idProperties
-# );
}
- $metadata->setPrimaryTable($primaryTable);
// Evaluate NamedQueries annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\NamedQueries'])) {
@@ -224,6 +218,15 @@ class Flow3AnnotationDriver implements \Doctrine\ORM\Mapping\Driver\Driver, \TYP
// Evaluate annotations on properties/fields
$this->evaluatePropertyAnnotations($metadata);
+ // build unique index for table
+ if (!isset($primaryTable['uniqueConstraints'])) {
+ $idProperties = array_keys($classSchema->getIdentityProperties());
+ foreach ($idProperties as $idProperty) {
+ $primaryTable['uniqueConstraints']['flow3_identity']['columns'][] = isset($metadata->columnNames[$idProperty]) ? $metadata->columnNames[$idProperty] : strtolower($idProperty);
+ }
+ }
+ $metadata->setPrimaryTable($primaryTable);
+
// Evaluate @HasLifecycleCallbacks annotation
$this->evaluateLifeCycleAnnotations($classAnnotations, $class, $metadata);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment