Skip to content

Commit

Permalink
Merge pull request #3807 from morozov/remove-requires-query-for-serve…
Browse files Browse the repository at this point in the history
…r-version

Removed ServerInfoAwareConnection#requiresQueryForServerVersion() as implementation detail
  • Loading branch information
morozov authored Jan 8, 2020
2 parents e35a8f4 + 8d01589 commit 2e54e78
Show file tree
Hide file tree
Showing 16 changed files with 8 additions and 235 deletions.
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 almost all supported drivers.

## BC BREAK: PingableConnection and ServerInfoAwareConnection interfaces now extends Connection

All implementations of the `PingableConnection` and `ServerInfoAwareConnection` interfaces have to implement the methods defined in the `Connection` interface as well.
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ private function getServerVersion() : ?string
$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 lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,6 @@ public function getServerVersion() : string
return $serverInfo->DBMS_VER;
}

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

/**
* {@inheritdoc}
*/
Expand Down
8 changes: 0 additions & 8 deletions lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,6 @@ public function getServerVersion() : string
return $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
}

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

/**
* {@inheritdoc}
*/
Expand Down
8 changes: 0 additions & 8 deletions lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,6 @@ public function getServerVersion() : string
return $matches[1];
}

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

/**
* {@inheritdoc}
*/
Expand Down
8 changes: 0 additions & 8 deletions lib/Doctrine/DBAL/Driver/PDOConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,6 @@ public function lastInsertId(?string $name = null) : string
}
}

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

/**
* Creates a wrapped statement
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,6 @@ public function quote(string $input) : string
return "'" . sasql_escape_string($this->connection, $input) . "'";
}

/**
* {@inheritdoc}
*/
public function requiresQueryForServerVersion() : bool
{
return true;
}

/**
* {@inheritdoc}
*
Expand Down
8 changes: 0 additions & 8 deletions lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,6 @@ public function getServerVersion() : string
return $serverInfo['SQLServerVersion'];
}

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

/**
* {@inheritDoc}
*/
Expand Down
7 changes: 0 additions & 7 deletions lib/Doctrine/DBAL/Driver/ServerInfoAwareConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,4 @@ interface ServerInfoAwareConnection extends Connection
* Returns the version number of the database server connected to.
*/
public function getServerVersion() : string;

/**
* 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() : bool;
}
4 changes: 0 additions & 4 deletions tests/Doctrine/Tests/DBAL/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,10 +687,6 @@ public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform() : v
->method('connect')
->will($this->returnValue($driverConnectionMock));

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

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

This file was deleted.

21 changes: 3 additions & 18 deletions tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,12 @@
use Doctrine\DBAL\Driver\Mysqli\MysqliConnection;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\Tests\DbalFunctionalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use function extension_loaded;
use function restore_error_handler;
use function set_error_handler;

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

protected function setUp() : void
{
if (! extension_loaded('mysqli')) {
Expand All @@ -30,18 +22,11 @@ protected function setUp() : void

parent::setUp();

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

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

public function testDoesNotRequireQueryForServerVersion() : void
{
self::assertFalse($this->connectionMock->requiresQueryForServerVersion());
$this->markTestSkipped('MySQL only test.');
}

public function testRestoresErrorHandlerOnException() : void
Expand Down
38 changes: 0 additions & 38 deletions tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php

This file was deleted.

This file was deleted.

38 changes: 0 additions & 38 deletions tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ protected function tearDown() : void
parent::tearDown();
}

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

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

0 comments on commit 2e54e78

Please sign in to comment.