Skip to content

Commit

Permalink
[doctrineGH-4503] Trigger deprecation in schema- and namespace-relate…
Browse files Browse the repository at this point in the history
…d APIs
  • Loading branch information
morozov committed Apr 1, 2021
1 parent a602f2b commit e5e31e1
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/Platforms/AbstractPlatform.php
Expand Up @@ -2758,6 +2758,13 @@ public function getListDatabasesSQL()
*/
public function getListNamespacesSQL()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'AbstractPlatform::getListNamespacesSQL() is deprecated,'
. ' use AbstractSchemaManager::listSchemaNames() instead.'
);

throw Exception::notSupported(__METHOD__);
}

Expand Down
7 changes: 7 additions & 0 deletions src/Platforms/PostgreSQL94Platform.php
Expand Up @@ -233,6 +233,13 @@ public function getListDatabasesSQL()
*/
public function getListNamespacesSQL()
{
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\_%'
Expand Down
7 changes: 7 additions & 0 deletions src/Platforms/SQLServer2012Platform.php
Expand Up @@ -1166,6 +1166,13 @@ public function getListDatabasesSQL()
*/
public function getListNamespacesSQL()
{
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')";
}

Expand Down
21 changes: 21 additions & 0 deletions src/Schema/AbstractSchemaManager.php
Expand Up @@ -117,6 +117,13 @@ public function listDatabases()
*/
public function listNamespaceNames()
{
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);
Expand Down Expand Up @@ -735,6 +742,13 @@ protected function _getPortableDatabasesList($databases)
*/
protected function getPortableNamespacesList(array $namespaces)
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'AbstractSchemaManager::getPortableNamespacesList() is deprecated,'
. ' use AbstractSchemaManager::listSchemaNames() instead.'
);

$namespacesList = [];

foreach ($namespaces as $namespace) {
Expand Down Expand Up @@ -765,6 +779,13 @@ protected function _getPortableDatabaseDefinition($database)
*/
protected function getPortableNamespaceDefinition(array $namespace)
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'AbstractSchemaManager::getPortableNamespaceDefinition() is deprecated,'
. ' use AbstractSchemaManager::listSchemaNames() instead.'
);

return $namespace;
}

Expand Down
17 changes: 16 additions & 1 deletion src/Schema/PostgreSQLSchemaManager.php
Expand Up @@ -6,6 +6,7 @@
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 @@ -46,6 +47,13 @@ class PostgreSQLSchemaManager extends AbstractSchemaManager
*/
public function getSchemaNames()
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'PostgreSQLSchemaManager::getSchemaNames() is deprecated,'
. ' use PostgreSQLSchemaManager::listSchemaNames() instead.'
);

return $this->listNamespaceNames();
}

Expand Down Expand Up @@ -287,10 +295,17 @@ protected function _getPortableSequencesList($sequences)
/**
* {@inheritdoc}
*
* @deprecated Use {@link PostgreSQLSchemaManager::listSchemaNames()} instead.
* @deprecated Use {@link listSchemaNames()} instead.
*/
protected function getPortableNamespaceDefinition(array $namespace)
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'PostgreSQLSchemaManager::getPortableNamespaceDefinition() is deprecated,'
. ' use PostgreSQLSchemaManager::listSchemaNames() instead.'
);

return $namespace['nspname'];
}

Expand Down
10 changes: 9 additions & 1 deletion src/Schema/SQLServerSchemaManager.php
Expand Up @@ -5,6 +5,7 @@
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 @@ -214,10 +215,17 @@ protected function _getPortableDatabaseDefinition($database)
/**
* {@inheritdoc}
*
* @deprecated Use {@link SQLServerSchemaManager::listSchemaNames()} instead.
* @deprecated Use {@link listSchemaNames()} instead.
*/
protected function getPortableNamespaceDefinition(array $namespace)
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4503',
'SQLServerSchemaManager::getPortableNamespaceDefinition() is deprecated,'
. ' use SQLServerSchemaManager::listSchemaNames() instead.'
);

return $namespace['name'];
}

Expand Down

0 comments on commit e5e31e1

Please sign in to comment.