Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Driver::getSchemaManager() #5465

Merged
merged 1 commit into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ awareness about deprecated code.

# Upgrade to 4.0

## BC BREAK: removed `Driver::getSchemaManager()`

The `Driver::getSchemaManager()` method has been removed.

## BC BREAK: removed `AbstractSchemaManager::getDatabasePlatform()`

The `AbstractSchemaManager::getDatabasePlatform()` method has been removed.
Expand Down
4 changes: 0 additions & 4 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
See https://github.com/doctrine/dbal/pull/4317
-->
<file name="tests/Functional/LegacyAPITest.php"/>
<!--
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Driver::getSchemaManager"/>
</errorLevel>
</DeprecatedMethod>
<DocblockTypeContradiction>
Expand Down
6 changes: 2 additions & 4 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1264,10 +1264,8 @@ public function getNativeConnection()
*/
public function createSchemaManager(): AbstractSchemaManager
{
return $this->_driver->getSchemaManager(
$this,
$this->getDatabasePlatform()
);
return $this->getDatabasePlatform()
->createSchemaManager($this);
}

/**
Expand Down
9 changes: 0 additions & 9 deletions src/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;

/**
* Driver interface.
Expand All @@ -35,14 +34,6 @@ public function connect(array $params): DriverConnection;
*/
public function getDatabasePlatform(ServerVersionProvider $versionProvider): AbstractPlatform;

/**
* Gets the SchemaManager that can be used to inspect and change the underlying
* database schema of the platform this driver connects to.
*
* @deprecated Use {@link AbstractPlatform::createSchemaManager()} instead.
*/
public function getSchemaManager(Connection $conn, AbstractPlatform $platform): AbstractSchemaManager;

/**
* Gets the ExceptionConverter that can be used to convert driver-level exceptions into DBAL exceptions.
*/
Expand Down
23 changes: 0 additions & 23 deletions src/Driver/AbstractDB2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@

namespace Doctrine\DBAL\Driver;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\API\IBMDB2\ExceptionConverter;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Schema\DB2SchemaManager;
use Doctrine\DBAL\ServerVersionProvider;
use Doctrine\Deprecations\Deprecation;

use function assert;

/**
* Abstract base implementation of the {@see Driver} interface for IBM DB2 based drivers.
Expand All @@ -25,23 +19,6 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): DB2
return new DB2Platform();
}

/**
* @deprecated Use {@link DB2Platform::createSchemaManager()} instead.
*/
public function getSchemaManager(Connection $conn, AbstractPlatform $platform): DB2SchemaManager
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5458',
'AbstractDB2Driver::getSchemaManager() is deprecated.'
. ' Use DB2Platform::createSchemaManager() instead.'
);

assert($platform instanceof DB2Platform);

return new DB2SchemaManager($conn, $platform);
}

public function getExceptionConverter(): ExceptionConverter
{
return new ExceptionConverter();
Expand Down
22 changes: 0 additions & 22 deletions src/Driver/AbstractMySQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,16 @@

namespace Doctrine\DBAL\Driver;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\Exception\InvalidPlatformVersion;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQL80Platform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Schema\MySQLSchemaManager;
use Doctrine\DBAL\ServerVersionProvider;
use Doctrine\Deprecations\Deprecation;

use function assert;
use function preg_match;
use function stripos;
use function version_compare;
Expand Down Expand Up @@ -81,23 +76,6 @@ private function getOracleMysqlVersionNumber(string $versionString): string
return $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
}

/**
* @deprecated Use {@link AbstractMySQLPlatform::createSchemaManager()} instead.
*/
public function getSchemaManager(Connection $conn, AbstractPlatform $platform): MySQLSchemaManager
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5458',
'AbstractMySQLDriver::getSchemaManager() is deprecated.'
. ' Use MySQLPlatform::createSchemaManager() instead.'
);

assert($platform instanceof AbstractMySQLPlatform);

return new MySQLSchemaManager($conn, $platform);
}

public function getExceptionConverter(): ExceptionConverter
{
return new ExceptionConverter();
Expand Down
23 changes: 0 additions & 23 deletions src/Driver/AbstractOracleDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@

namespace Doctrine\DBAL\Driver;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString;
use Doctrine\DBAL\Driver\API\OCI\ExceptionConverter;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Schema\OracleSchemaManager;
use Doctrine\DBAL\ServerVersionProvider;
use Doctrine\Deprecations\Deprecation;

use function assert;

/**
* Abstract base implementation of the {@see Driver} interface for Oracle based drivers.
Expand All @@ -26,23 +20,6 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): Ora
return new OraclePlatform();
}

/**
* @deprecated Use {@link OraclePlatform::createSchemaManager()} instead.
*/
public function getSchemaManager(Connection $conn, AbstractPlatform $platform): OracleSchemaManager
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5458',
'AbstractOracleDriver::getSchemaManager() is deprecated.'
. ' Use OraclePlatform::createSchemaManager() instead.'
);

assert($platform instanceof OraclePlatform);

return new OracleSchemaManager($conn, $platform);
}

public function getExceptionConverter(): ExceptionConverter
{
return new ExceptionConverter();
Expand Down
23 changes: 0 additions & 23 deletions src/Driver/AbstractPostgreSQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@

namespace Doctrine\DBAL\Driver;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\API\PostgreSQL\ExceptionConverter;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Schema\PostgreSQLSchemaManager;
use Doctrine\DBAL\ServerVersionProvider;
use Doctrine\Deprecations\Deprecation;

use function assert;

/**
* Abstract base implementation of the {@see Driver} interface for PostgreSQL based drivers.
Expand All @@ -25,23 +19,6 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): Pos
return new PostgreSQLPlatform();
}

/**
* @deprecated Use {@link PostgreSQLPlatform::createSchemaManager()} instead.
*/
public function getSchemaManager(Connection $conn, AbstractPlatform $platform): PostgreSQLSchemaManager
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5458',
'AbstractPostgreSQLDriver::getSchemaManager() is deprecated.'
. ' Use PostgreSQLPlatform::createSchemaManager() instead.'
);

assert($platform instanceof PostgreSQLPlatform);

return new PostgreSQLSchemaManager($conn, $platform);
}

public function getExceptionConverter(): ExceptionConverter
{
return new ExceptionConverter();
Expand Down
23 changes: 0 additions & 23 deletions src/Driver/AbstractSQLServerDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@

namespace Doctrine\DBAL\Driver;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\API\SQLSrv\ExceptionConverter;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\SQLServerSchemaManager;
use Doctrine\DBAL\ServerVersionProvider;
use Doctrine\Deprecations\Deprecation;

use function assert;

/**
* Abstract base implementation of the {@see Driver} interface for Microsoft SQL Server based drivers.
Expand All @@ -25,23 +19,6 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): SQL
return new SQLServerPlatform();
}

/**
* @deprecated Use {@link SQLServerPlatform::createSchemaManager()} instead.
*/
public function getSchemaManager(Connection $conn, AbstractPlatform $platform): SQLServerSchemaManager
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5458',
'AbstractSQLServerDriver::getSchemaManager() is deprecated.'
. ' Use SQLServerPlatform::createSchemaManager() instead.'
);

assert($platform instanceof SQLServerPlatform);

return new SQLServerSchemaManager($conn, $platform);
}

public function getExceptionConverter(): ExceptionConverter
{
return new ExceptionConverter();
Expand Down
23 changes: 0 additions & 23 deletions src/Driver/AbstractSQLiteDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@

namespace Doctrine\DBAL\Driver;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\API\SQLite\ExceptionConverter;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\SqliteSchemaManager;
use Doctrine\DBAL\ServerVersionProvider;
use Doctrine\Deprecations\Deprecation;

use function assert;

/**
* Abstract base implementation of the {@see Driver} interface for SQLite based drivers.
Expand All @@ -25,23 +19,6 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): Sql
return new SqlitePlatform();
}

/**
* @deprecated Use {@link SqlitePlatform::createSchemaManager()} instead.
*/
public function getSchemaManager(Connection $conn, AbstractPlatform $platform): SqliteSchemaManager
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5458',
'AbstractSQLiteDriver::getSchemaManager() is deprecated.'
. ' Use SqlitePlatform::createSchemaManager() instead.'
);

assert($platform instanceof SqlitePlatform);

return new SqliteSchemaManager($conn, $platform);
}

public function getExceptionConverter(): ExceptionConverter
{
return new ExceptionConverter();
Expand Down
18 changes: 0 additions & 18 deletions src/Driver/Middleware/AbstractDriverMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@

namespace Doctrine\DBAL\Driver\Middleware;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\API\ExceptionConverter;
use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\ServerVersionProvider;
use Doctrine\Deprecations\Deprecation;

abstract class AbstractDriverMiddleware implements Driver
{
Expand All @@ -35,21 +32,6 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): Abs
return $this->wrappedDriver->getDatabasePlatform($versionProvider);
}

/**
* @deprecated Use {@link AbstractPlatform::createSchemaManager()} instead.
*/
public function getSchemaManager(Connection $conn, AbstractPlatform $platform): AbstractSchemaManager
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5458',
'AbstractDriverMiddleware::getSchemaManager() is deprecated.'
. ' Use AbstractPlatform::createSchemaManager() instead.'
);

return $this->wrappedDriver->getSchemaManager($conn, $platform);
}

public function getExceptionConverter(): ExceptionConverter
{
return $this->wrappedDriver->getExceptionConverter();
Expand Down
17 changes: 0 additions & 17 deletions tests/Driver/AbstractDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use ReflectionProperty;

/**
* @template P of AbstractPlatform
Expand Down Expand Up @@ -50,22 +49,6 @@ public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion(
);
}

public function testReturnsSchemaManager(): void
{
$connection = $this->getConnectionMock();
$schemaManager = $this->driver->getSchemaManager(
$connection,
$this->createPlatform()
);

self::assertEquals($this->createSchemaManager($connection), $schemaManager);

$re = new ReflectionProperty($schemaManager, '_conn');
$re->setAccessible(true);

self::assertSame($connection, $re->getValue($schemaManager));
}

public function testReturnsExceptionConverter(): void
{
self::assertEquals($this->createExceptionConverter(), $this->driver->getExceptionConverter());
Expand Down