Skip to content

Commit

Permalink
[doctrineGH-4503] Remove deprecated in schema- and namespace-related …
Browse files Browse the repository at this point in the history
…APIs
  • Loading branch information
morozov committed Apr 2, 2021
1 parent ba7bf25 commit 872167f
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 214 deletions.
10 changes: 10 additions & 0 deletions UPGRADE.md
@@ -1,5 +1,15 @@
# Upgrade to 4.0

## 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
9 changes: 0 additions & 9 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
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
40 changes: 0 additions & 40 deletions src/Schema/PostgreSQLSchemaManager.php
Expand Up @@ -4,11 +4,9 @@

namespace Doctrine\DBAL\Schema;

use Doctrine\DBAL\Exception;
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 +35,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 @@ -283,23 +260,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
6 changes: 1 addition & 5 deletions tests/Functional/Schema/PostgreSQLSchemaManagerTest.php
Expand Up @@ -9,7 +9,6 @@
use Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\PostgreSQLSchemaManager;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\BlobType;
Expand All @@ -20,7 +19,6 @@
use function array_map;
use function array_pop;
use function array_unshift;
use function assert;
use function count;
use function preg_match;
use function strtolower;
Expand All @@ -47,9 +45,7 @@ public function testGetSearchPath(): void

public function testGetSchemaNames(): void
{
assert($this->schemaManager instanceof PostgreSQLSchemaManager);

$names = $this->schemaManager->getSchemaNames();
$names = $this->schemaManager->listSchemaNames();

self::assertContains('public', $names, 'The public schema should be found.');
}
Expand Down
25 changes: 2 additions & 23 deletions tests/Functional/Schema/SchemaManagerFunctionalTestCase.php
Expand Up @@ -154,10 +154,7 @@ public function testListDatabases(): void
self::assertContains('test_create_database', $databases);
}

/**
* @dataProvider listSchemaNamesMethodProvider
*/
public function testListSchemaNames(callable $method): void
public function testListSchemaNames(): void
{
if (! $this->schemaManager->getDatabasePlatform()->supportsSchemas()) {
self::markTestSkipped('Platform does not support schemas.');
Expand All @@ -169,25 +166,7 @@ public function testListSchemaNames(callable $method): void
$this->schemaManager->getDatabasePlatform()->getCreateSchemaSQL('test_create_schema')
);

self::assertContains('test_create_schema', $method($this->schemaManager));
}

/**
* @return iterable<list<mixed>>
*/
public static function listSchemaNamesMethodProvider(): iterable
{
yield [
static function (AbstractSchemaManager $schemaManager): array {
return $schemaManager->listNamespaceNames();
},
];

yield [
static function (AbstractSchemaManager $schemaManager): array {
return $schemaManager->listSchemaNames();
},
];
self::assertContains('test_create_schema', $this->schemaManager->listSchemaNames());
}

public function testListTables(): void
Expand Down

0 comments on commit 872167f

Please sign in to comment.