1
0
mirror of synced 2025-01-07 09:37:11 +03:00

DDC-515 - Fixed some issues with Schema Validation Command

This commit is contained in:
Benjamin Eberlei 2010-05-12 23:41:28 +02:00
parent 57cd2e01bb
commit d9969901e1
2 changed files with 47 additions and 39 deletions

View File

@ -73,6 +73,8 @@ EOT
$output->write("\n"); $output->write("\n");
} }
$exit += 1; $exit += 1;
} else {
$output->write('<info>[Mapping] OK - The mapping files are correct.</info>' . "\n");
} }
if (!$validator->schemaInSyncWithMetadata()) { if (!$validator->schemaInSyncWithMetadata()) {

View File

@ -130,7 +130,8 @@ class SchemaValidator
} }
} }
if ($assoc instanceof ManyToManyMapping && $assoc->isOwningSide) { if ($assoc->isOwningSide) {
if ($assoc instanceof ManyToManyMapping) {
foreach ($assoc->joinTable['joinColumns'] AS $joinColumn) { foreach ($assoc->joinTable['joinColumns'] AS $joinColumn) {
if (!isset($class->fieldNames[$joinColumn['referencedColumnName']])) { if (!isset($class->fieldNames[$joinColumn['referencedColumnName']])) {
$ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' does not " . $ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' does not " .
@ -145,33 +146,38 @@ class SchemaValidator
} }
} }
foreach ($assoc->joinTable['inverseJoinColumns'] AS $inverseJoinColumn) { foreach ($assoc->joinTable['inverseJoinColumns'] AS $inverseJoinColumn) {
if (!isset($class->fieldNames[$inverseJoinColumn['referencedColumnName']])) { $targetClass = $cmf->getMetadataFor($assoc->targetEntityName);
$ce[] = "The referenced column name '" . $inverseJoinColumn['referencedColumnName'] . "' does not " . if (!isset($targetClass->fieldNames[$inverseJoinColumn['referencedColumnName']])) {
"have a corresponding field with this column name on the class '" . $class->name . "'."; $ce[] = "The inverse referenced column name '" . $inverseJoinColumn['referencedColumnName'] . "' does not " .
"have a corresponding field with this column name on the class '" . $targetClass->name . "'.";
break; break;
} }
$fieldName = $class->fieldNames[$inverseJoinColumn['referencedColumnName']]; $fieldName = $targetClass->fieldNames[$inverseJoinColumn['referencedColumnName']];
if (!in_array($fieldName, $class->identifier)) { if (!in_array($fieldName, $targetClass->identifier)) {
$ce[] = "The referenced column name '" . $inverseJoinColumn['referencedColumnName'] . "' " . $ce[] = "The referenced column name '" . $inverseJoinColumn['referencedColumnName'] . "' " .
"has to be a primary key column."; "has to be a primary key column.";
} }
} }
} else if ($assoc instanceof OneToOneMapping) { } else if ($assoc instanceof OneToOneMapping) {
foreach ($assoc->joinColumns AS $joinColumn) { foreach ($assoc->joinColumns AS $joinColumn) {
if (!isset($class->fieldNames[$joinColumn['referencedColumnName']])) { $targetClass = $cmf->getMetadataFor($assoc->targetEntityName);
if (!isset($targetClass->fieldNames[$joinColumn['referencedColumnName']])) {
$ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' does not " . $ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' does not " .
"have a corresponding field with this column name on the class '" . $class->name . "'."; "have a corresponding field with this column name on the class '" . $targetClass->name . "'.";
break; break;
} }
$fieldName = $class->fieldNames[$joinColumn['referencedColumnName']]; $fieldName = $targetClass->fieldNames[$joinColumn['referencedColumnName']];
if (!in_array($fieldName, $class->identifier)) { if (!in_array($fieldName, $targetClass->identifier)) {
$ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' " . $ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' " .
"has to be a primary key column."; "has to be a primary key column.";
} }
} }
} }
} else {
}
if ($ce) { if ($ce) {
$errors[$class->name] = $ce; $errors[$class->name] = $ce;