Permalink
Browse files

Merge pull request #246 from hason/fulltext_index

Fixed sql for creating table with fulltext index
  • Loading branch information...
2 parents fed3d65 + da1fe6c commit 2f3377c0f28b276655a11ed54d0b2ac7ba5ad2d3 @guilhermeblanco guilhermeblanco committed Jan 8, 2013
@@ -1893,17 +1893,11 @@ public function getUniqueConstraintDeclarationSQL($name, Index $index)
*/
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 @@ public function testDiffTableBug()
$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 @@ protected function getQuotedColumnInIndexSQL()
'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);
+ }
}

0 comments on commit 2f3377c

Please sign in to comment.