From f19ed69b9c4291a6a46e4859be1c055b105b61ea 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 | 24 -------------- src/Platforms/DB2Platform.php | 16 ---------- src/Platforms/SqlitePlatform.php | 32 ++++++++++--------- .../Schema/Db2SchemaManagerTest.php | 8 +++++ .../SchemaManagerFunctionalTestCase.php | 4 --- tests/Platforms/DB2PlatformTest.php | 5 --- tests/Platforms/SQLServerPlatformTestCase.php | 5 --- 9 files changed, 27 insertions(+), 75 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..82ea3513378 100644 --- a/src/Platforms/AbstractPlatform.php +++ b/src/Platforms/AbstractPlatform.php @@ -2074,15 +2074,9 @@ public function getSequenceNextValSQL(string $sequence): string * Returns the SQL to create a new database. * * @param string $name The name of the database that should be created. - * - * @throws Exception If not supported on this platform. */ public function getCreateDatabaseSQL(string $name): string { - if (! $this->supportsCreateDropDatabase()) { - throw NotSupported::new(__METHOD__); - } - return 'CREATE DATABASE ' . $name; } @@ -2090,15 +2084,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 +2210,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..ca5c7622adf 100644 --- a/src/Platforms/SqlitePlatform.php +++ b/src/Platforms/SqlitePlatform.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Platforms\Exception\NotSupported; use Doctrine\DBAL\Platforms\Keywords\KeywordList; use Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords; use Doctrine\DBAL\Schema\Column; @@ -41,6 +42,22 @@ */ class SqlitePlatform extends AbstractPlatform { + /** + * @throws NotSupported + */ + public function getCreateDatabaseSQL(string $name): string + { + throw NotSupported::new(__METHOD__); + } + + /** + * @throws NotSupported + */ + public function getDropDatabaseSQL(string $name): string + { + throw NotSupported::new(__METHOD__); + } + public function getRegexpExpression(): string { return 'REGEXP'; @@ -424,21 +441,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 ba979eceb23..c6aa0375326 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());