Skip to content

Commit

Permalink
Merge pull request #3420 from leofeyer/hotfix/index-length
Browse files Browse the repository at this point in the history
Index length can be a `string`: ensure that it is an integer when read by the `MySqlSchemaManager`
  • Loading branch information
morozov authored Jan 6, 2019
2 parents f28f3a8 + 0608372 commit 0731608
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null
} elseif (strpos($v['index_type'], 'SPATIAL') !== false) {
$v['flags'] = ['SPATIAL'];
}
$v['length'] = $v['sub_part'] ?? null;
$v['length'] = isset($v['sub_part']) ? (int) $v['sub_part'] : null;

$tableIndexes[$k] = $v;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ public function testSpatialIndex()
self::assertTrue($indexes['s_index']->hasFlag('spatial'));
}

public function testIndexWithLength() : void
{
$table = new Table('index_length');
$table->addColumn('text', 'string', ['length' => 255]);
$table->addIndex(['text'], 'text_index', [], ['lengths' => [128]]);

$this->schemaManager->dropAndCreateTable($table);

$indexes = $this->schemaManager->listTableIndexes('index_length');
self::assertArrayHasKey('text_index', $indexes);
self::assertSame([128], $indexes['text_index']->getOption('lengths'));
}

/**
* @group DBAL-400
*/
Expand Down

0 comments on commit 0731608

Please sign in to comment.