Skip to content

Commit

Permalink
Revert case sensitivity check
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofandel committed Aug 28, 2023
1 parent bae63f0 commit d803926
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/Platforms/AbstractMySQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ public function getAlterTableSQL(TableDiff $diff)
$oldColumn = $columnDiff->getOldColumn() ?? $columnDiff->getOldColumnName();
$oldColumnName = $oldColumn->getName();

if ($columnDiff->hasNameChanged($this)) {
if ($columnDiff->hasNameChanged()) {
if ($this->onSchemaAlterTableRenameColumn($oldColumnName, $newColumn, $diff, $columnSql)) {
continue;
}
Expand Down
8 changes: 0 additions & 8 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -4679,12 +4679,4 @@ public function createSchemaManager(Connection $connection): AbstractSchemaManag
{
throw Exception::notSupported(__METHOD__);
}

/**
* Determines if this platform's column names are case sensitive or not (most of them are not).
*/
public function areColumnNamesCaseSensitive(): bool
{
return false;
}
}
4 changes: 2 additions & 2 deletions src/Platforms/DB2Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ public function getAlterTableSQL(TableDiff $diff)

$oldColumnName = $oldColumn->getQuotedName($this);

if ($columnDiff->hasNameChanged($this)) {
if ($columnDiff->hasNameChanged()) {
if ($this->onSchemaAlterTableRenameColumn($oldColumnName, $newColumn, $diff, $columnSql)) {
continue;
}
Expand Down Expand Up @@ -773,7 +773,7 @@ private function getAlterColumnClausesSQL(ColumnDiff $columnDiff): array

$clauses = [];

if ($columnDiff->hasNameChanged($this)) {
if ($columnDiff->hasNameChanged()) {
$clauses[] = 'RENAME COLUMN ' . $oldName . ' TO ' . $newName;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Platforms/OraclePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ public function getAlterTableSQL(TableDiff $diff)
$oldColumnName = $oldColumn->getQuotedName($this);

// Column names in Oracle are case insensitive and automatically uppercased on the server.
if ($columnDiff->hasNameChanged($this)) {
if ($columnDiff->hasNameChanged()) {
if ($this->onSchemaAlterTableRenameColumn($oldColumnName, $newColumn, $diff, $columnSql)) {
continue;

Check warning on line 910 in src/Platforms/OraclePlatform.php

View check run for this annotation

Codecov / codecov/patch

src/Platforms/OraclePlatform.php#L910

Added line #L910 was not covered by tests
}
Expand Down
7 changes: 1 addition & 6 deletions src/Platforms/PostgreSQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ public function getAlterTableSQL(TableDiff $diff)
$oldColumnName = $oldColumn->getQuotedName($this);
$newColumnName = $newColumn->getQuotedName($this);

if ($columnDiff->hasNameChanged($this)) {
if ($columnDiff->hasNameChanged()) {
if ($this->onSchemaAlterTableRenameColumn($oldColumnName, $newColumn, $diff, $columnSql)) {
continue;

Check warning on line 578 in src/Platforms/PostgreSQLPlatform.php

View check run for this annotation

Codecov / codecov/patch

src/Platforms/PostgreSQLPlatform.php#L578

Added line #L578 was not covered by tests
}
Expand Down Expand Up @@ -1398,9 +1398,4 @@ public function createSchemaManager(Connection $connection): PostgreSQLSchemaMan
{
return new PostgreSQLSchemaManager($connection, $this);
}

public function areColumnNamesCaseSensitive(): bool
{
return true;
}
}
4 changes: 2 additions & 2 deletions src/Platforms/SQLServerPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ public function getAlterTableSQL(TableDiff $diff)

$oldColumn = $columnDiff->getOldColumn() ?? $columnDiff->getOldColumnName();
$oldColumnName = $oldColumn->getQuotedName($this);
$nameChanged = $columnDiff->hasNameChanged($this);
$nameChanged = $columnDiff->hasNameChanged();

// Column names in SQL server are case insensitive and automatically uppercased on the server.
if ($nameChanged) {
Expand Down Expand Up @@ -776,7 +776,7 @@ private function alterColumnRequiresDropDefaultConstraint(ColumnDiff $columnDiff

// We need to drop an existing default constraint if the column was
// defined with a default value before and the native column type has changed.
return $columnDiff->hasTypeChanged() || $columnDiff->hasFixedChanged() || $columnDiff->hasNameChanged($this);
return $columnDiff->hasTypeChanged() || $columnDiff->hasFixedChanged() || $columnDiff->hasNameChanged();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Platforms/SqlitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ public function getAlterTableSQL(TableDiff $diff)

$oldColumnName = strtolower($oldColumn->getName());

if ($columnDiff->hasNameChanged($this)) {
if ($columnDiff->hasNameChanged()) {
if ($this->onSchemaAlterTableRenameColumn($oldColumnName, $newColumn, $diff, $columnSql)) {
continue;
}
Expand Down
6 changes: 2 additions & 4 deletions src/Schema/ColumnDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,12 @@ public function getNewColumn(): Column
return $this->column;
}

public function hasNameChanged(AbstractPlatform $platform): bool
public function hasNameChanged(): bool
{
$oldColumn = $this->getOldColumn() ?? $this->getOldColumnName();

// Column names are case insensitive
return $platform->areColumnNamesCaseSensitive()
? $oldColumn->getName() !== $this->getNewColumn()->getName()
: strcasecmp($oldColumn->getName(), $this->getNewColumn()->getName()) !== 0;
return strcasecmp($oldColumn->getName(), $this->getNewColumn()->getName()) !== 0;
}

public function hasTypeChanged(): bool
Expand Down
2 changes: 1 addition & 1 deletion tests/Schema/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function testRenameColumnException(): void
$this->expectExceptionMessage("You are trying to rename the column baz but you didn't change it's name");

$table = new Table('foo');
$table->renameColumn('baz', 'baz');
$table->renameColumn('baz', 'Baz');
}

public function testColumnsCaseInsensitive(): void
Expand Down

0 comments on commit d803926

Please sign in to comment.