diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php
index 6b391e2b8..29695ba12 100644
--- a/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php
+++ b/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php
@@ -66,13 +66,15 @@ EOT
$exit = 0;
if ($errors) {
foreach ($errors AS $className => $errorMessages) {
- $output->write("[Mapping] FAIL - The entity-class '" . $className . "' mapping is invalid:\n");
+ $output->write("[Mapping] FAIL - The entity-class '" . $className . "' mapping is invalid:\n");
foreach ($errorMessages AS $errorMessage) {
$output->write('* ' . $errorMessage . "\n");
}
$output->write("\n");
}
$exit += 1;
+ } else {
+ $output->write('[Mapping] OK - The mapping files are correct.' . "\n");
}
if (!$validator->schemaInSyncWithMetadata()) {
diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php
index aae4d37d8..0a13aa898 100644
--- a/lib/Doctrine/ORM/Tools/SchemaValidator.php
+++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php
@@ -130,47 +130,53 @@ class SchemaValidator
}
}
- if ($assoc instanceof ManyToManyMapping && $assoc->isOwningSide) {
- foreach ($assoc->joinTable['joinColumns'] AS $joinColumn) {
- if (!isset($class->fieldNames[$joinColumn['referencedColumnName']])) {
- $ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' does not " .
- "have a corresponding field with this column name on the class '" . $class->name . "'.";
- break;
- }
+ if ($assoc->isOwningSide) {
+ if ($assoc instanceof ManyToManyMapping) {
+ foreach ($assoc->joinTable['joinColumns'] AS $joinColumn) {
+ if (!isset($class->fieldNames[$joinColumn['referencedColumnName']])) {
+ $ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' does not " .
+ "have a corresponding field with this column name on the class '" . $class->name . "'.";
+ break;
+ }
- $fieldName = $class->fieldNames[$joinColumn['referencedColumnName']];
- if (!in_array($fieldName, $class->identifier)) {
- $ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' " .
- "has to be a primary key column.";
- }
- }
- foreach ($assoc->joinTable['inverseJoinColumns'] AS $inverseJoinColumn) {
- if (!isset($class->fieldNames[$inverseJoinColumn['referencedColumnName']])) {
- $ce[] = "The referenced column name '" . $inverseJoinColumn['referencedColumnName'] . "' does not " .
- "have a corresponding field with this column name on the class '" . $class->name . "'.";
- break;
- }
-
- $fieldName = $class->fieldNames[$inverseJoinColumn['referencedColumnName']];
- if (!in_array($fieldName, $class->identifier)) {
- $ce[] = "The referenced column name '" . $inverseJoinColumn['referencedColumnName'] . "' " .
- "has to be a primary key column.";
- }
- }
- } else if ($assoc instanceof OneToOneMapping) {
- foreach ($assoc->joinColumns AS $joinColumn) {
- if (!isset($class->fieldNames[$joinColumn['referencedColumnName']])) {
- $ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' does not " .
- "have a corresponding field with this column name on the class '" . $class->name . "'.";
- break;
- }
-
- $fieldName = $class->fieldNames[$joinColumn['referencedColumnName']];
- if (!in_array($fieldName, $class->identifier)) {
- $ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' " .
- "has to be a primary key column.";
+ $fieldName = $class->fieldNames[$joinColumn['referencedColumnName']];
+ if (!in_array($fieldName, $class->identifier)) {
+ $ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' " .
+ "has to be a primary key column.";
+ }
+ }
+ foreach ($assoc->joinTable['inverseJoinColumns'] AS $inverseJoinColumn) {
+ $targetClass = $cmf->getMetadataFor($assoc->targetEntityName);
+ if (!isset($targetClass->fieldNames[$inverseJoinColumn['referencedColumnName']])) {
+ $ce[] = "The inverse referenced column name '" . $inverseJoinColumn['referencedColumnName'] . "' does not " .
+ "have a corresponding field with this column name on the class '" . $targetClass->name . "'.";
+ break;
+ }
+
+ $fieldName = $targetClass->fieldNames[$inverseJoinColumn['referencedColumnName']];
+ if (!in_array($fieldName, $targetClass->identifier)) {
+ $ce[] = "The referenced column name '" . $inverseJoinColumn['referencedColumnName'] . "' " .
+ "has to be a primary key column.";
+ }
+ }
+ } else if ($assoc instanceof OneToOneMapping) {
+ foreach ($assoc->joinColumns AS $joinColumn) {
+ $targetClass = $cmf->getMetadataFor($assoc->targetEntityName);
+ if (!isset($targetClass->fieldNames[$joinColumn['referencedColumnName']])) {
+ $ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' does not " .
+ "have a corresponding field with this column name on the class '" . $targetClass->name . "'.";
+ break;
+ }
+
+ $fieldName = $targetClass->fieldNames[$joinColumn['referencedColumnName']];
+ if (!in_array($fieldName, $targetClass->identifier)) {
+ $ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' " .
+ "has to be a primary key column.";
+ }
}
}
+ } else {
+
}
if ($ce) {