Commit 585672e8 authored by Benjamin Eberlei's avatar Benjamin Eberlei

[DBAL-585] Quote Old column Names when generating ALTER TABLE SQL.

parent 8be725c4
......@@ -391,7 +391,7 @@ class DB2Platform extends AbstractPlatform
/* @var $columnDiff \Doctrine\DBAL\Schema\ColumnDiff */
$column = $columnDiff->column;
$queryParts[] = 'ALTER ' . ($columnDiff->oldColumnName) . ' '
$queryParts[] = 'ALTER ' . ($columnDiff->getOldColumnName()->getQuotedName($this)) . ' '
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
}
......
......@@ -410,7 +410,7 @@ class DrizzlePlatform extends AbstractPlatform
$column = $columnDiff->column;
$columnArray = $column->toArray();
$columnArray['comment'] = $this->getColumnComment($column);
$queryParts[] = 'CHANGE ' . ($columnDiff->oldColumnName) . ' '
$queryParts[] = 'CHANGE ' . ($columnDiff->getOldColumnName()->getQuotedName($this)) . ' '
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
}
......
......@@ -557,7 +557,7 @@ class MySqlPlatform extends AbstractPlatform
$column = $columnDiff->column;
$columnArray = $column->toArray();
$columnArray['comment'] = $this->getColumnComment($column);
$queryParts[] = 'CHANGE ' . ($columnDiff->oldColumnName) . ' '
$queryParts[] = 'CHANGE ' . ($columnDiff->getOldColumnName()->getQuotedName($this)) . ' '
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
}
......
......@@ -418,7 +418,7 @@ class PostgreSqlPlatform extends AbstractPlatform
continue;
}
$oldColumnName = $columnDiff->oldColumnName;
$oldColumnName = $columnDiff->getOldColumnName()->getQuotedName($this);
$column = $columnDiff->column;
if ($columnDiff->hasChanged('type') || $columnDiff->hasChanged('precision') || $columnDiff->hasChanged('scale')) {
......
......@@ -71,4 +71,12 @@ class ColumnDiff
{
return in_array($propertyName, $this->changedProperties);
}
/**
* @return \Doctrine\DBAL\Schema\Identifier
*/
public function getOldColumnName()
{
return new Identifier($this->oldColumnName);
}
}
......@@ -494,4 +494,24 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$sql = $this->_platform->getCreateTableSQL($table, AbstractPlatform::CREATE_FOREIGNKEYS);
$this->assertEquals($this->getQuotedColumnInForeignKeySQL(), $sql);
}
/**
* @group DBAL-585
*/
public function testAlterTableChangeQuotedColumn()
{
$tableDiff = new \Doctrine\DBAL\Schema\TableDiff('mytable');
$tableDiff->fromTable = new \Doctrine\DBAL\Schema\Table('mytable');
$tableDiff->changedColumns['foo'] = new \Doctrine\DBAL\Schema\ColumnDiff(
'select', new \Doctrine\DBAL\Schema\Column(
'select', \Doctrine\DBAL\Types\Type::getType('string')
),
array('type')
);
$this->assertContains(
$this->_platform->quoteIdentifier('select'),
implode(';', $this->_platform->getAlterTableSQL($tableDiff))
);
}
}
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