Skip to content

Commit

Permalink
Remove supportsCreateDropDatabase()
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Jul 16, 2022
1 parent 6e58532 commit 0bf655e
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 73 deletions.
3 changes: 2 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 0 additions & 5 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@
-->
<referencedMethod name="Doctrine\DBAL\Platforms\SqlitePlatform::getTinyIntTypeDeclarationSQL"/>
<referencedMethod name="Doctrine\DBAL\Platforms\SqlitePlatform::getMediumIntTypeDeclarationSQL"/>
<!--
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::supportsCreateDropDatabase"/>
<referencedMethod name="Doctrine\DBAL\Platforms\DB2Platform::supportsCreateDropDatabase"/>
</errorLevel>
</DeprecatedMethod>
<DocblockTypeContradiction>
Expand Down
22 changes: 0 additions & 22 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -2079,26 +2079,16 @@ public function getSequenceNextValSQL(string $sequence): string
*/
public function getCreateDatabaseSQL(string $name): string
{
if (! $this->supportsCreateDropDatabase()) {
throw NotSupported::new(__METHOD__);
}

return 'CREATE DATABASE ' . $name;
}

/**
* 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;
}

Expand Down Expand Up @@ -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.
*/
Expand Down
16 changes: 0 additions & 16 deletions src/Platforms/DB2Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 0 additions & 15 deletions src/Platforms/SqlitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions tests/Functional/Schema/Db2SchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Doctrine\DBAL\Tests\Functional\Schema;

use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\DB2Platform;

Expand All @@ -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();
}
}
4 changes: 0 additions & 4 deletions tests/Functional/Schema/SchemaManagerFunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 0 additions & 5 deletions tests/Platforms/DB2PlatformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 0 additions & 5 deletions tests/Platforms/SQLServerPlatformTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 0bf655e

Please sign in to comment.