Commit 2f3377c0 authored by Guilherme Blanco's avatar Guilherme Blanco

Merge pull request #246 from hason/fulltext_index

Fixed sql for creating table with fulltext index
parents fed3d650 da1fe6ca
......@@ -1893,17 +1893,11 @@ abstract class AbstractPlatform
*/
public function getIndexDeclarationSQL($name, Index $index)
{
$type = '';
if ($index->isUnique()) {
$type = 'UNIQUE ';
}
if (count($index->getColumns()) === 0) {
throw new \InvalidArgumentException("Incomplete definition. 'columns' required.");
}
return $type . 'INDEX ' . $name . ' ('
return $this->getCreateIndexSQLFlags($index) . 'INDEX ' . $name . ' ('
. $this->getIndexFieldDeclarationListSQL($index->getColumns())
. ')';
}
......
......@@ -47,4 +47,21 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this->assertFalse($diff, "no changes expected.");
}
public function testFulltextIndex()
{
$table = new Table('fulltext_index');
$table->addColumn('text', 'text');
$table->addIndex(array('text'), 'f_index');
$table->addOption('engine', 'MyISAM');
$index = $table->getIndex('f_index');
$index->addFlag('fulltext');
$this->_sm->dropAndCreateTable($table);
$indexes = $this->_sm->listTableIndexes('fulltext_index');
$this->assertArrayHasKey('f_index', $indexes);
$this->assertTrue($indexes['f_index']->hasFlag('fulltext'));
}
}
......@@ -240,4 +240,18 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
'CREATE TABLE `quoted` (`key` VARCHAR(255) NOT NULL, INDEX IDX_22660D028A90ABA9 (`key`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
}
public function testCreateTableWithFulltextIndex()
{
$table = new Table('fulltext_table');
$table->addOption('engine', 'MyISAM');
$table->addColumn('text', 'text');
$table->addIndex(array('text'), 'fulltext_text');
$index = $table->getIndex('fulltext_text');
$index->addFlag('fulltext');
$sql = $this->_platform->getCreateTableSQL($table);
$this->assertEquals(array('CREATE TABLE fulltext_table (text LONGTEXT NOT NULL, FULLTEXT INDEX fulltext_text (text)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = MyISAM'), $sql);
}
}
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