[DBAL-1692] Throw exception if table has no primary key instead of fatal error.
This commit is contained in:
parent
0e1eff14bc
commit
de5e4b0fdc
@ -130,6 +130,13 @@ class DatabaseDriver implements Driver
|
|||||||
$allForeignKeyColumns = array_merge($allForeignKeyColumns, $foreignKey->getLocalColumns());
|
$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();
|
$pkColumns = $table->getPrimaryKey()->getColumns();
|
||||||
sort($pkColumns);
|
sort($pkColumns);
|
||||||
sort($allForeignKeyColumns);
|
sort($allForeignKeyColumns);
|
||||||
|
Loading…
Reference in New Issue
Block a user