From 0bf655e57aa12f9057386600149078b75769d7ef Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 16 Jul 2022 10:56:32 -0700 Subject: [PATCH] Remove supportsCreateDropDatabase() --- UPGRADE.md | 3 ++- psalm.xml.dist | 5 ----- src/Platforms/AbstractPlatform.php | 22 ------------------- src/Platforms/DB2Platform.php | 16 -------------- src/Platforms/SqlitePlatform.php | 15 ------------- .../Schema/Db2SchemaManagerTest.php | 8 +++++++ .../SchemaManagerFunctionalTestCase.php | 4 ---- tests/Platforms/DB2PlatformTest.php | 5 ----- tests/Platforms/SQLServerPlatformTestCase.php | 5 ----- 9 files changed, 10 insertions(+), 73 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 0a76550fea8..6f60d546fbe 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -12,7 +12,8 @@ awareness about deprecated code. 1. `getDefaultSchemaName()`, 2. `getIdentitySequenceName()`, -3. `usesSequenceEmulatedIdentityColumns()`. +3. `supportsCreateDropDatabase()`, +4. `usesSequenceEmulatedIdentityColumns()`. ## BC BREAK: removed support for the `NULL` value of schema asset filter. diff --git a/psalm.xml.dist b/psalm.xml.dist index 549eb873521..d704819f79a 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -44,11 +44,6 @@ --> - - - diff --git a/src/Platforms/AbstractPlatform.php b/src/Platforms/AbstractPlatform.php index 0bb36f4b1df..77f05a3531f 100644 --- a/src/Platforms/AbstractPlatform.php +++ b/src/Platforms/AbstractPlatform.php @@ -2079,10 +2079,6 @@ public function getSequenceNextValSQL(string $sequence): string */ public function getCreateDatabaseSQL(string $name): string { - if (! $this->supportsCreateDropDatabase()) { - throw NotSupported::new(__METHOD__); - } - return 'CREATE DATABASE ' . $name; } @@ -2090,15 +2086,9 @@ public function getCreateDatabaseSQL(string $name): string * Returns the SQL snippet to drop an existing database. * * @param string $name The name of the database that should be dropped. - * - * @throws Exception If not supported on this platform. */ public function getDropDatabaseSQL(string $name): string { - if (! $this->supportsCreateDropDatabase()) { - throw NotSupported::new(__METHOD__); - } - return 'DROP DATABASE ' . $name; } @@ -2222,18 +2212,6 @@ public function supportsSchemas(): bool return false; } - /** - * Whether this platform supports create database. - * - * Some databases don't allow to create and drop databases at all or only with certain tools. - * - * @deprecated - */ - public function supportsCreateDropDatabase(): bool - { - return true; - } - /** * Whether this platform support to add inline column comments as postfix. */ diff --git a/src/Platforms/DB2Platform.php b/src/Platforms/DB2Platform.php index ec2e31998c0..f5a5280dfb1 100644 --- a/src/Platforms/DB2Platform.php +++ b/src/Platforms/DB2Platform.php @@ -14,7 +14,6 @@ use Doctrine\DBAL\Schema\Identifier; use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\TableDiff; -use Doctrine\Deprecations\Deprecation; use function array_merge; use function count; @@ -206,21 +205,6 @@ public function getListViewsSQL(string $database): string return 'SELECT NAME, TEXT FROM SYSIBM.SYSVIEWS'; } - /** - * @deprecated - */ - public function supportsCreateDropDatabase(): bool - { - Deprecation::trigger( - 'doctrine/dbal', - 'https://github.com/doctrine/dbal/pull/5513', - '%s is deprecated.', - __METHOD__ - ); - - return false; - } - public function supportsCommentOnStatement(): bool { return true; diff --git a/src/Platforms/SqlitePlatform.php b/src/Platforms/SqlitePlatform.php index 9ccccdb299d..44bfe26cf54 100644 --- a/src/Platforms/SqlitePlatform.php +++ b/src/Platforms/SqlitePlatform.php @@ -424,21 +424,6 @@ public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey return $query; } - /** - * @deprecated - */ - public function supportsCreateDropDatabase(): bool - { - Deprecation::trigger( - 'doctrine/dbal', - 'https://github.com/doctrine/dbal/pull/5513', - '%s is deprecated.', - __METHOD__ - ); - - return false; - } - public function supportsIdentityColumns(): bool { return true; diff --git a/tests/Functional/Schema/Db2SchemaManagerTest.php b/tests/Functional/Schema/Db2SchemaManagerTest.php index c94b0695cd5..fafe709786a 100644 --- a/tests/Functional/Schema/Db2SchemaManagerTest.php +++ b/tests/Functional/Schema/Db2SchemaManagerTest.php @@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Tests\Functional\Schema; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\DB2Platform; @@ -13,4 +14,11 @@ protected function supportsPlatform(AbstractPlatform $platform): bool { return $platform instanceof DB2Platform; } + + public function testListDatabases(): void + { + $this->expectException(Exception::class); + + $this->schemaManager->listDatabases(); + } } diff --git a/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php index f0870397807..af5137708e6 100644 --- a/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php +++ b/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php @@ -153,10 +153,6 @@ public function testListSequences(): void public function testListDatabases(): void { - if (! $this->connection->getDatabasePlatform()->supportsCreateDropDatabase()) { - self::markTestSkipped('Cannot drop Database client side with this Driver.'); - } - try { $this->schemaManager->dropDatabase('test_create_database'); } catch (DatabaseObjectNotFoundException $e) { diff --git a/tests/Platforms/DB2PlatformTest.php b/tests/Platforms/DB2PlatformTest.php index 87e03d4eb0f..84f50b3e932 100644 --- a/tests/Platforms/DB2PlatformTest.php +++ b/tests/Platforms/DB2PlatformTest.php @@ -399,11 +399,6 @@ public function testDoesNotSupportReleasePoints(): void self::assertFalse($this->platform->supportsReleaseSavepoints()); } - public function testDoesNotSupportCreateDropDatabase(): void - { - self::assertFalse($this->platform->supportsCreateDropDatabase()); - } - public function testGetVariableLengthStringTypeDeclarationSQLNoLength(): void { $this->expectException(ColumnLengthRequired::class); diff --git a/tests/Platforms/SQLServerPlatformTestCase.php b/tests/Platforms/SQLServerPlatformTestCase.php index 81be88aee40..5798a1c9358 100644 --- a/tests/Platforms/SQLServerPlatformTestCase.php +++ b/tests/Platforms/SQLServerPlatformTestCase.php @@ -155,11 +155,6 @@ public function testSupportsIdentityColumns(): void self::assertTrue($this->platform->supportsIdentityColumns()); } - public function testSupportsCreateDropDatabase(): void - { - self::assertTrue($this->platform->supportsCreateDropDatabase()); - } - public function testSupportsSchemas(): void { self::assertTrue($this->platform->supportsSchemas());