1
0
mirror of synced 2024-12-13 14:56:01 +03:00

[DBAL-1692] Throw exception if table has no primary key instead of fatal error.

This commit is contained in:
Benjamin Eberlei 2012-03-14 21:09:48 +01:00
parent 0e1eff14bc
commit de5e4b0fdc

View File

@ -130,6 +130,13 @@ class DatabaseDriver implements Driver
$allForeignKeyColumns = array_merge($allForeignKeyColumns, $foreignKey->getLocalColumns());
}
if ( ! $table->hasPrimaryKey()) {
throw new MappingException(
"Table " . $table->getName() . " has no primary key. Doctrine does not ".
"support reverse engineering from tables that don't have a primary key."
);
}
$pkColumns = $table->getPrimaryKey()->getColumns();
sort($pkColumns);
sort($allForeignKeyColumns);