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

Merge 3.2.x into 4.0.x #4759

Merged
merged 27 commits into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
80af3bc
Refactor DataAccessTest
morozov Jul 24, 2021
fbd0a89
Fix setup in TableGeneratorTest
morozov Jul 25, 2021
234815b
Merge pull request #4731 from morozov/randomized-test-suite
morozov Jul 25, 2021
916c90f
Deprecate reference from foreign key to its referencing table
morozov Aug 3, 2021
634797b
Merge pull request #4743 from morozov/issues/4506-deprecation
morozov Aug 3, 2021
0a54d82
Improve ConnectionTest by triggering real exceptions
grongor Jan 7, 2019
5a360f8
Merge pull request #3425 from grongor/add-functional-tests-for-transa…
morozov Aug 17, 2021
d971d9f
Remove unused static Exception methods
morozov Jul 31, 2021
89d4331
Remove trigger-related methods
morozov Jul 31, 2021
55894c0
Remove unnecessary escaping in regular expressions
morozov Jul 31, 2021
f5fc751
Merge pull request #4752 from morozov/code-cleanup
morozov Aug 24, 2021
ae4bbe6
Deprecate AbstractPlatform::getNowExpression()
morozov Jul 31, 2021
8143950
Merge pull request #4753 from morozov/deprecate-now-expression
morozov Aug 24, 2021
6907620
Remove unused local variables
morozov Jul 31, 2021
57ad4ac
Remove unnecessary property default values
morozov Jul 31, 2021
f3dadc9
Merge pull request #4756 from morozov/code-cleanup
morozov Aug 25, 2021
7b2a322
Deprecate VersionAwarePlatformDriver and ServerInfoAwareConnection
morozov Aug 23, 2021
b46a318
Merge pull request #4751 from morozov/deprecate-server-info-aware-con…
morozov Aug 25, 2021
a380840
Improve isolation in integration tests
morozov Aug 15, 2021
ad5b860
Parametrize AbstractSchemaManager with AbstractPlatform
morozov Aug 22, 2021
1809a91
Platform-aware schema comparison
morozov Aug 14, 2021
0453eef
Merge pull request #4746 from morozov/platform-schema-comparison
morozov Aug 26, 2021
666c065
Reinstate PostgreSQLPlatform and PostgreSQLKeywords
morozov Aug 26, 2021
c8cad0e
Reinstate SQLServerPlatform and SQLServerKeywords
morozov Aug 26, 2021
4b174ad
Deprecate AbstractPlatform::getName()
morozov Aug 24, 2021
d04d0d6
Merge pull request #4755 from morozov/deprecate-platform-get-name
morozov Aug 26, 2021
cc378c3
Merge branch '3.2.x' into 4.0.x
morozov Aug 26, 2021
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
5 changes: 5 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ awareness about deprecated code.

# Upgrade to 3.2

## Deprecated driver-level APIs that don't take the server version into account.

The `ServerInfoAwareConnection` and `VersionAwarePlatformDriver` interfaces are deprecated. In the next major version,
all drivers and driver connections will be required to implement the APIs aware of the server version.

## Deprecated `AbstractPlatform::getNowExpression()`.

Relying on dates generated by the database is deprecated. Generate dates within the application.
Expand Down
14 changes: 14 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,22 @@
-->
<referencedClass name="Doctrine\DBAL\Id\TableGenerator"/>
<referencedClass name="Doctrine\DBAL\Id\TableGeneratorSchemaVisitor"/>
<!--
TODO: remove in 4.0.0
-->
<referencedClass name="Doctrine\DBAL\Driver\ServerInfoAwareConnection"/>
<referencedClass name="Doctrine\DBAL\VersionAwarePlatformDriver"/>
</errorLevel>
</DeprecatedClass>
<DeprecatedInterface>
<errorLevel type="suppress">
<!--
TODO: remove in 4.0.0
-->
<referencedClass name="Doctrine\DBAL\Driver\ServerInfoAwareConnection"/>
<referencedClass name="Doctrine\DBAL\VersionAwarePlatformDriver"/>
</errorLevel>
</DeprecatedInterface>
<DeprecatedMethod>
<errorLevel type="suppress">
<!--
Expand Down
8 changes: 8 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use function array_key_exists;
use function assert;
use function count;
use function get_class;
use function implode;
use function is_int;
use function is_string;
Expand Down Expand Up @@ -441,6 +442,13 @@ private function getServerVersion()
}
}

Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pulls/4750',
'Not implementing the ServerInfoAwareConnection interface in %s is deprecated',
get_class($connection)
);

// Unable to detect platform version.
return null;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Driver/ServerInfoAwareConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

/**
* Contract for a connection that is able to provide information about the server it is connected to.
*
* @deprecated The methods defined in this interface will be made part of the {@link Driver} interface
* in the next major release.
*/
interface ServerInfoAwareConnection extends Connection
{
Expand Down
16 changes: 15 additions & 1 deletion src/Portability/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
use Doctrine\DBAL\Driver\Result as DriverResult;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Driver\Statement as DriverStatement;
use Doctrine\DBAL\ParameterType;
use Doctrine\Deprecations\Deprecation;
use LogicException;

/**
* Portability wrapper for a Connection.
*/
final class Connection implements ConnectionInterface
final class Connection implements ServerInfoAwareConnection
{
public const PORTABILITY_ALL = 255;
public const PORTABILITY_NONE = 0;
Expand Down Expand Up @@ -99,4 +101,16 @@ public function rollBack()
{
return $this->connection->rollBack();
}

/**
* {@inheritDoc}
*/
public function getServerVersion()
{
if (! $this->connection instanceof ServerInfoAwareConnection) {
throw new LogicException('The underlying connection is not a ServerInfoAwareConnection');
}

return $this->connection->getServerVersion();
}
}
2 changes: 2 additions & 0 deletions src/VersionAwarePlatformDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* support the correct features and SQL syntax of each version.
* This interface should be implemented by drivers that are capable to do this
* distinction.
*
* @deprecated All drivers will have to be aware of the server version in the next major release.
*/
interface VersionAwarePlatformDriver extends Driver
{
Expand Down
23 changes: 23 additions & 0 deletions tests/Portability/ConnectionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Doctrine\DBAL\Tests\Portability;

use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Portability\Connection;
use Doctrine\DBAL\Portability\Converter;
use PHPUnit\Framework\TestCase;

class ConnectionTest extends TestCase
{
public function testGetServerVersion(): void
{
$driverConnection = $this->createMock(ServerInfoAwareConnection::class);
$driverConnection->expects(self::once())
->method('getServerVersion')
->willReturn('1.2.3');

$connection = new Connection($driverConnection, new Converter(false, false, 0));

self::assertSame('1.2.3', $connection->getServerVersion());
}
}