1
0
mirror of synced 2025-01-05 16:53:21 +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");
}
$exit += 1;
} else {
$output->write('<info>[Mapping] OK - The mapping files are correct.</info>' . "\n");
}
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) {
if (!isset($class->fieldNames[$joinColumn['referencedColumnName']])) {
$ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' does not " .
@ -145,33 +146,38 @@ class SchemaValidator
}
}
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 . "'.";
$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 = $class->fieldNames[$inverseJoinColumn['referencedColumnName']];
if (!in_array($fieldName, $class->identifier)) {
$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) {
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 " .
"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;
}
$fieldName = $class->fieldNames[$joinColumn['referencedColumnName']];
if (!in_array($fieldName, $class->identifier)) {
$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) {
$errors[$class->name] = $ce;