Skip to content

Commit

Permalink
Move test up to SchemaManagerFunctionalTestCase
Browse files Browse the repository at this point in the history
Also add method to AbstrastPlatform to indicate whether new
functionality is supported.
  • Loading branch information
bburnichon committed Sep 7, 2018
1 parent adae83d commit ae102ea
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 16 deletions.
10 changes: 10 additions & 0 deletions lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -3160,6 +3160,16 @@ public function supportsPartialIndexes()
return false;
}

/**
* Whether the platform supports indexes with column length definitions.
*
* @return bool
*/
public function supportsColumnLengthIndexes()
{
return false;
}

/**
* Whether the platform supports altering tables.
*
Expand Down
5 changes: 5 additions & 0 deletions lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,11 @@ public function getDefaultTransactionIsolationLevel()
return TransactionIsolationLevel::REPEATABLE_READ;
}

public function supportsColumnLengthIndexes()
{
return true;
}

/**
* {@inheritdoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,20 +478,4 @@ public function testEnsureDefaultsAreUnescapedFromSchemaIntrospection() : void
$onlineTable = $this->_sm->listTableDetails("test_column_defaults_with_create");
self::assertSame($default, $onlineTable->getColumn('col1')->getDefault());
}

public function testGenerateAnIndexWithPartialColumnLength() : void
{
$table = new Table('test_partial_column_index');
$table->addColumn('long_column', 'string', ['length' => 40]);
$table->addColumn('standard_column', 'integer');
$table->addIndex(['long_column'], 'partial_long_column_idx', [], ['lengths' => [4]]);
$table->addIndex(['standard_column', 'long_column'], 'standard_and_partial_idx', [], ['lengths' => [null, 2]]);

$expected = $table->getIndexes();

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

$onlineTable = $this->_sm->listTableDetails('test_partial_column_index');
self::assertEquals($expected, $onlineTable->getIndexes());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1517,4 +1517,24 @@ public function testPrimaryKeyAutoIncrement()

$this->assertGreaterThan($lastUsedIdBeforeDelete, $lastUsedIdAfterDelete);
}

public function testGenerateAnIndexWithPartialColumnLength() : void
{
if (! $this->_sm->getDatabasePlatform()->supportsColumnLengthIndexes()) {
self::markTestSkipped('This test is only supported on platforms that support indexes with column length definitions.');
}

$table = new Table('test_partial_column_index');
$table->addColumn('long_column', 'string', ['length' => 40]);
$table->addColumn('standard_column', 'integer');
$table->addIndex(['long_column'], 'partial_long_column_idx', [], ['lengths' => [4]]);
$table->addIndex(['standard_column', 'long_column'], 'standard_and_partial_idx', [], ['lengths' => [null, 2]]);

$expected = $table->getIndexes();

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

$onlineTable = $this->_sm->listTableDetails('test_partial_column_index');
self::assertEquals($expected, $onlineTable->getIndexes());
}
}

0 comments on commit ae102ea

Please sign in to comment.