Skip to content

Commit

Permalink
refactor out getting old column comment
Browse files Browse the repository at this point in the history
  • Loading branch information
bendavies committed Oct 16, 2018
1 parent 7702023 commit 8a7208d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,11 +580,8 @@ public function getAlterTableSQL(TableDiff $diff)
}
}

$oldComment = null;
$newComment = $this->getColumnComment($column);
if (null !== $columnDiff->fromColumn) {
$oldComment = $this->getColumnComment($columnDiff->fromColumn);
}
$oldComment = $this->getOldColumnComment($columnDiff);

if ($columnDiff->hasChanged('comment') || ($columnDiff->fromColumn !== null && $oldComment !== $newComment)) {
$commentsSQL[] = $this->getCommentOnColumnSQL(
Expand Down Expand Up @@ -1254,4 +1251,9 @@ private function isNumericType(Type $type) : bool
{
return $type instanceof IntegerType || $type instanceof BigIntType;
}

private function getOldColumnComment(ColumnDiff $columnDiff) : ?string
{
return $columnDiff->fromColumn ? $this->getColumnComment($columnDiff->fromColumn) : null;
}
}

0 comments on commit 8a7208d

Please sign in to comment.