Skip to content

Commit

Permalink
Use original case to index renamed columns
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Dec 19, 2021
1 parent 421b8e8 commit 3f3253b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
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

0 comments on commit 3f3253b

Please sign in to comment.