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