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::getName() #4755

Merged
merged 3 commits into from
Aug 26, 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
9 changes: 9 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ awareness about deprecated code.

# Upgrade to 3.2

## Deprecated `AbstractPlatform::getName()`

Relying on the name of the platform is discouraged. To identify the platform, use its class name.

## Deprecated versioned platform classes that represent the lowest supported version:

1. `PostgreSQL94Platform` and `PostgreSQL94Keywords`. Use `PostgreSQLPlatform` and `PostgreSQLKeywords` instead.
2. `SQLServer2012Platform` and `SQLServer2012Keywords`. Use `SQLServerPlatform` and `SQLServerKeywords` instead.

## Deprecated schema comparison APIs that don't account for the current database connection and the database platform

1. Instantiation of the `Comparator` class outside the DBAL is deprecated. Use `SchemaManager::createComparator()`
Expand Down
4 changes: 2 additions & 2 deletions docs/en/reference/platforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ Oracle
Microsoft SQL Server
^^^^^^^^^^^^^^^^^^^^

- ``SQLServer2012Platform`` for version 2012 and above.
- ``SQLServerPlatform`` for version 2012 and above.

PostgreSQL
^^^^^^^^^^

- ``PostgreSQL94Platform`` for version 9.4 and above.
- ``PostgreSQLPlatform`` for version 9.4 and above.
- ``PostgreSQL100Platform`` for version 10.0 and above.

SQLite
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ parameters:
-
message: '~^Only numeric types are allowed in -, int<1, max>\|false given on the left side\.~'
paths:
- %currentWorkingDirectory%/src/Platforms/SQLServer2012Platform.php
- %currentWorkingDirectory%/src/Platforms/SQLServerPlatform.php

# Unlike Psalm, PHPStan doesn't understand the shape of the parse_str() return value
-
Expand All @@ -95,7 +95,7 @@ parameters:
-
message: '~^Only numeric types are allowed in pre\-decrement, int\<1, max\>\|false given\.$~'
paths:
- %currentWorkingDirectory%/src/Platforms/SQLServer2012Platform.php
- %currentWorkingDirectory%/src/Platforms/SQLServerPlatform.php

# https://github.com/phpstan/phpstan-phpunit/issues/83
-
Expand Down
9 changes: 8 additions & 1 deletion psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@
-->
<referencedClass name="Doctrine\DBAL\Driver\ServerInfoAwareConnection"/>
<referencedClass name="Doctrine\DBAL\VersionAwarePlatformDriver"/>
<!--
TODO: remove in 4.0.0
-->
<referencedClass name="Doctrine\DBAL\Platforms\Keywords\PostgreSQL94Keywords"/>
<referencedClass name="Doctrine\DBAL\Platforms\Keywords\SQLServer2012Keywords"/>
<referencedClass name="Doctrine\DBAL\Platforms\PostgreSQL94Platform"/>
<referencedClass name="Doctrine\DBAL\Platforms\SQLServer2012Platform"/>
</errorLevel>
</DeprecatedClass>
<DeprecatedInterface>
Expand Down Expand Up @@ -177,7 +184,7 @@
<file name="src/DriverManager.php"/>
<file name="src/Platforms/AbstractPlatform.php"/>
<file name="src/Platforms/MySQLPlatform.php"/>
<file name="src/Platforms/SQLServer2012Platform.php"/>
<file name="src/Platforms/SQLServerPlatform.php"/>
<file name="src/Platforms/SqlitePlatform.php"/>
<file name="src/Schema/Column.php"/>
<!--
Expand Down
4 changes: 3 additions & 1 deletion src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ abstract public function getBlobTypeDeclarationSQL(array $column);
/**
* Gets the name of the platform.
*
* @deprecated Identify platforms by their class.
*
* @return string
*/
abstract public function getName();
Expand Down Expand Up @@ -3690,7 +3692,7 @@ protected function doModifyLimitQuery($query, $limit, $offset)
*/
public function supportsLimitOffset()
{
Deprecation::trigger(
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pulls/4724',
'AbstractPlatform::supportsViews() is deprecated.'
Expand Down
6 changes: 6 additions & 0 deletions src/Platforms/DB2Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ public function getClobTypeDeclarationSQL(array $column)
*/
public function getName()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4749',
'DB2Platform::getName() is deprecated. Identify platforms by their class.'
);

return 'db2';
}

Expand Down
119 changes: 3 additions & 116 deletions src/Platforms/Keywords/PostgreSQL94Keywords.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,122 +4,9 @@

/**
* PostgreSQL 9.4 reserved keywords list.
*
* @deprecated Use {@link PostgreSQLKeywords} instead.
*/
class PostgreSQL94Keywords extends KeywordList
class PostgreSQL94Keywords extends PostgreSQLKeywords
{
/**
* {@inheritdoc}
*/
public function getName()
{
return 'PostgreSQL';
}

/**
* {@inheritdoc}
*/
protected function getKeywords()
{
return [
'ALL',
'ANALYSE',
'ANALYZE',
'AND',
'ANY',
'ARRAY',
'AS',
'ASC',
'ASYMMETRIC',
'AUTHORIZATION',
'BINARY',
'BOTH',
'CASE',
'CAST',
'CHECK',
'COLLATE',
'COLLATION',
'COLUMN',
'CONCURRENTLY',
'CONSTRAINT',
'CREATE',
'CROSS',
'CURRENT_CATALOG',
'CURRENT_DATE',
'CURRENT_ROLE',
'CURRENT_SCHEMA',
'CURRENT_TIME',
'CURRENT_TIMESTAMP',
'CURRENT_USER',
'DEFAULT',
'DEFERRABLE',
'DESC',
'DISTINCT',
'DO',
'ELSE',
'END',
'EXCEPT',
'FALSE',
'FETCH',
'FOR',
'FOREIGN',
'FREEZE',
'FROM',
'FULL',
'GRANT',
'GROUP',
'HAVING',
'ILIKE',
'IN',
'INITIALLY',
'INNER',
'INTERSECT',
'INTO',
'IS',
'ISNULL',
'JOIN',
'LATERAL',
'LEADING',
'LEFT',
'LIKE',
'LIMIT',
'LOCALTIME',
'LOCALTIMESTAMP',
'NATURAL',
'NOT',
'NOTNULL',
'NULL',
'OFFSET',
'ON',
'ONLY',
'OR',
'ORDER',
'OUTER',
'OVERLAPS',
'PLACING',
'PRIMARY',
'REFERENCES',
'RETURNING',
'RIGHT',
'SELECT',
'SESSION_USER',
'SIMILAR',
'SOME',
'SYMMETRIC',
'TABLE',
'THEN',
'TO',
'TRAILING',
'TRUE',
'UNION',
'UNIQUE',
'USER',
'USING',
'VARIADIC',
'VERBOSE',
'WHEN',
'WHERE',
'WINDOW',
'WITH',
];
}
}
125 changes: 125 additions & 0 deletions src/Platforms/Keywords/PostgreSQLKeywords.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?php

namespace Doctrine\DBAL\Platforms\Keywords;

/**
* Reserved keywords list corresponding to the PostgreSQL database platform of the oldest supported version.
*/
class PostgreSQLKeywords extends KeywordList
{
/**
* {@inheritdoc}
*/
public function getName()
{
return 'PostgreSQL';
}

/**
* {@inheritdoc}
*/
protected function getKeywords()
{
return [
'ALL',
'ANALYSE',
'ANALYZE',
'AND',
'ANY',
'ARRAY',
'AS',
'ASC',
'ASYMMETRIC',
'AUTHORIZATION',
'BINARY',
'BOTH',
'CASE',
'CAST',
'CHECK',
'COLLATE',
'COLLATION',
'COLUMN',
'CONCURRENTLY',
'CONSTRAINT',
'CREATE',
'CROSS',
'CURRENT_CATALOG',
'CURRENT_DATE',
'CURRENT_ROLE',
'CURRENT_SCHEMA',
'CURRENT_TIME',
'CURRENT_TIMESTAMP',
'CURRENT_USER',
'DEFAULT',
'DEFERRABLE',
'DESC',
'DISTINCT',
'DO',
'ELSE',
'END',
'EXCEPT',
'FALSE',
'FETCH',
'FOR',
'FOREIGN',
'FREEZE',
'FROM',
'FULL',
'GRANT',
'GROUP',
'HAVING',
'ILIKE',
'IN',
'INITIALLY',
'INNER',
'INTERSECT',
'INTO',
'IS',
'ISNULL',
'JOIN',
'LATERAL',
'LEADING',
'LEFT',
'LIKE',
'LIMIT',
'LOCALTIME',
'LOCALTIMESTAMP',
'NATURAL',
'NOT',
'NOTNULL',
'NULL',
'OFFSET',
'ON',
'ONLY',
'OR',
'ORDER',
'OUTER',
'OVERLAPS',
'PLACING',
'PRIMARY',
'REFERENCES',
'RETURNING',
'RIGHT',
'SELECT',
'SESSION_USER',
'SIMILAR',
'SOME',
'SYMMETRIC',
'TABLE',
'THEN',
'TO',
'TRAILING',
'TRUE',
'UNION',
'UNIQUE',
'USER',
'USING',
'VARIADIC',
'VERBOSE',
'WHEN',
'WHERE',
'WINDOW',
'WITH',
];
}
}
Loading