Skip to content

Commit

Permalink
Remove support for Postgres 10 and 11
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Aug 15, 2024
1 parent ef2f9b6 commit 116256c
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 102 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ jobs:
php-version:
- "8.1"
postgres-version:
- "10"
- "12"
- "15"
- "16"
extension:
Expand Down
3 changes: 2 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ awareness about deprecated code.
A new method `getColumnName()` has been added to the `Result` interface and must be implemented by
all drivers and middleware.

## BC BREAK: Removed support for MariaDB 10.4 and MySQL 5.7
## BC BREAK: Removed support for MariaDB 10.4, MySQL 5.7 and Postgres 10 + 11

* Upgrade to MariaDB 10.5 or later.
* Upgrade to MySQL 8.0 or later.
* Upgrade to Postgres 12 or later.

# Upgrade to 4.1

Expand Down
3 changes: 1 addition & 2 deletions docs/en/reference/platforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ Microsoft SQL Server
PostgreSQL
^^^^^^^^^^

- ``PostgreSQLPlatform`` for version 10.0 and above.
- ``PostgreSQL120Platform`` for version 12.0 and above.
- ``PostgreSQLPlatform`` for version 12.0 and above.

IBM DB2
^^^^^^^
Expand Down
9 changes: 0 additions & 9 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@
<file name="src/Driver/OCI8/ConvertPositionalToNamedPlaceholders.php"/>
</errorLevel>
</ConflictingReferenceConstraint>
<DeprecatedClass>
<errorLevel type="suppress">
<!--
See https://github.com/doctrine/dbal/pull/6343
TODO: remove in 5.0.0
-->
<referencedClass name="Doctrine\DBAL\Platforms\PostgreSQL120Platform" />
</errorLevel>
</DeprecatedClass>
<DeprecatedMethod>
<errorLevel type="suppress">
<!--
Expand Down
30 changes: 0 additions & 30 deletions src/Driver/AbstractPostgreSQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,8 @@
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
use Doctrine\DBAL\Driver\API\PostgreSQL\ExceptionConverter;
use Doctrine\DBAL\Platforms\Exception\InvalidPlatformVersion;
use Doctrine\DBAL\Platforms\PostgreSQL120Platform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\ServerVersionProvider;
use Doctrine\Deprecations\Deprecation;

use function preg_match;
use function version_compare;

/**
* Abstract base implementation of the {@see Driver} interface for PostgreSQL based drivers.
Expand All @@ -23,30 +17,6 @@ abstract class AbstractPostgreSQLDriver implements Driver
{
public function getDatabasePlatform(ServerVersionProvider $versionProvider): PostgreSQLPlatform
{
$version = $versionProvider->getServerVersion();

if (preg_match('/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/', $version, $versionParts) === 0) {
throw InvalidPlatformVersion::new(
$version,
'<major_version>.<minor_version>.<patch_version>',
);
}

$majorVersion = $versionParts['major'];
$minorVersion = $versionParts['minor'] ?? 0;
$patchVersion = $versionParts['patch'] ?? 0;
$version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion;

if (version_compare($version, '12.0', '>=')) {
return new PostgreSQL120Platform();
}

Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/6495',
'Support for Postgres < 12 is deprecated and will be removed in DBAL 5',
);

return new PostgreSQLPlatform();
}

Expand Down
32 changes: 0 additions & 32 deletions src/Platforms/PostgreSQL120Platform.php

This file was deleted.

13 changes: 0 additions & 13 deletions src/Platforms/PostgreSQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -677,19 +677,6 @@ public function getTruncateTableSQL(string $tableName, bool $cascade = false): s
return $sql;
}

/**
* Get the snippet used to retrieve the default value for a given column
*/
public function getDefaultColumnValueSQLSnippet(): string
{
return <<<'SQL'
SELECT pg_get_expr(adbin, adrelid)
FROM pg_attrdef
WHERE c.oid = pg_attrdef.adrelid
AND pg_attrdef.adnum=a.attnum
SQL;
}

protected function initializeDoctrineTypeMappings(): void
{
$this->doctrineTypeMapping = [
Expand Down
13 changes: 10 additions & 3 deletions src/Schema/PostgreSQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ protected function selectTableColumns(string $databaseName, ?string $tableName =
$sql .= 'c.relname AS table_name, n.nspname AS schema_name,';
}

$sql .= sprintf(<<<'SQL'
$sql .= <<<'SQL'

Check warning on line 420 in src/Schema/PostgreSQLSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/PostgreSQLSchemaManager.php#L420

Added line #L420 was not covered by tests
a.attnum,
quote_ident(a.attname) AS field,
t.typname AS type,
Expand All @@ -434,7 +434,14 @@ protected function selectTableColumns(string $databaseName, ?string $tableName =
AND pg_index.indkey[0] = a.attnum
AND pg_index.indisprimary = 't'
) AS pri,
(%s) AS default,
(SELECT
CASE
WHEN a.attgenerated = 's' THEN NULL
ELSE pg_get_expr(adbin, adrelid)
END
FROM pg_attrdef
WHERE c.oid = pg_attrdef.adrelid
AND pg_attrdef.adnum=a.attnum) AS default,
(SELECT pg_description.description
FROM pg_description WHERE pg_description.objoid = c.oid AND a.attnum = pg_description.objsubid
) AS comment
Expand All @@ -449,7 +456,7 @@ protected function selectTableColumns(string $databaseName, ?string $tableName =
ON d.objid = c.oid
AND d.deptype = 'e'
AND d.classid = (SELECT oid FROM pg_class WHERE relname = 'pg_class')
SQL, $this->platform->getDefaultColumnValueSQLSnippet());
SQL;

Check warning on line 459 in src/Schema/PostgreSQLSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/PostgreSQLSchemaManager.php#L459

Added line #L459 was not covered by tests

$conditions = array_merge([
'a.attnum > 0',
Expand Down
9 changes: 3 additions & 6 deletions tests/Driver/VersionAwarePlatformDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQL84Platform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQL120Platform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -64,11 +63,9 @@ public function testPDOPgSQL(string $version, string $expectedClass): void
public static function postgreSQLVersionProvider(): array
{
return [
['10.0', PostgreSQLPlatform::class],
['11.0', PostgreSQLPlatform::class],
['12.0', PostgreSQL120Platform::class],
['13.16', PostgreSQL120Platform::class],
['16.4', PostgreSQL120Platform::class],
['12.0', PostgreSQLPlatform::class],
['13.16', PostgreSQLPlatform::class],
['16.4', PostgreSQLPlatform::class],
];
}

Expand Down
5 changes: 0 additions & 5 deletions tests/Functional/Schema/PostgreSQLSchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Doctrine\DBAL\Tests\Functional\Schema;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\PostgreSQL120Platform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Schema;
Expand Down Expand Up @@ -293,10 +292,6 @@ public function testBooleanDefault(): void

public function testGeneratedColumn(): void
{
if (! $this->connection->getDatabasePlatform() instanceof PostgreSQL120Platform) {
self::markTestSkipped('Generated columns are not supported in Postgres 11 and earlier');
}

$table = new Table('ddc6198_generated_always_as');
$table->addColumn('id', Types::INTEGER);
$table->addColumn(
Expand Down

0 comments on commit 116256c

Please sign in to comment.