Skip to content

Commit 0739646

Browse files
authored
Merge pull request #5647 from morozov/remove-column-diff-old-column-name
Remove ColumnDiff::$oldColumnName and ::getOldColumnName()
2 parents 2d57c31 + 58d4b3c commit 0739646

11 files changed

+5
-82
lines changed

UPGRADE.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,10 @@ the name of the object as a separate parameter. The name of the passed index or
421421
The `AbstractPlatform::canEmulateSchemas()` method and the schema emulation implemented in the SQLite platform
422422
have been removed.
423423

424-
## BC BREAK: The `$fromColumn` parameter of the `ColumnDiff` constructor made required
424+
## BC BREAK: Changes in the `ColumnDiff` class
425+
426+
1. The `$fromColumn` parameter of the `ColumnDiff` constructor has been made required.
427+
2. The `$oldColumnName` property and the `getOldColumnName()` method have been removed.
425428

426429
## BC BREAK: Changes in the return value of `Table::getColumns()`
427430

psalm.xml.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
<!--
4343
TODO: remove in 4.0.0
4444
-->
45-
<referencedMethod name="Doctrine\DBAL\Schema\ColumnDiff::getOldColumnName"/>
4645
<referencedMethod name="Doctrine\DBAL\Schema\AbstractSchemaManager::createSchema"/>
4746
</errorLevel>
4847
</DeprecatedMethod>

src/Schema/ColumnDiff.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace Doctrine\DBAL\Schema;
66

7-
use Doctrine\Deprecations\Deprecation;
8-
97
use function in_array;
108

119
/**
@@ -19,10 +17,6 @@ class ColumnDiff
1917
* @param array<string> $changedProperties
2018
*/
2119
public function __construct(
22-
/**
23-
* @deprecated Use {@see $fromColumn} and {@see Column::getName()} instead.
24-
*/
25-
public string $oldColumnName,
2620
public Column $column,
2721
public array $changedProperties,
2822
public Column $fromColumn,
@@ -86,17 +80,4 @@ public function hasChanged(string $propertyName): bool
8680
{
8781
return in_array($propertyName, $this->changedProperties, true);
8882
}
89-
90-
/** @deprecated Use {@see $fromColumn} instead. */
91-
public function getOldColumnName(): Identifier
92-
{
93-
Deprecation::trigger(
94-
'doctrine/dbal',
95-
'https://github.com/doctrine/dbal/pull/5622',
96-
'%s is deprecated. Use $fromColumn instead.',
97-
__METHOD__,
98-
);
99-
100-
return new Identifier($this->oldColumnName, $this->fromColumn->isQuoted());
101-
}
10283
}

src/Schema/Comparator.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ public function diffTable(Table $fromTable, Table $toTable): ?TableDiff
219219
}
220220

221221
$tableDifferences->changedColumns[$column->getName()] = new ColumnDiff(
222-
$column->getName(),
223222
$toColumn,
224223
$this->diffColumn($column, $toColumn),
225224
$column,

tests/Functional/Schema/SQLServerSchemaManagerTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,11 @@ public function testDefaultConstraints(): void
9999
[],
100100
[
101101
'df_integer' => new ColumnDiff(
102-
'df_integer',
103102
new Column('df_integer', Type::getType('integer'), ['default' => 0]),
104103
['default'],
105104
new Column('df_integer', Type::getType('integer'), ['default' => 666]),
106105
),
107106
'df_string_2' => new ColumnDiff(
108-
'df_string_2',
109107
new Column('df_string_2', Type::getType('string'), ['length' => 32]),
110108
['default'],
111109
new Column('df_string_2', Type::getType('string'), [
@@ -114,7 +112,6 @@ public function testDefaultConstraints(): void
114112
]),
115113
),
116114
'df_string_3' => new ColumnDiff(
117-
'df_string_3',
118115
new Column('df_string_3', Type::getType('string'), [
119116
'length' => 50,
120117
'default' => 'another default value',
@@ -126,7 +123,6 @@ public function testDefaultConstraints(): void
126123
]),
127124
),
128125
'df_boolean' => new ColumnDiff(
129-
'df_boolean',
130126
new Column('df_boolean', Type::getType('boolean'), ['default' => false]),
131127
['default'],
132128
new Column('df_boolean', Type::getType('boolean'), ['default' => true]),
@@ -165,7 +161,6 @@ public function testDefaultConstraints(): void
165161
[],
166162
[
167163
'df_integer' => new ColumnDiff(
168-
'df_integer',
169164
new Column('df_integer', Type::getType('integer'), ['default' => 666]),
170165
['default'],
171166
new Column('df_integer', Type::getType('integer'), ['default' => 0]),

tests/Functional/Schema/SchemaManagerFunctionalTestCase.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,14 +843,12 @@ public function testChangeColumnsTypeWithDefaultValue(): void
843843
$tableDiff = new TableDiff($tableName);
844844
$tableDiff->fromTable = $table;
845845
$tableDiff->changedColumns['col_int'] = new ColumnDiff(
846-
'col_int',
847846
new Column('col_int', Type::getType('integer'), ['default' => 666]),
848847
['type'],
849848
new Column('col_int', Type::getType('smallint'), ['default' => 666]),
850849
);
851850

852851
$tableDiff->changedColumns['col_string'] = new ColumnDiff(
853-
'col_string',
854852
new Column('col_string', Type::getType('string'), [
855853
'length' => 3,
856854
'fixed' => true,

tests/Platforms/AbstractPlatformTestCase.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ public function testGeneratesTableAlterationSql(): void
249249
$tableDiff->addedColumns['quota'] = new Column('quota', Type::getType('integer'), ['notnull' => false]);
250250
$tableDiff->removedColumns['foo'] = new Column('foo', Type::getType('integer'));
251251
$tableDiff->changedColumns['bar'] = new ColumnDiff(
252-
'bar',
253252
new Column(
254253
'baz',
255254
Type::getType('string'),
@@ -263,7 +262,6 @@ public function testGeneratesTableAlterationSql(): void
263262
);
264263

265264
$tableDiff->changedColumns['bloo'] = new ColumnDiff(
266-
'bloo',
267265
new Column(
268266
'bloo',
269267
Type::getType('boolean'),
@@ -367,7 +365,6 @@ public function testGetAlterTableSqlDispatchEvent(): void
367365
$tableDiff->addedColumns['added'] = new Column('added', Type::getType('integer'), []);
368366
$tableDiff->removedColumns['removed'] = new Column('removed', Type::getType('integer'), []);
369367
$tableDiff->changedColumns['changed'] = new ColumnDiff(
370-
'changed',
371368
new Column('changed2', Type::getType('string'), ['length' => 255]),
372369
[],
373370
$table->getColumn('changed'),
@@ -615,7 +612,6 @@ public function testAlterTableChangeQuotedColumn(): void
615612
$tableDiff = new TableDiff('mytable');
616613
$tableDiff->fromTable = $table;
617614
$tableDiff->changedColumns['select'] = new ColumnDiff(
618-
'select',
619615
new Column(
620616
'select',
621617
Type::getType('string'),
@@ -1134,7 +1130,6 @@ public function testQuotesTableIdentifiersInAlterTableSQL(): void
11341130
$tableDiff->newName = 'table';
11351131
$tableDiff->addedColumns['bloo'] = new Column('bloo', Type::getType('integer'));
11361132
$tableDiff->changedColumns['bar'] = new ColumnDiff(
1137-
'bar',
11381133
new Column('bar', Type::getType('integer'), ['notnull' => false]),
11391134
['notnull'],
11401135
$table->getColumn('bar'),
@@ -1163,7 +1158,6 @@ public function testAlterStringToFixedString(): void
11631158
$tableDiff->fromTable = $table;
11641159

11651160
$tableDiff->changedColumns['name'] = new ColumnDiff(
1166-
'name',
11671161
new Column(
11681162
'name',
11691163
Type::getType('string'),

tests/Platforms/DB2PlatformTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ public function testGeneratesAlterColumnSQL(
522522
): void {
523523
$tableDiff = new TableDiff('foo');
524524
$tableDiff->fromTable = new Table('foo');
525-
$tableDiff->changedColumns['bar'] = new ColumnDiff('bar', $column, [$changedProperty], $column);
525+
$tableDiff->changedColumns['bar'] = new ColumnDiff($column, [$changedProperty], $column);
526526

527527
$expectedSQL = [];
528528

tests/Platforms/SQLServerPlatformTestCase.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,6 @@ public function testAlterTableWithSchemaDropColumnComments(): void
681681
{
682682
$tableDiff = new TableDiff('testschema.mytable');
683683
$tableDiff->changedColumns['quota'] = new ColumnDiff(
684-
'quota',
685684
new Column('quota', Type::getType('integer'), []),
686685
['comment'],
687686
new Column('quota', Type::getType('integer'), ['comment' => 'A comment']),
@@ -699,7 +698,6 @@ public function testAlterTableWithSchemaUpdateColumnComments(): void
699698
{
700699
$tableDiff = new TableDiff('testschema.mytable');
701700
$tableDiff->changedColumns['quota'] = new ColumnDiff(
702-
'quota',
703701
new Column('quota', Type::getType('integer'), ['comment' => 'B comment']),
704702
['comment'],
705703
new Column('quota', Type::getType('integer'), ['comment' => 'A comment']),
@@ -818,47 +816,41 @@ public function testGeneratesAlterTableSQLWithColumnComments(): void
818816

819817
// Add comment to non-commented column.
820818
$tableDiff->changedColumns['id'] = new ColumnDiff(
821-
'id',
822819
new Column('id', Type::getType('integer'), ['autoincrement' => true, 'comment' => 'primary']),
823820
['comment'],
824821
new Column('id', Type::getType('integer'), ['autoincrement' => true]),
825822
);
826823

827824
// Change type to custom type from empty string commented column.
828825
$tableDiff->changedColumns['comment_empty_string'] = new ColumnDiff(
829-
'comment_empty_string',
830826
new Column('comment_empty_string', Type::getType('json')),
831827
['type'],
832828
new Column('comment_empty_string', Type::getType('integer'), ['comment' => '']),
833829
);
834830

835831
// Change comment to empty comment from zero-string commented column.
836832
$tableDiff->changedColumns['comment_string_0'] = new ColumnDiff(
837-
'comment_string_0',
838833
new Column('comment_string_0', Type::getType('integer'), ['comment' => '']),
839834
['comment'],
840835
new Column('comment_string_0', Type::getType('integer'), ['comment' => '0']),
841836
);
842837

843838
// Remove comment from regular commented column.
844839
$tableDiff->changedColumns['comment'] = new ColumnDiff(
845-
'comment',
846840
new Column('comment', Type::getType('integer')),
847841
['comment'],
848842
new Column('comment', Type::getType('integer'), ['comment' => 'Doctrine 0wnz you!']),
849843
);
850844

851845
// Change comment and change type to custom type from regular commented column.
852846
$tableDiff->changedColumns['`comment_quoted`'] = new ColumnDiff(
853-
'`comment_quoted`',
854847
new Column('`comment_quoted`', Type::getType('json'), ['comment' => 'Doctrine JSON.']),
855848
['comment', 'type'],
856849
new Column('`comment_quoted`', Type::getType('integer'), ['comment' => 'Doctrine 0wnz you!']),
857850
);
858851

859852
// Remove comment and change type to custom type from regular commented column.
860853
$tableDiff->changedColumns['create'] = new ColumnDiff(
861-
'create',
862854
new Column('create', Type::getType('json')),
863855
['comment', 'type'],
864856
new Column(
@@ -870,23 +862,20 @@ public function testGeneratesAlterTableSQLWithColumnComments(): void
870862

871863
// Add comment and change custom type to regular type from non-commented column.
872864
$tableDiff->changedColumns['commented_type'] = new ColumnDiff(
873-
'commented_type',
874865
new Column('commented_type', Type::getType('integer'), ['comment' => 'foo']),
875866
['comment', 'type'],
876867
new Column('commented_type', Type::getType('json')),
877868
);
878869

879870
// Remove comment from commented custom type column.
880871
$tableDiff->changedColumns['commented_type_with_comment'] = new ColumnDiff(
881-
'commented_type_with_comment',
882872
new Column('commented_type_with_comment', Type::getType('json')),
883873
['comment'],
884874
new Column('commented_type_with_comment', Type::getType('json'), ['comment' => 'Doctrine JSON type.']),
885875
);
886876

887877
// Change comment from comment with string literal char column.
888878
$tableDiff->changedColumns['comment_with_string_literal_char'] = new ColumnDiff(
889-
'comment_with_string_literal_char',
890879
new Column('comment_with_string_literal_char', Type::getType('string'), ['comment' => "'"]),
891880
['comment'],
892881
new Column('comment_with_string_literal_char', Type::getType('json'), ['comment' => "O'Reilly"]),
@@ -1074,14 +1063,12 @@ public function testChangeColumnsTypeWithDefaultValue(): void
10741063
$tableDiff = new TableDiff($tableName);
10751064
$tableDiff->fromTable = $table;
10761065
$tableDiff->changedColumns['col_int'] = new ColumnDiff(
1077-
'col_int',
10781066
new Column('col_int', Type::getType('integer'), ['default' => 666]),
10791067
['type'],
10801068
new Column('col_int', Type::getType('smallint'), ['default' => 666]),
10811069
);
10821070

10831071
$tableDiff->changedColumns['col_string'] = new ColumnDiff(
1084-
'col_string',
10851072
new Column('col_string', Type::getType('string'), [
10861073
'length' => 255,
10871074
'fixed' => true,
@@ -1244,7 +1231,6 @@ public static function getGeneratesIdentifierNamesInAlterTableSQL(): iterable
12441231
],
12451232
[
12461233
'mycolumn' => new ColumnDiff(
1247-
'mycolumn',
12481234
new Column('mycolumn', Type::getType('string'), [
12491235
'length' => 255,
12501236
'default' => 'bar',
@@ -1284,7 +1270,6 @@ public static function getGeneratesIdentifierNamesInAlterTableSQL(): iterable
12841270
],
12851271
[
12861272
'mycolumn' => new ColumnDiff(
1287-
'`mycolumn`',
12881273
new Column('`mycolumn`', Type::getType('string'), [
12891274
'length' => 255,
12901275
'default' => 'bar',
@@ -1324,7 +1309,6 @@ public static function getGeneratesIdentifierNamesInAlterTableSQL(): iterable
13241309
],
13251310
[
13261311
'select' => new ColumnDiff(
1327-
'select',
13281312
new Column('select', Type::getType('string'), [
13291313
'length' => 255,
13301314
'default' => 'bar',
@@ -1364,7 +1348,6 @@ public static function getGeneratesIdentifierNamesInAlterTableSQL(): iterable
13641348
],
13651349
[
13661350
'select' => new ColumnDiff(
1367-
'`select`',
13681351
new Column('`select`', Type::getType('string'), [
13691352
'length' => 255,
13701353
'default' => 'bar',
@@ -1641,7 +1624,6 @@ public function testAlterTableWithSchemaSameColumnComments(): void
16411624
{
16421625
$tableDiff = new TableDiff('testschema.mytable');
16431626
$tableDiff->changedColumns['quota'] = new ColumnDiff(
1644-
'quota',
16451627
new Column('quota', Type::getType('integer'), ['comment' => 'A comment', 'notnull' => true]),
16461628
['notnull'],
16471629
new Column('quota', Type::getType('integer'), ['comment' => 'A comment', 'notnull' => false]),

tests/Schema/ColumnDiffTest.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/Schema/ComparatorTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,6 @@ public function testCompareChangedColumn(): void
998998
$tableDiff->fromTable = $tableFoo;
999999

10001000
$tableDiff->changedColumns['id'] = new ColumnDiff(
1001-
'id',
10021001
$table->getColumn('id'),
10031002
['type'],
10041003
$tableFoo->getColumn('id'),
@@ -1025,7 +1024,6 @@ public function testCompareChangedBinaryColumn(): void
10251024
$tableDiff->fromTable = $tableFoo;
10261025

10271026
$tableDiff->changedColumns['id'] = new ColumnDiff(
1028-
'id',
10291027
$table->getColumn('id'),
10301028
['length', 'fixed'],
10311029
$tableFoo->getColumn('id'),

0 commit comments

Comments
 (0)