Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix renaming upper-cased SQLite columns #4815

Merged
merged 1 commit into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Platforms/SqlitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ public function getAlterTableSQL(TableDiff $diff)
private function replaceColumn($tableName, array $columns, $columnName, Column $column): array
{
$keys = array_keys($columns);
$index = array_search($columnName, $keys, true);
$index = array_search(strtolower($columnName), $keys, true);

if ($index === false) {
throw SchemaException::columnDoesNotExist($columnName, $tableName);
Expand Down
22 changes: 19 additions & 3 deletions tests/Functional/Platform/RenameColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@

class RenameColumnTest extends FunctionalTestCase
{
public function testColumnPositionRetainedAfterRenaming(): void
/**
* @dataProvider columnNameProvider
*/
public function testColumnPositionRetainedAfterRenaming(string $columnName): void
{
if ($columnName === 'C1') {
self::markTestIncomplete('See https://github.com/doctrine/dbal/issues/4816');
}

$table = new Table('test_rename');
$table->addColumn('c1', 'string');
$table->addColumn($columnName, 'string');
$table->addColumn('c2', 'integer');

$sm = $this->connection->createSchemaManager();
$sm->dropAndCreateTable($table);

$table->dropColumn('c1')
$table->dropColumn($columnName)
->addColumn('c1_x', 'string');

$comparator = new Comparator();
Expand All @@ -31,4 +38,13 @@ public function testColumnPositionRetainedAfterRenaming(): void
$table = $sm->listTableDetails('test_rename');
self::assertSame(['c1_x', 'c2'], array_keys($table->getColumns()));
}

/**
* @return iterable<array{string}>
*/
public static function columnNameProvider(): iterable
{
yield ['c1'];
yield ['C1'];
}
}