Skip to content

Commit

Permalink
[DBAL-1692] Throw exception if table has no primary key instead of fa…
Browse files Browse the repository at this point in the history
…tal error.
  • Loading branch information
beberlei committed Mar 14, 2012
1 parent 0e1eff1 commit de5e4b0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ private function reverseEngineerMappingFromDatabase()
$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);
Expand Down

0 comments on commit de5e4b0

Please sign in to comment.