Commit 80194350 authored by Steve Müller's avatar Steve Müller

quote reserved keywords in TRUNCATE TABLE SQL

fixes #2270
parent 9567eaaa
......@@ -3418,7 +3418,9 @@ abstract class AbstractPlatform
*/
public function getTruncateTableSQL($tableName, $cascade = false)
{
return 'TRUNCATE '.$tableName;
$tableIdentifier = new Identifier($tableName);
return 'TRUNCATE ' . $tableIdentifier->getQuotedName($this);
}
/**
......
......@@ -234,7 +234,9 @@ class DB2Platform extends AbstractPlatform
*/
public function getTruncateTableSQL($tableName, $cascade = false)
{
return 'TRUNCATE ' . $tableName . ' IMMEDIATE';
$tableIdentifier = new Identifier($tableName);
return 'TRUNCATE ' . $tableIdentifier->getQuotedName($this) . ' IMMEDIATE';
}
/**
......
......@@ -1057,7 +1057,9 @@ LEFT JOIN user_cons_columns r_cols
*/
public function getTruncateTableSQL($tableName, $cascade = false)
{
return 'TRUNCATE TABLE '.$tableName;
$tableIdentifier = new Identifier($tableName);
return 'TRUNCATE TABLE ' . $tableIdentifier->getQuotedName($this);
}
/**
......
......@@ -1068,7 +1068,14 @@ class PostgreSqlPlatform extends AbstractPlatform
*/
public function getTruncateTableSQL($tableName, $cascade = false)
{
return 'TRUNCATE '.$tableName.' '.(($cascade)?'CASCADE':'');
$tableIdentifier = new Identifier($tableName);
$sql = 'TRUNCATE ' . $tableIdentifier->getQuotedName($this);
if ($cascade) {
$sql .= ' CASCADE';
}
return $sql;
}
/**
......
......@@ -1124,7 +1124,9 @@ class SQLAnywherePlatform extends AbstractPlatform
*/
public function getTruncateTableSQL($tableName, $cascade = false)
{
return 'TRUNCATE TABLE ' . $tableName;
$tableIdentifier = new Identifier($tableName);
return 'TRUNCATE TABLE ' . $tableIdentifier->getQuotedName($this);
}
/**
......
......@@ -1493,7 +1493,9 @@ class SQLServerPlatform extends AbstractPlatform
*/
public function getTruncateTableSQL($tableName, $cascade = false)
{
return 'TRUNCATE TABLE '.$tableName;
$tableIdentifier = new Identifier($tableName);
return 'TRUNCATE TABLE ' . $tableIdentifier->getQuotedName($this);
}
/**
......
......@@ -505,7 +505,8 @@ class SqlitePlatform extends AbstractPlatform
*/
public function getTruncateTableSQL($tableName, $cascade = false)
{
$tableName = str_replace('.', '__', $tableName);
$tableIdentifier = new Identifier($tableName);
$tableName = str_replace('.', '__', $tableIdentifier->getQuotedName($this));
return 'DELETE FROM ' . $tableName;
}
......
......@@ -701,6 +701,14 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
return 'INDEX `select` (foo)';
}
/**
* {@inheritdoc}
*/
protected function getQuotesReservedKeywordInTruncateTableSQL()
{
return 'TRUNCATE `select`';
}
/**
* {@inheritdoc}
*/
......
......@@ -621,6 +621,22 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
*/
abstract protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL();
/**
* @group DBAL-2270
*/
public function testQuotesReservedKeywordInTruncateTableSQL()
{
$this->assertSame(
$this->getQuotesReservedKeywordInTruncateTableSQL(),
$this->_platform->getTruncateTableSQL('select')
);
}
/**
* @return string
*/
abstract protected function getQuotesReservedKeywordInTruncateTableSQL();
/**
* @group DBAL-1051
*/
......
......@@ -769,6 +769,14 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
return 'INDEX "select" (foo)';
}
/**
* {@inheritdoc}
*/
protected function getQuotesReservedKeywordInTruncateTableSQL()
{
return 'TRUNCATE "select"';
}
/**
* {@inheritdoc}
*/
......
......@@ -1311,6 +1311,14 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
return 'INDEX [select] (foo)';
}
/**
* {@inheritdoc}
*/
protected function getQuotesReservedKeywordInTruncateTableSQL()
{
return 'TRUNCATE TABLE [select]';
}
/**
* {@inheritdoc}
*/
......
......@@ -640,6 +640,14 @@ class DB2PlatformTest extends AbstractPlatformTestCase
return ''; // not supported by this platform
}
/**
* {@inheritdoc}
*/
protected function getQuotesReservedKeywordInTruncateTableSQL()
{
return 'TRUNCATE "select" IMMEDIATE';
}
/**
* {@inheritdoc}
*/
......
......@@ -714,6 +714,14 @@ EOD;
return 'INDEX "select" (foo)';
}
/**
* {@inheritdoc}
*/
protected function getQuotesReservedKeywordInTruncateTableSQL()
{
return 'TRUNCATE TABLE "select"';
}
/**
* {@inheritdoc}
*/
......
......@@ -960,6 +960,14 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
return ''; // not supported by this platform
}
/**
* {@inheritdoc}
*/
protected function getQuotesReservedKeywordInTruncateTableSQL()
{
return 'TRUNCATE TABLE "select"';
}
/**
* {@inheritdoc}
*/
......
......@@ -639,6 +639,14 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
return 'INDEX "select" (foo)';
}
/**
* {@inheritdoc}
*/
protected function getQuotesReservedKeywordInTruncateTableSQL()
{
return 'DELETE FROM "select"';
}
/**
* {@inheritdoc}
*/
......
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