Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate AbstractPlatform::prefersIdentityColumns() #5119

Merged
merged 1 commit into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@
See https://github.com/doctrine/dbal/pull/4966
-->
<referencedMethod name="Doctrine\DBAL\Connection::getWrappedConnection"/>
<!--
TODO: remove in 4.0.0
See https://github.com/doctrine/dbal/pull/1519
-->
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractMySQLPlatform::prefersIdentityColumns"/>
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::prefersIdentityColumns"/>
<referencedMethod name="Doctrine\DBAL\Platforms\DB2Platform::prefersIdentityColumns"/>
<referencedMethod name="Doctrine\DBAL\Platforms\SQLServerPlatform::prefersIdentityColumns"/>
<referencedMethod name="Doctrine\DBAL\Platforms\SqlitePlatform::prefersIdentityColumns"/>
</errorLevel>
</DeprecatedMethod>
<DeprecatedProperty>
Expand Down
8 changes: 8 additions & 0 deletions src/Platforms/AbstractMySQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions src/Platforms/DB2Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions src/Platforms/SQLServerPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions src/Platforms/SqlitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/WriteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}

Expand Down