Commit bb844961 authored by Benjamin Eberlei's avatar Benjamin Eberlei

DBAL-144 - Dont throw exception when no primary key exists

parent 4138d8ae
......@@ -475,7 +475,7 @@ class Table extends AbstractAsset
$pkCols = array();
$fkCols = array();
if ($this->hasIndex($this->_primaryKeyName)) {
if ($this->hasPrimaryKey()) {
$pkCols = $this->getPrimaryKey()->getColumns();
}
foreach ($this->getForeignKeys() AS $fk) {
......@@ -520,10 +520,13 @@ class Table extends AbstractAsset
}
/**
* @return Index
* @return Index|null
*/
public function getPrimaryKey()
{
if (!$this->hasPrimaryKey()) {
return null;
}
return $this->getIndex($this->_primaryKeyName);
}
......
......@@ -99,7 +99,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
$label .= '<FONT COLOR="#2e3436" FACE="Helvetica" POINT-SIZE="12">' . $columnLabel . '</FONT>';
$label .= '</TD><TD BORDER="0" ALIGN="LEFT" BGCOLOR="#eeeeec"><FONT COLOR="#2e3436" FACE="Helvetica" POINT-SIZE="10">' . strtolower($column->getType()) . '</FONT></TD>';
$label .= '<TD BORDER="0" ALIGN="RIGHT" BGCOLOR="#eeeeec" PORT="col'.$column->getName().'">';
if (in_array($column->getName(), $table->getPrimaryKey()->getColumns())) {
if ($table->hasPrimaryKey() && in_array($column->getName(), $table->getPrimaryKey()->getColumns())) {
$label .= "\xe2\x9c\xb7";
}
$label .= '</TD></TR>';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment