diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index 9bcfaf7b89b..f0ace993ea4 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -1517,7 +1517,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE $options['primary'] = $index->getQuotedColumns($this); $options['primary_index'] = $index; } else { - $options['indexes'][$index->getName()] = $index; + $options['indexes'][$index->getQuotedName($this)] = $index; } } } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php index e4fec91d011..45e93c43460 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php @@ -242,6 +242,13 @@ protected function getQuotedColumnInIndexSQL() ); } + protected function getQuotedNameInIndexSQL() + { + return array( + 'CREATE TABLE test (column1 VARCHAR(255) NOT NULL, INDEX `key` (column1)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB' + ); + } + protected function getQuotedColumnInForeignKeySQL() { return array( diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php index 2f66c7c15fd..6246556e159 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php @@ -539,6 +539,7 @@ public function testQuotedColumnInPrimaryKeyPropagation() abstract protected function getQuotedColumnInPrimaryKeySQL(); abstract protected function getQuotedColumnInIndexSQL(); + abstract protected function getQuotedNameInIndexSQL(); abstract protected function getQuotedColumnInForeignKeySQL(); /** @@ -554,6 +555,16 @@ public function testQuotedColumnInIndexPropagation() $this->assertEquals($this->getQuotedColumnInIndexSQL(), $sql); } + public function testQuotedNameInIndexSQL() + { + $table = new Table('test'); + $table->addColumn('column1', 'string'); + $table->addIndex(array('column1'), '`key`'); + + $sql = $this->_platform->getCreateTableSQL($table); + $this->assertEquals($this->getQuotedNameInIndexSQL(), $sql); + } + /** * @group DBAL-374 */ diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php index 39f8e5be795..3c612419d40 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php @@ -280,6 +280,14 @@ protected function getQuotedColumnInIndexSQL() ); } + protected function getQuotedNameInIndexSQL() + { + return array( + 'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)', + 'CREATE INDEX "key" ON test (column1)', + ); + } + protected function getQuotedColumnInForeignKeySQL() { return array( diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php index 181d0213a4b..4cab426ff1a 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php @@ -455,6 +455,14 @@ protected function getQuotedColumnInIndexSQL() ); } + protected function getQuotedNameInIndexSQL() + { + return array( + 'CREATE TABLE test (column1 NVARCHAR(255) NOT NULL)', + 'CREATE INDEX [key] ON test (column1)', + ); + } + protected function getQuotedColumnInForeignKeySQL() { return array( diff --git a/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php index e71993d7481..69d8e05a43d 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php @@ -86,6 +86,14 @@ protected function getQuotedColumnInIndexSQL() ); } + protected function getQuotedNameInIndexSQL() + { + return array( + 'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)', + 'CREATE INDEX "key" ON test (column1)', + ); + } + protected function getQuotedColumnInPrimaryKeySQL() { return array( diff --git a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php index 077702b00d5..8c271e75392 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php @@ -302,6 +302,14 @@ protected function getQuotedColumnInIndexSQL() ); } + protected function getQuotedNameInIndexSQL() + { + return array( + 'CREATE TABLE test (column1 VARCHAR2(255) NOT NULL)', + 'CREATE INDEX "key" ON test (column1)', + ); + } + protected function getQuotedColumnInForeignKeySQL() { return array( diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php index e155933fd29..cc82c2a5454 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php @@ -78,6 +78,14 @@ protected function getQuotedColumnInIndexSQL() ); } + protected function getQuotedNameInIndexSQL() + { + return array( + 'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)', + 'CREATE INDEX "key" ON test (column1)', + ); + } + protected function getQuotedColumnInPrimaryKeySQL() { return array( diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php index 348a328673e..dcbcab17f0b 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php @@ -440,6 +440,14 @@ protected function getQuotedColumnInIndexSQL() ); } + protected function getQuotedNameInIndexSQL() + { + return array( + 'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)', + 'CREATE INDEX "key" ON test (column1)', + ); + } + protected function getQuotedColumnInForeignKeySQL() { return array(