Commit f59df8ca authored by Benjamin Eberlei's avatar Benjamin Eberlei

DBAL-64 - Fix Platforms to use AbstractAsset::getQuotedName() in all occourances

parent 36bb5429
......@@ -672,7 +672,7 @@ abstract class AbstractPlatform
public function getDropTableSQL($table)
{
if ($table instanceof \Doctrine\DBAL\Schema\Table) {
$table = $table->getName();
$table = $table->getQuotedName($this);
}
return 'DROP TABLE ' . $table;
......@@ -688,7 +688,7 @@ abstract class AbstractPlatform
public function getDropIndexSQL($index, $table=null)
{
if($index instanceof \Doctrine\DBAL\Schema\Index) {
$index = $index->getName();
$index = $index->getQuotedName($this);
} else if(!is_string($index)) {
throw new \InvalidArgumentException('AbstractPlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.');
}
......@@ -706,11 +706,11 @@ abstract class AbstractPlatform
public function getDropConstraintSQL($constraint, $table)
{
if ($constraint instanceof \Doctrine\DBAL\Schema\Constraint) {
$constraint = $constraint->getName();
$constraint = $constraint->getQuotedName($this);
}
if ($table instanceof \Doctrine\DBAL\Schema\Table) {
$table = $table->getName();
$table = $table->getQuotedName($this);
}
return 'ALTER TABLE ' . $table . ' DROP CONSTRAINT ' . $constraint;
......@@ -724,11 +724,11 @@ abstract class AbstractPlatform
public function getDropForeignKeySQL($foreignKey, $table)
{
if ($foreignKey instanceof \Doctrine\DBAL\Schema\ForeignKeyConstraint) {
$foreignKey = $foreignKey->getName();
$foreignKey = $foreignKey->getQuotedName($this);
}
if ($table instanceof \Doctrine\DBAL\Schema\Table) {
$table = $table->getName();
$table = $table->getQuotedName($this);
}
return 'ALTER TABLE ' . $table . ' DROP FOREIGN KEY ' . $foreignKey;
......@@ -752,7 +752,7 @@ abstract class AbstractPlatform
throw DBALException::noColumnsSpecifiedForTable($table->getName());
}
$tableName = $table->getName();
$tableName = $table->getQuotedName($this);
$options = $table->getOptions();
$options['uniqueConstraints'] = array();
$options['indexes'] = array();
......@@ -773,7 +773,7 @@ abstract class AbstractPlatform
foreach ($table->getColumns() AS $column) {
/* @var \Doctrine\DBAL\Schema\Column $column */
$columnData = array();
$columnData['name'] = $column->getName();
$columnData['name'] = $column->getQuotedName($this);
$columnData['type'] = $column->getType();
$columnData['length'] = $column->getLength();
$columnData['notnull'] = $column->getNotNull();
......@@ -876,10 +876,10 @@ abstract class AbstractPlatform
public function getCreateConstraintSQL(\Doctrine\DBAL\Schema\Constraint $constraint, $table)
{
if ($table instanceof \Doctrine\DBAL\Schema\Table) {
$table = $table->getName();
$table = $table->getQuotedName($this);
}
$query = 'ALTER TABLE ' . $table . ' ADD CONSTRAINT ' . $constraint->getName();
$query = 'ALTER TABLE ' . $table . ' ADD CONSTRAINT ' . $constraint->getQuotedName($this);
$columns = array();
foreach ($constraint->getColumns() as $column) {
......@@ -923,9 +923,9 @@ abstract class AbstractPlatform
public function getCreateIndexSQL(Index $index, $table)
{
if ($table instanceof Table) {
$table = $table->getName();
$table = $table->getQuotedName($this);
}
$name = $index->getName();
$name = $index->getQuotedName($this);
$columns = $index->getColumns();
if (count($columns) == 0) {
......@@ -972,7 +972,7 @@ abstract class AbstractPlatform
public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, $table)
{
if ($table instanceof \Doctrine\DBAL\Schema\Table) {
$table = $table->getName();
$table = $table->getQuotedName($this);
}
$query = 'ALTER TABLE ' . $table . ' ADD ' . $this->getForeignKeyDeclarationSQL($foreignKey);
......@@ -1423,7 +1423,7 @@ abstract class AbstractPlatform
{
$sql = '';
if (strlen($foreignKey->getName())) {
$sql .= 'CONSTRAINT ' . $foreignKey->getName() . ' ';
$sql .= 'CONSTRAINT ' . $foreignKey->getQuotedName($this) . ' ';
}
$sql .= 'FOREIGN KEY (';
......
......@@ -379,22 +379,22 @@ class DB2Platform extends AbstractPlatform
$queryParts = array();
foreach ($diff->addedColumns AS $fieldName => $column) {
$queryParts[] = 'ADD COLUMN ' . $this->getColumnDeclarationSQL($column->getName(), $column->toArray());
$queryParts[] = 'ADD COLUMN ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
}
foreach ($diff->removedColumns AS $column) {
$queryParts[] = 'DROP COLUMN ' . $column->getName();
$queryParts[] = 'DROP COLUMN ' . $column->getQuotedName($this);
}
foreach ($diff->changedColumns AS $columnDiff) {
/* @var $columnDiff Doctrine\DBAL\Schema\ColumnDiff */
$column = $columnDiff->column;
$queryParts[] = 'ALTER ' . ($columnDiff->oldColumnName) . ' '
. $this->getColumnDeclarationSQL($column->getName(), $column->toArray());
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
}
foreach ($diff->renamedColumns AS $oldColumnName => $column) {
$queryParts[] = 'RENAME ' . $oldColumnName . ' TO ' . $column->getName();
$queryParts[] = 'RENAME ' . $oldColumnName . ' TO ' . $column->getQuotedName($this);
}
if (count($queryParts) > 0) {
......
......@@ -114,11 +114,11 @@ DROP DATABASE ' . $name . ';';
public function getDropForeignKeySQL($foreignKey, $table)
{
if ($foreignKey instanceof \Doctrine\DBAL\Schema\ForeignKeyConstraint) {
$foreignKey = $foreignKey->getName();
$foreignKey = $foreignKey->getQuotedName($this);
}
if ($table instanceof \Doctrine\DBAL\Schema\Table) {
$table = $table->getName();
$table = $table->getQuotedName($this);
}
return 'ALTER TABLE ' . $table . ' DROP CONSTRAINT ' . $foreignKey;
......@@ -131,7 +131,7 @@ DROP DATABASE ' . $name . ';';
{
if ($index instanceof \Doctrine\DBAL\Schema\Index) {
$index_ = $index;
$index = $index->getName();
$index = $index->getQuotedName($this);
} else if (!is_string($index)) {
throw new \InvalidArgumentException('AbstractPlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.');
}
......@@ -140,7 +140,7 @@ DROP DATABASE ' . $name . ';';
return 'DROP INDEX ' . $index;
} else {
if ($table instanceof \Doctrine\DBAL\Schema\Table) {
$table = $table->getName();
$table = $table->getQuotedName($this);
}
return "IF EXISTS (SELECT * FROM sysobjects WHERE name = '$index')
......@@ -231,23 +231,23 @@ DROP DATABASE ' . $name . ';';
}
foreach ($diff->addedColumns AS $fieldName => $column) {
$queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getName(), $column->toArray());
$queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
}
foreach ($diff->removedColumns AS $column) {
$queryParts[] = 'DROP COLUMN ' . $column->getName();
$queryParts[] = 'DROP COLUMN ' . $column->getQuotedName($this);
}
foreach ($diff->changedColumns AS $columnDiff) {
/* @var $columnDiff Doctrine\DBAL\Schema\ColumnDiff */
$column = $columnDiff->column;
$queryParts[] = 'CHANGE ' . ($columnDiff->oldColumnName) . ' '
. $this->getColumnDeclarationSQL($column->getName(), $column->toArray());
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
}
foreach ($diff->renamedColumns AS $oldColumnName => $column) {
$queryParts[] = 'CHANGE ' . $oldColumnName . ' '
. $this->getColumnDeclarationSQL($column->getName(), $column->toArray());
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
}
$sql = array();
......
......@@ -410,23 +410,23 @@ class MySqlPlatform extends AbstractPlatform
}
foreach ($diff->addedColumns AS $fieldName => $column) {
$queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getName(), $column->toArray());
$queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
}
foreach ($diff->removedColumns AS $column) {
$queryParts[] = 'DROP ' . $column->getName();
$queryParts[] = 'DROP ' . $column->getQuotedName($this);
}
foreach ($diff->changedColumns AS $columnDiff) {
/* @var $columnDiff Doctrine\DBAL\Schema\ColumnDiff */
$column = $columnDiff->column;
$queryParts[] = 'CHANGE ' . ($columnDiff->oldColumnName) . ' '
. $this->getColumnDeclarationSQL($column->getName(), $column->toArray());
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
}
foreach ($diff->renamedColumns AS $oldColumnName => $column) {
$queryParts[] = 'CHANGE ' . $oldColumnName . ' '
. $this->getColumnDeclarationSQL($column->getName(), $column->toArray());
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
}
$sql = array();
......@@ -520,13 +520,13 @@ class MySqlPlatform extends AbstractPlatform
public function getDropIndexSQL($index, $table=null)
{
if($index instanceof \Doctrine\DBAL\Schema\Index) {
$index = $index->getName();
$index = $index->getQuotedName($this);
} else if(!is_string($index)) {
throw new \InvalidArgumentException('MysqlPlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.');
}
if($table instanceof \Doctrine\DBAL\Schema\Table) {
$table = $table->getName();
$table = $table->getQuotedName($this);
} else if(!is_string($table)) {
throw new \InvalidArgumentException('MysqlPlatform::getDropIndexSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.');
}
......@@ -543,7 +543,7 @@ class MySqlPlatform extends AbstractPlatform
public function getDropTableSQL($table)
{
if ($table instanceof \Doctrine\DBAL\Schema\Table) {
$table = $table->getName();
$table = $table->getQuotedName($this);
} else if(!is_string($table)) {
throw new \InvalidArgumentException('MysqlPlatform::getDropTableSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.');
}
......
......@@ -113,7 +113,7 @@ class OraclePlatform extends AbstractPlatform
*/
public function getCreateSequenceSQL(\Doctrine\DBAL\Schema\Sequence $sequence)
{
return 'CREATE SEQUENCE ' . $sequence->getName() .
return 'CREATE SEQUENCE ' . $sequence->getQuotedName($this) .
' START WITH ' . $sequence->getInitialValue() .
' MINVALUE ' . $sequence->getInitialValue() .
' INCREMENT BY ' . $sequence->getAllocationSize();
......@@ -455,7 +455,7 @@ LEFT JOIN all_cons_columns r_cols
public function getDropSequenceSQL($sequence)
{
if ($sequence instanceof \Doctrine\DBAL\Schema\Sequence) {
$sequence = $sequence->getName();
$sequence = $sequence->getQuotedName($this);
}
return 'DROP SEQUENCE ' . $sequence;
......@@ -469,11 +469,11 @@ LEFT JOIN all_cons_columns r_cols
public function getDropForeignKeySQL($foreignKey, $table)
{
if ($foreignKey instanceof \Doctrine\DBAL\Schema\ForeignKeyConstraint) {
$foreignKey = $foreignKey->getName();
$foreignKey = $foreignKey->getQuotedName($this);
}
if ($table instanceof \Doctrine\DBAL\Schema\Table) {
$table = $table->getName();
$table = $table->getQuotedName($this);
}
return 'ALTER TABLE ' . $table . ' DROP CONSTRAINT ' . $foreignKey;
......@@ -502,7 +502,7 @@ LEFT JOIN all_cons_columns r_cols
$fields = array();
foreach ($diff->addedColumns AS $column) {
$fields[] = $this->getColumnDeclarationSQL($column->getName(), $column->toArray());
$fields[] = $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
}
if (count($fields)) {
$sql[] = 'ALTER TABLE ' . $diff->name . ' ADD (' . implode(', ', $fields) . ')';
......@@ -511,19 +511,19 @@ LEFT JOIN all_cons_columns r_cols
$fields = array();
foreach ($diff->changedColumns AS $columnDiff) {
$column = $columnDiff->column;
$fields[] = $column->getName(). ' ' . $this->getColumnDeclarationSQL('', $column->toArray());
$fields[] = $column->getQuotedName($this). ' ' . $this->getColumnDeclarationSQL('', $column->toArray());
}
if (count($fields)) {
$sql[] = 'ALTER TABLE ' . $diff->name . ' MODIFY (' . implode(', ', $fields) . ')';
}
foreach ($diff->renamedColumns AS $oldColumnName => $column) {
$sql[] = 'ALTER TABLE ' . $diff->name . ' RENAME COLUMN ' . $oldColumnName .' TO ' . $column->getName();
$sql[] = 'ALTER TABLE ' . $diff->name . ' RENAME COLUMN ' . $oldColumnName .' TO ' . $column->getQuotedName($this);
}
$fields = array();
foreach ($diff->removedColumns AS $column) {
$fields[] = $column->getName();
$fields[] = $column->getQuotedName($this);
}
if (count($fields)) {
$sql[] = 'ALTER TABLE ' . $diff->name . ' DROP COLUMN ' . implode(', ', $fields);
......
......@@ -342,12 +342,12 @@ class PostgreSqlPlatform extends AbstractPlatform
$sql = array();
foreach ($diff->addedColumns as $column) {
$query = 'ADD ' . $this->getColumnDeclarationSQL($column->getName(), $column->toArray());
$query = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
$sql[] = 'ALTER TABLE ' . $diff->name . ' ' . $query;
}
foreach ($diff->removedColumns as $column) {
$query = 'DROP ' . $column->getName();
$query = 'DROP ' . $column->getQuotedName($this);
$sql[] = 'ALTER TABLE ' . $diff->name . ' ' . $query;
}
......@@ -388,7 +388,7 @@ class PostgreSqlPlatform extends AbstractPlatform
}
foreach ($diff->renamedColumns as $oldColumnName => $column) {
$sql[] = 'ALTER TABLE ' . $diff->name . ' RENAME COLUMN ' . $oldColumnName . ' TO ' . $column->getName();
$sql[] = 'ALTER TABLE ' . $diff->name . ' RENAME COLUMN ' . $oldColumnName . ' TO ' . $column->getQuotedName($this);
}
if ($diff->newName !== false) {
......@@ -408,7 +408,7 @@ class PostgreSqlPlatform extends AbstractPlatform
*/
public function getCreateSequenceSQL(\Doctrine\DBAL\Schema\Sequence $sequence)
{
return 'CREATE SEQUENCE ' . $sequence->getName() .
return 'CREATE SEQUENCE ' . $sequence->getQuotedName($this) .
' INCREMENT BY ' . $sequence->getAllocationSize() .
' MINVALUE ' . $sequence->getInitialValue() .
' START ' . $sequence->getInitialValue();
......@@ -422,7 +422,7 @@ class PostgreSqlPlatform extends AbstractPlatform
public function getDropSequenceSQL($sequence)
{
if ($sequence instanceof \Doctrine\DBAL\Schema\Sequence) {
$sequence = $sequence->getName();
$sequence = $sequence->getQuotedName($this);
}
return 'DROP SEQUENCE ' . $sequence;
}
......
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