Commit aac65338 authored by Gareth Evans's avatar Gareth Evans Committed by Steve Müller

Update index name quoting in MySQL table creation

parent 1b94c383
......@@ -392,14 +392,14 @@ class MySqlPlatform extends AbstractPlatform
if (isset($options['uniqueConstraints']) && ! empty($options['uniqueConstraints'])) {
foreach ($options['uniqueConstraints'] as $index => $definition) {
$queryFields .= ', ' . $this->getUniqueConstraintDeclarationSQL($index, $definition);
$queryFields .= ', ' . $this->getUniqueConstraintDeclarationSQL($definition->getQuotedName($this), $definition);
}
}
// add all indexes
if (isset($options['indexes']) && ! empty($options['indexes'])) {
foreach ($options['indexes'] as $index => $definition) {
$queryFields .= ', ' . $this->getIndexDeclarationSQL($index, $definition);
$queryFields .= ', ' . $this->getIndexDeclarationSQL($definition->getQuotedName($this), $definition);
}
}
......
......@@ -26,6 +26,20 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
$this->assertEquals('CREATE TABLE Foo (Bar INT NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB', array_shift($sql));
}
public function testReservedKeywordInIndexGeneratedTableSql()
{
$table = new Table("Foo");
$table->addColumn("user_name", "string");
$table->addColumn("last_login", "date");
$table->addIndex(array('user_name', 'last_login'), 'key');
$sql = $this->_platform->getCreateTableSQL($table);
$this->assertEquals(
'CREATE TABLE Foo (user_name VARCHAR(255) NOT NULL, last_login DATE NOT NULL, INDEX `key` (user_name, last_login)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
array_shift($sql)
);
}
public function getGenerateTableSql()
{
return 'CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB';
......
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