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 ServerInfoAwareConnection#requiresQueryForServerVersion() as an implementation detail #4115

Merged
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
@@ -1,5 +1,9 @@
# Upgrade to 3.0

## BC BREAK: `ServerInfoAwareConnection::requiresQueryForServerVersion()` is removed.

The `ServerInfoAwareConnection::requiresQueryForServerVersion()` method has been removed as an implementation detail which is the same for all supported drivers.

## BC BREAK Changes in driver exceptions

1. The `Doctrine\DBAL\Driver\DriverException::getErrorCode()` method is removed. In order to obtain the driver error code, please use `::getCode()` or `::getSQLState()`.
Expand Down
2 changes: 1 addition & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ private function getServerVersion()
$connection = $this->getWrappedConnection();

// Automatic platform version detection.
if ($connection instanceof ServerInfoAwareConnection && ! $connection->requiresQueryForServerVersion()) {
if ($connection instanceof ServerInfoAwareConnection) {
return $connection->getServerVersion();
}

Expand Down
8 changes: 0 additions & 8 deletions src/Driver/IBMDB2/DB2Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,6 @@ public function getServerVersion()
return $serverInfo->DBMS_VER;
}

/**
* {@inheritdoc}
*/
public function requiresQueryForServerVersion()
{
return false;
}

public function prepare(string $sql): DriverStatement
{
$stmt = @db2_prepare($this->conn, $sql);
Expand Down
8 changes: 0 additions & 8 deletions src/Driver/Mysqli/MysqliConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@ public function getServerVersion()
return $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
}

/**
* {@inheritdoc}
*/
public function requiresQueryForServerVersion()
{
return false;
}

public function prepare(string $sql): DriverStatement
{
return new Statement($this->conn, $sql);
Expand Down
8 changes: 0 additions & 8 deletions src/Driver/OCI8/OCI8Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,6 @@ public function getServerVersion()
return $matches[1];
}

/**
* {@inheritdoc}
*/
public function requiresQueryForServerVersion()
{
return false;
}

public function prepare(string $sql): DriverStatement
{
return new Statement($this->dbh, $sql, $this->executionMode);
Expand Down
8 changes: 0 additions & 8 deletions src/Driver/PDOConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,6 @@ public function lastInsertId($name = null)
}
}

/**
* {@inheritdoc}
*/
public function requiresQueryForServerVersion()
{
return false;
}

/**
* Creates a wrapped statement
*/
Expand Down
8 changes: 0 additions & 8 deletions src/Driver/SQLSrv/SQLSrvConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@ public function getServerVersion()
return $serverInfo['SQLServerVersion'];
}

/**
* {@inheritdoc}
*/
public function requiresQueryForServerVersion()
{
return false;
}

public function prepare(string $sql): DriverStatement
{
return new Statement($this->conn, $sql, $this->lastInsertId);
Expand Down
7 changes: 0 additions & 7 deletions src/Driver/ServerInfoAwareConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,4 @@ interface ServerInfoAwareConnection extends Connection
* @return string
*/
public function getServerVersion();

/**
* Checks whether a query is required to retrieve the database server version.
*
* @return bool True if a query is required to retrieve the database server version, false otherwise.
*/
public function requiresQueryForServerVersion();
}
4 changes: 0 additions & 4 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,10 +661,6 @@ public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform(): vo
->method('connect')
->will(self::returnValue($driverConnectionMock));

$driverConnectionMock->expects(self::once())
->method('requiresQueryForServerVersion')
->will(self::returnValue(false));

$driverConnectionMock->expects(self::once())
->method('getServerVersion')
->will(self::returnValue('6.6.6'));
Expand Down
37 changes: 0 additions & 37 deletions tests/Driver/IBMDB2/DB2ConnectionTest.php

This file was deleted.

23 changes: 0 additions & 23 deletions tests/Driver/Mysqli/MysqliConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,19 @@

use Doctrine\DBAL\Driver\Mysqli\Driver;
use Doctrine\DBAL\Driver\Mysqli\HostRequired;
use Doctrine\DBAL\Driver\Mysqli\MysqliConnection;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use PHPUnit\Framework\MockObject\MockObject;

use function extension_loaded;

class MysqliConnectionTest extends FunctionalTestCase
{
/**
* The mysqli driver connection mock under test.
*
* @var MysqliConnection|MockObject
*/
private $connectionMock;

protected function setUp(): void
{
if (! extension_loaded('mysqli')) {
self::markTestSkipped('mysqli is not installed.');
}

parent::setUp();

if (! $this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
$this->markTestSkipped('MySQL only test.');
}

$this->connectionMock = $this->getMockBuilder(MysqliConnection::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
}

public function testDoesNotRequireQueryForServerVersion(): void
{
self::assertFalse($this->connectionMock->requiresQueryForServerVersion());
}

public function testHostnameIsRequiredForPersistentConnection(): void
Expand Down
37 changes: 0 additions & 37 deletions tests/Driver/OCI8/OCI8ConnectionTest.php

This file was deleted.

37 changes: 0 additions & 37 deletions tests/Driver/SQLSrv/SQLSrvConnectionTest.php

This file was deleted.

5 changes: 0 additions & 5 deletions tests/Functional/Driver/PDO/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ protected function tearDown(): void
parent::tearDown();
}

public function testDoesNotRequireQueryForServerVersion(): void
{
self::assertFalse($this->driverConnection->requiresQueryForServerVersion());
}

public function testThrowsWrappedExceptionOnConstruct(): void
{
$this->expectException(Exception::class);
Expand Down