Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed sql for creating table with fulltext index #246

Merged
merged 1 commit into from

3 participants

Martin Hasoň doctrinebot Guilherme Blanco
Martin Hasoň

No description provided.

doctrinebot
Collaborator

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DBAL-410

Guilherme Blanco guilhermeblanco merged commit 2f3377c into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 8, 2013
  1. Martin Hasoň
This page is out of date. Refresh to see the latest.
8 lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View
@@ -1905,17 +1905,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())
. ')';
}
19 tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
View
@@ -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'));
+ }
+}
14 tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
View
@@ -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);
+ }
}
Something went wrong with that request. Please try again.