diff --git a/UPGRADE.md b/UPGRADE.md index 3f5fc6a45f4..8197a7b6e3c 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -220,6 +220,11 @@ Relying on the name of the platform is discouraged. To identify the platform, us The `ServerInfoAwareConnection` and `VersionAwarePlatformDriver` interfaces are deprecated. In the next major version, all drivers and driver connections will be required to implement the APIs aware of the server version. +## Deprecated `AbstractPlatform::prefersIdentityColumns()`. + +Whether to use identity columns should be decided by the application developer. For example, based on the set +of supported database platforms. + ## Deprecated `AbstractPlatform::getNowExpression()`. Relying on dates generated by the database is deprecated. Generate dates within the application. diff --git a/psalm.xml.dist b/psalm.xml.dist index 80a094d4cf2..f63a1c8ef43 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -210,6 +210,15 @@ See https://github.com/doctrine/dbal/pull/4966 --> + + + + + + diff --git a/src/Platforms/AbstractMySQLPlatform.php b/src/Platforms/AbstractMySQLPlatform.php index f95d58d29d7..9030f30c3da 100644 --- a/src/Platforms/AbstractMySQLPlatform.php +++ b/src/Platforms/AbstractMySQLPlatform.php @@ -279,11 +279,19 @@ public function getBooleanTypeDeclarationSQL(array $column) /** * {@inheritDoc} * + * @deprecated + * * MySQL prefers "autoincrement" identity columns since sequences can only * be emulated with a table. */ public function prefersIdentityColumns() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pulls/1519', + 'AbstractMySQLPlatform::prefersIdentityColumns() is deprecated.' + ); + return true; } diff --git a/src/Platforms/AbstractPlatform.php b/src/Platforms/AbstractPlatform.php index 37b1482140e..198542195fb 100644 --- a/src/Platforms/AbstractPlatform.php +++ b/src/Platforms/AbstractPlatform.php @@ -2914,10 +2914,18 @@ public function getColumnCollationDeclarationSQL($collation) * Whether the platform prefers identity columns (eg. autoincrement) for ID generation. * Subclasses should override this method to return TRUE if they prefer identity columns. * + * @deprecated + * * @return bool */ public function prefersIdentityColumns() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pulls/1519', + 'AbstractPlatform::prefersIdentityColumns() is deprecated.' + ); + return false; } diff --git a/src/Platforms/DB2Platform.php b/src/Platforms/DB2Platform.php index 90ba9aa34b2..264ef3f4266 100644 --- a/src/Platforms/DB2Platform.php +++ b/src/Platforms/DB2Platform.php @@ -847,9 +847,17 @@ public function supportsIdentityColumns() /** * {@inheritDoc} + * + * @deprecated */ public function prefersIdentityColumns() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pulls/1519', + 'DB2Platform::prefersIdentityColumns() is deprecated.' + ); + return true; } diff --git a/src/Platforms/SQLServerPlatform.php b/src/Platforms/SQLServerPlatform.php index c9e8150ade5..732cb636346 100644 --- a/src/Platforms/SQLServerPlatform.php +++ b/src/Platforms/SQLServerPlatform.php @@ -98,9 +98,17 @@ public function getDateDiffExpression($date1, $date2) * * Microsoft SQL Server prefers "autoincrement" identity columns * since sequences can only be emulated with a table. + * + * @deprecated */ public function prefersIdentityColumns() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pulls/1519', + 'SQLServerPlatform::prefersIdentityColumns() is deprecated.' + ); + return true; } diff --git a/src/Platforms/SqlitePlatform.php b/src/Platforms/SqlitePlatform.php index 2775ee49a3d..6d5adda49c8 100644 --- a/src/Platforms/SqlitePlatform.php +++ b/src/Platforms/SqlitePlatform.php @@ -205,9 +205,17 @@ public function getSetTransactionIsolationSQL($level) /** * {@inheritDoc} + * + * @deprecated */ public function prefersIdentityColumns() { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pulls/1519', + 'SqlitePlatform::prefersIdentityColumns() is deprecated.' + ); + return true; } diff --git a/tests/Functional/WriteTest.php b/tests/Functional/WriteTest.php index 92b7c3eb5e1..944dccdb62f 100644 --- a/tests/Functional/WriteTest.php +++ b/tests/Functional/WriteTest.php @@ -149,7 +149,7 @@ public function testUpdate(): void public function testLastInsertId(): void { - if (! $this->connection->getDatabasePlatform()->prefersIdentityColumns()) { + if (! $this->connection->getDatabasePlatform()->supportsIdentityColumns()) { self::markTestSkipped('Test only works on platforms with identity columns.'); }