Skip to content

Commit

Permalink
Merge pull request #4577 from morozov/issues/4503
Browse files Browse the repository at this point in the history
Remove deprecated schema- and namespace-related APIs
  • Loading branch information
morozov committed Apr 3, 2021
2 parents ba7bf25 + cf00e6a commit ac2763f
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 233 deletions.
15 changes: 15 additions & 0 deletions UPGRADE.md
@@ -1,5 +1,20 @@
# Upgrade to 4.0

## `PostgreSQLSchemaManager` methods have been made protected.

`PostgreSQLSchemaManager::getExistingSchemaSearchPaths()` and `::determineExistingSchemaSearchPaths()` have been made protected.
The former has also been made final.

## Removed schema- and namespace-related methods

The following schema- and namespace-related methods have been removed:

- `AbstractPlatform::getListNamespacesSQL()`,
- `AbstractSchemaManager::listNamespaceNames()`,
- `AbstractSchemaManager::getPortableNamespacesList()`,
- `AbstractSchemaManager::getPortableNamespaceDefinition()`,
- `PostgreSQLSchemaManager::getSchemaNames()`.

## Removed the `$driverOptions` argument of `PDO\Statement::bindParam()` and `PDO\SQLSrv\Statement::bindParam()`

The `$driverOptions` argument of `PDO\Statement::bindParam()` and `PDO\SQLSrv\Statement::bindParam()` has been removed. The specifics of binding a parameter to the statement should be specified using the `$type` argument.
Expand Down
17 changes: 0 additions & 17 deletions psalm.xml.dist
Expand Up @@ -59,15 +59,6 @@
See https://github.com/doctrine/dbal/issues/4510
-->
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getReservedKeywordsClass"/>
<!--
This suppression should be removed in 4.0.x
See https://github.com/doctrine/dbal/issues/4503
-->
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getListNamespacesSQL"/>
<referencedMethod name="Doctrine\DBAL\Schema\AbstractSchemaManager::getPortableNamespaceDefinition"/>
<referencedMethod name="Doctrine\DBAL\Schema\AbstractSchemaManager::getPortableNamespacesList"/>
<referencedMethod name="Doctrine\DBAL\Schema\AbstractSchemaManager::listNamespaceNames"/>
<referencedMethod name="Doctrine\DBAL\Schema\PostgreSQLSchemaManager::getSchemaNames"/>
</errorLevel>
</DeprecatedMethod>
<DocblockTypeContradiction>
Expand Down Expand Up @@ -125,12 +116,6 @@
<file name="src/Driver/OCI8/Connection.php"/>
</errorLevel>
</ImplementedReturnTypeMismatch>
<InvalidNullableReturnType>
<errorLevel type="suppress">
<!-- See https://github.com/doctrine/dbal/issues/4503 -->
<file name="src/Schema/PostgreSQLSchemaManager.php"/>
</errorLevel>
</InvalidNullableReturnType>
<InvalidPropertyAssignmentValue>
<errorLevel type="suppress">
<!-- Fixing this issue requires an API change -->
Expand All @@ -143,8 +128,6 @@
Fixing this issue requires an API change
-->
<file name="src/Driver/AbstractSQLiteDriver.php"/>
<!-- See https://github.com/doctrine/dbal/issues/4503 -->
<file name="src/Schema/PostgreSQLSchemaManager.php"/>
</errorLevel>
</NullableReturnStatement>
<PossiblyNullArgument>
Expand Down
19 changes: 0 additions & 19 deletions src/Platforms/AbstractPlatform.php
Expand Up @@ -2505,25 +2505,6 @@ public function getListDatabasesSQL(): string
throw NotSupported::new(__METHOD__);
}

/**
* Returns the SQL statement for retrieving the namespaces defined in the database.
*
* @deprecated Use {@link AbstractSchemaManager::listSchemaNames()} instead.
*
* @throws Exception If not supported on this platform.
*/
public function getListNamespacesSQL(): string
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'AbstractPlatform::getListNamespacesSQL() is deprecated,'
. ' use AbstractSchemaManager::listSchemaNames() instead.'
);

throw NotSupported::new(__METHOD__);
}

/**
* @throws Exception If not supported on this platform.
*/
Expand Down
18 changes: 0 additions & 18 deletions src/Platforms/PostgreSQL94Platform.php
Expand Up @@ -170,24 +170,6 @@ public function getListDatabasesSQL(): string
return 'SELECT datname FROM pg_database';
}

/**
* @deprecated Use {@link PostgreSQLSchemaManager::listSchemaNames()} instead.
*/
public function getListNamespacesSQL(): string
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'PostgreSQL94Platform::getListNamespacesSQL() is deprecated,'
. ' use PostgreSQLSchemaManager::listSchemaNames() instead.'
);

return "SELECT schema_name AS nspname
FROM information_schema.schemata
WHERE schema_name NOT LIKE 'pg\_%'
AND schema_name != 'information_schema'";
}

public function getListSequencesSQL(string $database): string
{
return "SELECT sequence_name AS relname,
Expand Down
15 changes: 0 additions & 15 deletions src/Platforms/SQLServer2012Platform.php
Expand Up @@ -1050,21 +1050,6 @@ public function getListDatabasesSQL(): string
return 'SELECT * FROM sys.databases';
}

/**
* @deprecated Use {@link SQLServerSchemaManager::listSchemaNames()} instead.
*/
public function getListNamespacesSQL(): string
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'SQLServer2012Platform::getListNamespacesSQL() is deprecated,'
. ' use SQLServerSchemaManager::listSchemaNames() instead.'
);

return "SELECT name FROM sys.schemas WHERE name NOT IN('guest', 'INFORMATION_SCHEMA', 'sys')";
}

public function getSubstringExpression(string $string, string $start, ?string $length = null): string
{
if ($length === null) {
Expand Down
68 changes: 1 addition & 67 deletions src/Schema/AbstractSchemaManager.php
Expand Up @@ -12,7 +12,6 @@
use Doctrine\DBAL\Exception\DatabaseRequired;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\Exception\NotSupported;
use Doctrine\Deprecations\Deprecation;
use Throwable;

use function array_filter;
Expand Down Expand Up @@ -98,31 +97,6 @@ public function listDatabases(): array
return $this->_getPortableDatabasesList($databases);
}

/**
* Returns a list of all namespaces in the current database.
*
* @deprecated Use {@link listSchemaNames()} instead.
*
* @return array<int, string>
*
* @throws Exception
*/
public function listNamespaceNames(): array
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'AbstractSchemaManager::listNamespaceNames() is deprecated,'
. ' use AbstractSchemaManager::listSchemaNames() instead.'
);

$sql = $this->_platform->getListNamespacesSQL();

$namespaces = $this->_conn->fetchAllAssociative($sql);

return $this->getPortableNamespacesList($namespaces);
}

/**
* Returns a list of the names of all schemata in the current database.
*
Expand Down Expand Up @@ -643,34 +617,6 @@ protected function _getPortableDatabasesList(array $databases): array
return $list;
}

/**
* Converts a list of namespace names from the native DBMS data definition to a portable Doctrine definition.
*
* @deprecated Use {@link listSchemaNames()} instead.
*
* @param array<int, array<string, mixed>> $namespaces The list of namespace names
* in the native DBMS data definition.
*
* @return array<int, string>
*/
protected function getPortableNamespacesList(array $namespaces): array
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'AbstractSchemaManager::getPortableNamespacesList() is deprecated,'
. ' use AbstractSchemaManager::listSchemaNames() instead.'
);

$namespacesList = [];

foreach ($namespaces as $namespace) {
$namespacesList[] = $this->getPortableNamespaceDefinition($namespace);
}

return $namespacesList;
}

/**
* @param array<string, string> $database
*/
Expand All @@ -681,18 +627,6 @@ protected function _getPortableDatabaseDefinition(array $database): string
return array_shift($database);
}

/**
* Converts a namespace definition from the native DBMS data definition to a portable Doctrine definition.
*
* @deprecated Use {@link listSchemaNames()} instead.
*
* @param array<string, mixed> $namespace The native DBMS namespace definition.
*/
protected function getPortableNamespaceDefinition(array $namespace): string
{
return array_shift($namespace);
}

/**
* @param array<int, array<string, mixed>> $sequences
*
Expand Down Expand Up @@ -973,7 +907,7 @@ public function createSchema(): Schema
$schemaNames = [];

if ($this->_platform->supportsSchemas()) {
$schemaNames = $this->listNamespaceNames();
$schemaNames = $this->listSchemaNames();
}

$sequences = [];
Expand Down
61 changes: 10 additions & 51 deletions src/Schema/PostgreSQLSchemaManager.php
Expand Up @@ -8,7 +8,6 @@
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\Deprecations\Deprecation;

use function array_change_key_case;
use function array_filter;
Expand Down Expand Up @@ -37,27 +36,6 @@ class PostgreSQLSchemaManager extends AbstractSchemaManager
/** @var array<int, string>|null */
private $existingSchemaPaths;

/**
* Gets all the existing schema names.
*
* @deprecated Use {@link listSchemaNames()} instead.
*
* @return array<int, string>
*
* @throws Exception
*/
public function getSchemaNames(): array
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'PostgreSQLSchemaManager::getSchemaNames() is deprecated,'
. ' use PostgreSQLSchemaManager::listSchemaNames() instead.'
);

return $this->listNamespaceNames();
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -93,36 +71,34 @@ public function getSchemaSearchPaths(): array
}

/**
* Gets names of all existing schemas in the current users search path.
*
* This is a PostgreSQL only function.
*
* @internal The method should be only used from within the PostgreSQLSchemaManager class hierarchy.
* Gets names of all existing schemas in the current user's search path.
*
* @return array<int, string>
*
* @throws Exception
*/
public function getExistingSchemaSearchPaths(): array
final protected function getExistingSchemaSearchPaths(): array
{
if ($this->existingSchemaPaths === null) {
$this->determineExistingSchemaSearchPaths();
$this->existingSchemaPaths = $this->determineExistingSchemaSearchPaths();
}

return $this->existingSchemaPaths;
}

/**
* Sets or resets the order of the existing schemas in the current search path of the user.
* Determines the names of all existing schemas in the current user's search path.
*
* This is a PostgreSQL only function.
* @return array<int,string>
*
* @internal The method should be only used from within the PostgreSQLSchemaManager class hierarchy.
* @throws Exception
*/
public function determineExistingSchemaSearchPaths(): void
protected function determineExistingSchemaSearchPaths(): array
{
$names = $this->listSchemaNames();
$paths = $this->getSchemaSearchPaths();

$this->existingSchemaPaths = array_filter($paths, static function ($v) use ($names): bool {
return array_filter($paths, static function ($v) use ($names): bool {
return in_array($v, $names, true);
});
}
Expand Down Expand Up @@ -283,23 +259,6 @@ protected function _getPortableSequencesList(array $sequences): array
return $list;
}

/**
* {@inheritdoc}
*
* @deprecated Use {@link listSchemaNames()} instead.
*/
protected function getPortableNamespaceDefinition(array $namespace): string
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'PostgreSQLSchemaManager::getPortableNamespaceDefinition() is deprecated,'
. ' use PostgreSQLSchemaManager::listSchemaNames() instead.'
);

return $namespace['nspname'];
}

/**
* {@inheritdoc}
*/
Expand Down
18 changes: 0 additions & 18 deletions src/Schema/SQLServerSchemaManager.php
Expand Up @@ -7,7 +7,6 @@
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\Types\Type;
use Doctrine\Deprecations\Deprecation;
use PDOException;

use function assert;
Expand Down Expand Up @@ -226,23 +225,6 @@ protected function _getPortableDatabaseDefinition(array $database): string
return $database['name'];
}

/**
* {@inheritdoc}
*
* @deprecated Use {@link listSchemaNames()} instead.
*/
protected function getPortableNamespaceDefinition(array $namespace): string
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'SQLServerSchemaManager::getPortableNamespaceDefinition() is deprecated,'
. ' use SQLServerSchemaManager::listSchemaNames() instead.'
);

return $namespace['name'];
}

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit ac2763f

Please sign in to comment.