Skip to content

Commit 039b945

Browse files
committed
Merge branch '3.5.x' into 4.0.x
2 parents 0e15462 + 0361d33 commit 039b945

17 files changed

+234
-49
lines changed

UPGRADE.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,11 +734,23 @@ The following methods have been removed.
734734

735735
# Upgrade to 3.5
736736

737+
## Deprecated "unique" and "check" column properties.
738+
739+
The "unique" and "check" column properties have been deprecated. Use unique constraints to define unique columns.
740+
737741
## Deprecated relying on the default precision and scale of decimal columns.
738742

739743
Relying on the default precision and scale of decimal columns provided by the DBAL is deprecated.
740744
When declaring decimal columns, specify the precision and scale explicitly.
741745

746+
## Deprecated renaming tables via `TableDiff` and `AbstractPlatform::alterTable()`.
747+
748+
Renaming tables via setting the `$newName` property on a `TableDiff` and passing it to `AbstractPlatform::alterTable()`
749+
is deprecated. The implementations of `AbstractSchemaManager::alterTable()` should use `AbstractPlatform::renameTable()`
750+
instead.
751+
752+
The `TableDiff::$newName` property and the `TableDiff::getNewName()` method have been deprecated.
753+
742754
## Marked `Comparator` methods as internal.
743755

744756
The following `Comparator` methods have been marked as internal:
@@ -788,6 +800,10 @@ The constructors of the following classes have been marked as internal:
788800
These classes can be instantiated only by schema comparators. The signatures of the constructors may change in future
789801
versions.
790802

803+
## Deprecated `SchemaDiff` reference to the original schema.
804+
805+
The `SchemaDiff::$fromSchema` property has been deprecated.
806+
791807
## Marked `AbstractSchemaManager::_execSql()` as internal.
792808

793809
The `AbstractSchemaManager::_execSql()` method has been marked as internal. It will not be available in 4.0.

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141
"require-dev": {
4242
"doctrine/coding-standard": "9.0.2",
4343
"jetbrains/phpstorm-stubs": "2022.2",
44-
"phpstan/phpstan": "1.8.2",
44+
"phpstan/phpstan": "1.8.3",
4545
"phpstan/phpstan-phpunit": "1.1.1",
4646
"phpstan/phpstan-strict-rules": "^1.3",
47-
"phpunit/phpunit": "9.5.21",
47+
"phpunit/phpunit": "9.5.24",
4848
"psalm/plugin-phpunit": "0.17.0",
4949
"squizlabs/php_codesniffer": "3.7.1",
5050
"symfony/cache": "^5.4|^6.0",
5151
"symfony/console": "^4.4.30|^5.4|^6.0",
52-
"vimeo/psalm": "4.24.0"
52+
"vimeo/psalm": "4.27.0"
5353
},
5454
"suggest": {
5555
"symfony/console": "For helpful console commands such as SQL execution and import of files."

docs/en/reference/schema-representation.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ The following options are considered to be fully portable across all database pl
107107
- **customSchemaOptions** (array): Additional options for the column that are
108108
supported by all vendors:
109109

110-
- **unique** (boolean): Whether to automatically add a unique constraint for the column.
111-
Defaults to ``false``.
112-
113110
Common options
114111
^^^^^^^^^^^^^^
115112

@@ -138,5 +135,3 @@ The following options are completely vendor specific and absolutely not portable
138135
on MySQL.
139136
- **collation** (string): The collation to use for the column. Supported by MySQL, PostgreSQL,
140137
Sqlite and SQL Server.
141-
- **check** (string): The check constraint clause to add to the column.
142-
Defaults to ``null``.

phpstan.neon.dist

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ parameters:
2727
-
2828
message: '~^Only booleans are allowed in .*, mixed given~'
2929
paths:
30-
- src/Driver/*/Driver.php
3130
- src/Platforms/*Platform.php
3231
- src/Schema/*SchemaManager.php
3332

@@ -77,11 +76,6 @@ parameters:
7776
- src/Driver/Mysqli/Exception/InvalidCharset.php
7877
- src/Driver/Mysqli/Exception/StatementError.php
7978

80-
-
81-
message: '~^Unable to resolve the template type T in call to method Doctrine\\DBAL\\Portability\\Converter\:\:compose\(\)$~'
82-
paths:
83-
- src/Portability/Converter.php
84-
8579
# We're testing with invalid input.
8680
-
8781
message: '~^Parameter #2 \$lockMode of method Doctrine\\DBAL\\Platforms\\AbstractPlatform\:\:appendLockHint\(\) expects 0\|1\|2\|4, 128 given\.$~'

psalm.xml.dist

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,26 @@
3939
See https://github.com/doctrine/dbal/pull/4317
4040
-->
4141
<file name="tests/Functional/LegacyAPITest.php"/>
42+
<!--
43+
TODO: remove in 4.0.0
44+
-->
45+
<referencedMethod name="Doctrine\DBAL\Schema\TableDiff::getNewName"/>
4246
</errorLevel>
4347
</DeprecatedMethod>
44-
<DocblockTypeContradiction>
48+
<DeprecatedProperty>
4549
<errorLevel type="suppress">
4650
<!--
47-
Requires a release of https://github.com/JetBrains/phpstorm-stubs/pull/1158
51+
TODO: remove in 4.0.0
52+
-->
53+
<referencedProperty name="Doctrine\DBAL\Schema\SchemaDiff::$fromSchema"/>
54+
<!--
55+
TODO: remove in 4.0.0
4856
-->
49-
<file name="src/Driver/IBMDB2/Connection.php"/>
57+
<referencedProperty name="Doctrine\DBAL\Schema\TableDiff::$newName"/>
58+
</errorLevel>
59+
</DeprecatedProperty>
60+
<DocblockTypeContradiction>
61+
<errorLevel type="suppress">
5062
<!--
5163
These issues can be mostly divided in the following categories:
5264
1. Union types not supported at the language level (require dropping PHP 7 support)

src/Platforms/AbstractMySQLPlatform.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\DBAL\Schema\Table;
1616
use Doctrine\DBAL\Schema\TableDiff;
1717
use Doctrine\DBAL\TransactionIsolationLevel;
18+
use Doctrine\Deprecations\Deprecation;
1819

1920
use function array_merge;
2021
use function array_unique;
@@ -313,6 +314,12 @@ public function getAlterTableSQL(TableDiff $diff): array
313314
$newName = $diff->getNewName();
314315

315316
if ($newName !== null) {
317+
Deprecation::trigger(
318+
'doctrine/dbal',
319+
'https://github.com/doctrine/dbal/pull/5663',
320+
'Generation of SQL that renames a table using %s is deprecated. Use getRenameTableSQL() instead.',
321+
__METHOD__,
322+
);
316323
$queryParts[] = 'RENAME TO ' . $newName->getQuotedName($this);
317324
}
318325

src/Platforms/AbstractPlatform.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
use Doctrine\DBAL\Types;
3939
use Doctrine\DBAL\Types\Exception\TypeNotFound;
4040
use Doctrine\DBAL\Types\Type;
41+
use Doctrine\Deprecations\Deprecation;
4142
use InvalidArgumentException;
4243
use UnexpectedValueException;
4344

@@ -1286,6 +1287,14 @@ public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, string
12861287
*/
12871288
abstract public function getAlterTableSQL(TableDiff $diff): array;
12881289

1290+
/** @return list<string> */
1291+
public function getRenameTableSQL(string $oldName, string $newName): array
1292+
{
1293+
return [
1294+
sprintf('ALTER TABLE %s RENAME TO %s', $oldName, $newName),
1295+
];
1296+
}
1297+
12891298
/** @param mixed[] $columnSql */
12901299
protected function onSchemaAlterTableAddColumn(Column $column, TableDiff $diff, array &$columnSql): bool
12911300
{
@@ -1557,9 +1566,29 @@ public function getColumnDeclarationSQL(string $name, array $column): string
15571566

15581567
$notnull = ! empty($column['notnull']) ? ' NOT NULL' : '';
15591568

1560-
$unique = ! empty($column['unique']) ? ' UNIQUE' : '';
1569+
if (! empty($column['unique'])) {
1570+
Deprecation::trigger(
1571+
'doctrine/dbal',
1572+
'https://github.com/doctrine/dbal/pull/5656',
1573+
'The usage of the "unique" column property is deprecated. Use unique constraints instead.',
1574+
);
15611575

1562-
$check = ! empty($column['check']) ? ' ' . $column['check'] : '';
1576+
$unique = ' UNIQUE';
1577+
} else {
1578+
$unique = '';
1579+
}
1580+
1581+
if (! empty($column['check'])) {
1582+
Deprecation::trigger(
1583+
'doctrine/dbal',
1584+
'https://github.com/doctrine/dbal/pull/5656',
1585+
'The usage of the "check" column property is deprecated.',
1586+
);
1587+
1588+
$check = ' ' . $column['check'];
1589+
} else {
1590+
$check = '';
1591+
}
15631592

15641593
$typeDecl = $column['type']->getSQLDeclaration($column, $this);
15651594
$declaration = $typeDecl . $charset . $default . $notnull . $unique . $check . $collation;

src/Platforms/DB2Platform.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\DBAL\Schema\Index;
1616
use Doctrine\DBAL\Schema\TableDiff;
1717
use Doctrine\DBAL\TransactionIsolationLevel;
18+
use Doctrine\Deprecations\Deprecation;
1819

1920
use function array_merge;
2021
use function count;
@@ -351,6 +352,12 @@ public function getAlterTableSQL(TableDiff $diff): array
351352
$newName = $diff->getNewName();
352353

353354
if ($newName !== null) {
355+
Deprecation::trigger(
356+
'doctrine/dbal',
357+
'https://github.com/doctrine/dbal/pull/5663',
358+
'Generation of "rename table" SQL using %s is deprecated. Use getRenameTableSQL() instead.',
359+
__METHOD__,
360+
);
354361
$sql[] = sprintf(
355362
'RENAME TABLE %s TO %s',
356363
$diff->getName($this)->getQuotedName($this),
@@ -368,6 +375,16 @@ public function getAlterTableSQL(TableDiff $diff): array
368375
return array_merge($sql, $tableSql, $columnSql);
369376
}
370377

378+
/**
379+
* {@inheritDoc}
380+
*/
381+
public function getRenameTableSQL(string $oldName, string $newName): array
382+
{
383+
return [
384+
sprintf('RENAME TABLE %s TO %s', $oldName, $newName),
385+
];
386+
}
387+
371388
/**
372389
* Gathers the table alteration SQL for a given column diff.
373390
*

src/Platforms/OraclePlatform.php

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\DBAL\Schema\Sequence;
1616
use Doctrine\DBAL\Schema\TableDiff;
1717
use Doctrine\DBAL\TransactionIsolationLevel;
18+
use Doctrine\Deprecations\Deprecation;
1819
use InvalidArgumentException;
1920

2021
use function array_merge;
@@ -625,6 +626,12 @@ public function getAlterTableSQL(TableDiff $diff): array
625626
$newName = $diff->getNewName();
626627

627628
if ($newName !== null) {
629+
Deprecation::trigger(
630+
'doctrine/dbal',
631+
'https://github.com/doctrine/dbal/pull/5663',
632+
'Generation of "rename table" SQL using %s is deprecated. Use getRenameTableSQL() instead.',
633+
__METHOD__,
634+
);
628635
$sql[] = sprintf(
629636
'ALTER TABLE %s RENAME TO %s',
630637
$diff->getName($this)->getQuotedName($this),
@@ -660,10 +667,29 @@ public function getColumnDeclarationSQL(string $name, array $column): string
660667
$notnull = $column['notnull'] ? ' NOT NULL' : ' NULL';
661668
}
662669

663-
$unique = ! empty($column['unique']) ? ' UNIQUE' : '';
670+
if (! empty($column['unique'])) {
671+
Deprecation::trigger(
672+
'doctrine/dbal',
673+
'https://github.com/doctrine/dbal/pull/5656',
674+
'The usage of the "unique" column property is deprecated. Use unique constraints instead.',
675+
);
676+
677+
$unique = ' UNIQUE';
678+
} else {
679+
$unique = '';
680+
}
664681

665-
$check = ! empty($column['check']) ?
666-
' ' . $column['check'] : '';
682+
if (! empty($column['check'])) {
683+
Deprecation::trigger(
684+
'doctrine/dbal',
685+
'https://github.com/doctrine/dbal/pull/5656',
686+
'The usage of the "check" column property is deprecated.',
687+
);
688+
689+
$check = ' ' . $column['check'];
690+
} else {
691+
$check = '';
692+
}
667693

668694
$typeDecl = $column['type']->getSQLDeclaration($column, $this);
669695
$columnDef = $typeDecl . $default . $notnull . $unique . $check;

src/Platforms/PostgreSQLPlatform.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\DBAL\Schema\Sequence;
1515
use Doctrine\DBAL\Schema\TableDiff;
1616
use Doctrine\DBAL\TransactionIsolationLevel;
17+
use Doctrine\Deprecations\Deprecation;
1718
use UnexpectedValueException;
1819

1920
use function array_merge;
@@ -346,6 +347,12 @@ public function getAlterTableSQL(TableDiff $diff): array
346347
$newName = $diff->getNewName();
347348

348349
if ($newName !== null) {
350+
Deprecation::trigger(
351+
'doctrine/dbal',
352+
'https://github.com/doctrine/dbal/pull/5663',
353+
'Generation of "rename table" SQL using %s is deprecated. Use getRenameTableSQL() instead.',
354+
__METHOD__,
355+
);
349356
$sql[] = sprintf(
350357
'ALTER TABLE %s RENAME TO %s',
351358
$diff->getName($this)->getQuotedName($this),

0 commit comments

Comments
 (0)