Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fixed sql for creating table with fulltext index #246

Merged
merged 1 commit into from over 1 year ago

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

Showing 1 unique commit by 1 author.

Jan 08, 2013
Martin Hasoň hason Fixed sql for creating table with fulltext index da1fe6c
This page is out of date. Refresh to see the latest.
8 lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
@@ -1905,17 +1905,11 @@ public function getUniqueConstraintDeclarationSQL($name, Index $index)
1905 1905 */
1906 1906 public function getIndexDeclarationSQL($name, Index $index)
1907 1907 {
1908   - $type = '';
1909   -
1910   - if ($index->isUnique()) {
1911   - $type = 'UNIQUE ';
1912   - }
1913   -
1914 1908 if (count($index->getColumns()) === 0) {
1915 1909 throw new \InvalidArgumentException("Incomplete definition. 'columns' required.");
1916 1910 }
1917 1911
1918   - return $type . 'INDEX ' . $name . ' ('
  1912 + return $this->getCreateIndexSQLFlags($index) . 'INDEX ' . $name . ' ('
1919 1913 . $this->getIndexFieldDeclarationListSQL($index->getColumns())
1920 1914 . ')';
1921 1915 }
19 tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
@@ -47,4 +47,21 @@ public function testDiffTableBug()
47 47
48 48 $this->assertFalse($diff, "no changes expected.");
49 49 }
50   -}
  50 +
  51 + public function testFulltextIndex()
  52 + {
  53 + $table = new Table('fulltext_index');
  54 + $table->addColumn('text', 'text');
  55 + $table->addIndex(array('text'), 'f_index');
  56 + $table->addOption('engine', 'MyISAM');
  57 +
  58 + $index = $table->getIndex('f_index');
  59 + $index->addFlag('fulltext');
  60 +
  61 + $this->_sm->dropAndCreateTable($table);
  62 +
  63 + $indexes = $this->_sm->listTableIndexes('fulltext_index');
  64 + $this->assertArrayHasKey('f_index', $indexes);
  65 + $this->assertTrue($indexes['f_index']->hasFlag('fulltext'));
  66 + }
  67 +}
14 tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
@@ -240,4 +240,18 @@ protected function getQuotedColumnInIndexSQL()
240 240 'CREATE TABLE `quoted` (`key` VARCHAR(255) NOT NULL, INDEX IDX_22660D028A90ABA9 (`key`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
241 241 );
242 242 }
  243 +
  244 + public function testCreateTableWithFulltextIndex()
  245 + {
  246 + $table = new Table('fulltext_table');
  247 + $table->addOption('engine', 'MyISAM');
  248 + $table->addColumn('text', 'text');
  249 + $table->addIndex(array('text'), 'fulltext_text');
  250 +
  251 + $index = $table->getIndex('fulltext_text');
  252 + $index->addFlag('fulltext');
  253 +
  254 + $sql = $this->_platform->getCreateTableSQL($table);
  255 + $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);
  256 + }
243 257 }

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.