Commit 02fa06ce authored by Benjamin Eberlei's avatar Benjamin Eberlei

[DBAL-555] Fix Sqlite and SQLAnywhere Platforms, document TableDiff changes.

parent 2815335e
......@@ -28,6 +28,7 @@ use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Constraint;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Identifier;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
......@@ -189,18 +190,18 @@ class SQLAnywherePlatform extends AbstractPlatform
continue;
}
$sql[] = $this->getAlterTableClause($diff->name) . ' ' .
$sql[] = $this->getAlterTableClause($diff->getName()) . ' ' .
$this->getAlterTableRenameColumnClause($oldColumnName, $column);
}
if ( ! $this->onSchemaAlterTable($diff, $tableSql)) {
if ( ! empty($alterClauses)) {
$sql[] = $this->getAlterTableClause($diff->name) . ' ' . implode(", ", $alterClauses);
$sql[] = $this->getAlterTableClause($diff->getName()) . ' ' . implode(", ", $alterClauses);
}
if ($diff->newName !== false) {
$sql[] = $this->getAlterTableClause($diff->name) . ' ' .
$this->getAlterTableRenameTableClause($diff->newName);
$sql[] = $this->getAlterTableClause($diff->getName()) . ' ' .
$this->getAlterTableRenameTableClause($diff->getNewName());
}
$sql = array_merge($sql, $this->_getAlterTableIndexForeignKeySQL($diff), $commentsSQL);
......@@ -224,13 +225,13 @@ class SQLAnywherePlatform extends AbstractPlatform
/**
* Returns the SQL clause for altering a table.
*
* @param string $tableName The quoted name of the table to alter.
* @param Identifier $tableName The quoted name of the table to alter.
*
* @return string
*/
protected function getAlterTableClause($tableName)
protected function getAlterTableClause(Identifier $tableName)
{
return 'ALTER TABLE ' . $tableName;
return 'ALTER TABLE ' . $tableName->getQuotedName($this);
}
/**
......@@ -261,13 +262,13 @@ class SQLAnywherePlatform extends AbstractPlatform
/**
* Returns the SQL clause for renaming a table in a table alteration.
*
* @param string $newTableName The quoted name of the table to rename to.
* @param Identifier $newTableName The quoted name of the table to rename to.
*
* @return string
*/
protected function getAlterTableRenameTableClause($newTableName)
protected function getAlterTableRenameTableClause(Identifier $newTableName)
{
return 'RENAME ' . $newTableName;
return 'RENAME ' . $newTableName->getQuotedName($this);
}
/**
......
......@@ -24,6 +24,7 @@ use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Identifier;
use Doctrine\DBAL\Schema\Constraint;
/**
......@@ -804,7 +805,7 @@ class SqlitePlatform extends AbstractPlatform
$sql[] = $this->getDropTableSQL($dataTable);
if ($diff->newName && $diff->newName != $diff->name) {
$renamedTable = new Table($diff->newName);
$renamedTable = new Identifier($diff->newName);
$sql[] = 'ALTER TABLE '.$newTable->getQuotedName($this).' RENAME TO '.$renamedTable->getQuotedName($this);
}
......@@ -859,7 +860,7 @@ class SqlitePlatform extends AbstractPlatform
if ( ! $this->onSchemaAlterTable($diff, $tableSql)) {
if ($diff->newName !== false) {
$newTable = new Table($diff->newName);
$newTable = new Identifier($diff->newName);
$sql[] = 'ALTER TABLE '.$table->getQuotedName($this).' RENAME TO '.$newTable->getQuotedName($this);
}
}
......
......@@ -139,11 +139,17 @@ class TableDiff
$this->fromTable = $fromTable;
}
/**
* @return \Doctrine\DBAL\Schema\Identifier
*/
public function getName()
{
return new Identifier($this->name);
}
/**
* @return \Doctrine\DBAL\Schema\Identifier
*/
public function getNewName()
{
return new Identifier($this->newName);
......
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