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

Use original case to index renamed columns #4817

Merged
merged 1 commit into from
Dec 30, 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
4 changes: 2 additions & 2 deletions src/Schema/Comparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ private function detectColumnRenamings(TableDiff $tableDifferences): void
}

[$removedColumn, $addedColumn] = $candidateColumns[0];
$removedColumnName = strtolower($removedColumn->getName());
$removedColumnName = $removedColumn->getName();
$addedColumnName = strtolower($addedColumn->getName());

if (isset($tableDifferences->renamedColumns[$removedColumnName])) {
Expand All @@ -383,7 +383,7 @@ private function detectColumnRenamings(TableDiff $tableDifferences): void
$tableDifferences->renamedColumns[$removedColumnName] = $addedColumn;
unset(
$tableDifferences->addedColumns[$addedColumnName],
$tableDifferences->removedColumns[$removedColumnName]
$tableDifferences->removedColumns[strtolower($removedColumnName)]
);
}
}
Expand Down
7 changes: 2 additions & 5 deletions tests/Functional/Platform/RenameColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Doctrine\DBAL\Tests\FunctionalTestCase;

use function array_keys;
use function strtolower;

class RenameColumnTest extends FunctionalTestCase
{
Expand All @@ -15,10 +16,6 @@ class RenameColumnTest extends FunctionalTestCase
*/
public function testColumnPositionRetainedAfterRenaming(string $columnName, string $newColumnName): void
{
if ($columnName === 'C1' || $columnName === 'importantColumn') {
self::markTestIncomplete('See https://github.com/doctrine/dbal/issues/4816');
}

$table = new Table('test_rename');
$table->addColumn($columnName, 'string');
$table->addColumn('c2', 'integer');
Expand All @@ -36,7 +33,7 @@ public function testColumnPositionRetainedAfterRenaming(string $columnName, stri
$sm->alterTable($diff);

$table = $sm->listTableDetails('test_rename');
self::assertSame([$newColumnName, 'c2'], array_keys($table->getColumns()));
self::assertSame([strtolower($newColumnName), 'c2'], array_keys($table->getColumns()));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Schema/ComparatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ public function testDiff(): void
$tableDiff = $this->comparator->diffTable($table, $newtable);

self::assertInstanceOf(TableDiff::class, $tableDiff);
self::assertEquals(['twitterid', 'displayname'], array_keys($tableDiff->renamedColumns));
self::assertEquals(['twitterId', 'displayName'], array_keys($tableDiff->renamedColumns));
self::assertEquals(['logged_in_at'], array_keys($tableDiff->addedColumns));
self::assertCount(0, $tableDiff->removedColumns);
}
Expand Down