From b77af9de93d6e86d034500365fe8c1c75557e7ff Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Thu, 13 Jun 2019 23:11:19 +0200 Subject: [PATCH] Remove Postgres 9.3 and MariaDB 10.0 support --- .travis.yml | 19 +------- UPGRADE.md | 16 +++++++ docs/en/reference/configuration.rst | 10 ++--- docs/en/reference/platforms.rst | 3 +- docs/en/reference/types.rst | 4 +- .../DBAL/Driver/AbstractPostgreSQLDriver.php | 14 +++--- .../Keywords/PostgreSQL100Keywords.php | 2 +- .../Keywords/PostgreSQL94Keywords.php | 34 -------------- .../Platforms/Keywords/PostgreSQLKeywords.php | 4 +- .../DBAL/Platforms/PostgreSQL100Platform.php | 2 +- .../DBAL/Platforms/PostgreSQL94Platform.php | 45 ------------------- .../DBAL/Platforms/PostgreSqlPlatform.php | 5 +++ .../Console/Command/ReservedWordsCommand.php | 6 +-- .../Driver/AbstractPostgreSQLDriverTest.php | 10 ++--- .../Schema/PostgreSqlSchemaManagerTest.php | 4 +- .../Platforms/PostgreSQL100PlatformTest.php | 2 +- .../Platforms/PostgreSQL94PlatformTest.php | 34 -------------- .../DBAL/Platforms/PostgreSqlPlatformTest.php | 4 ++ 18 files changed, 51 insertions(+), 167 deletions(-) delete mode 100644 lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL94Keywords.php delete mode 100644 lib/Doctrine/DBAL/Platforms/PostgreSQL94Platform.php delete mode 100644 tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php diff --git a/.travis.yml b/.travis.yml index 0e014417efa..53f08c52f1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -147,11 +147,6 @@ jobs: - docker before_script: - bash ./tests/travis/install-mysql-8.0.sh - - stage: Test - php: 7.3 - env: DB=mariadb MARIADB_VERSION=10.0 COVERAGE=yes - addons: - mariadb: 10.0 - stage: Test php: 7.3 env: DB=mariadb MARIADB_VERSION=10.1 COVERAGE=yes @@ -167,11 +162,6 @@ jobs: env: DB=mariadb MARIADB_VERSION=10.3 COVERAGE=yes addons: mariadb: 10.3 - - stage: Test - php: 7.3 - env: DB=mariadb.mysqli MARIADB_VERSION=10.0 COVERAGE=yes - addons: - mariadb: 10.0 - stage: Test php: 7.3 env: DB=mariadb.mysqli MARIADB_VERSION=10.1 COVERAGE=yes @@ -187,13 +177,6 @@ jobs: env: DB=mariadb.mysqli MARIADB_VERSION=10.3 COVERAGE=yes addons: mariadb: 10.3 - - stage: Test - php: 7.3 - env: DB=pgsql POSTGRESQL_VERSION=9.3 COVERAGE=yes - services: - - postgresql - addons: - postgresql: "9.3" - stage: Test php: 7.3 env: DB=pgsql POSTGRESQL_VERSION=9.4 COVERAGE=yes @@ -222,7 +205,7 @@ jobs: services: - postgresql addons: - postgresql: "9.6" + postgresql: "10.0" before_script: - bash ./tests/travis/install-postgres-10.sh - stage: Test diff --git a/UPGRADE.md b/UPGRADE.md index 6ecce0dd10e..7ead2321b99 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,21 @@ # Upgrade to 3.0 +## BC BREAK: Removed support for PostgreSQL 9.3 and older + +DBAL now requires PostgeSQL 9.4 or newer, support for unmaintained versions has been dropped. +If you are using any of the legacy versions, you have to upgrade to newer PostgreSQL version (9.6+ is recommended). +`Doctrine\DBAL\Platforms\PostgreSqlPlatform` and `Doctrine\DBAL\Platforms\Keywords\PostgreSQLKeywords` now represent the PostgreSQL 9.4. + +The following classes have been removed: + + * `Doctrine\DBAL\Platforms\PostgreSQL94Platform` + * `Doctrine\DBAL\Platforms\Keywords\PostgreSQL94Keywords` + +## BC BREAK: Removed support for MariaDB 10.0 and older + +DBAL now requires MariaDB 10.1 or newer, support for unmaintained versions has been dropped. +If you are using any of the legacy versions, you have to upgrade to newer PostgreSQL version (10.1+ is recommended). + ## BC BREAK: Changes in obtaining the currently selected database name - The `Doctrine\DBAL\Driver::getDatabase()` method has been removed. Please use `Doctrine\DBAL\Connection::getDatabase()` instead. diff --git a/docs/en/reference/configuration.rst b/docs/en/reference/configuration.rst index a4fba806a0c..7a25975e241 100644 --- a/docs/en/reference/configuration.rst +++ b/docs/en/reference/configuration.rst @@ -229,20 +229,20 @@ pdo_pgsql - ``sslmode`` (string): Determines whether or with what priority a SSL TCP/IP connection will be negotiated with the server. See the list of available modes: - `https://www.postgresql.org/docs/9.3/static/libpq-connect.html#LIBPQ-CONNECT-SSLMODE` + `https://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLMODE` - ``sslrootcert`` (string): specifies the name of a file containing SSL certificate authority (CA) certificate(s). If the file exists, the server's certificate will be verified to be signed by one of these authorities. - See https://www.postgresql.org/docs/9.3/static/libpq-connect.html#LIBPQ-CONNECT-SSLROOTCERT + See https://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLROOTCERT - ``sslcert`` (string): specifies the file name of the client SSL certificate. - See `https://www.postgresql.org/docs/9.3/static/libpq-connect.html#LIBPQ-CONNECT-SSLCERT` + See `https://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLCERT` - ``sslkey`` (string): specifies the location for the secret key used for the client certificate. - See `https://www.postgresql.org/docs/9.3/static/libpq-connect.html#LIBPQ-CONNECT-SSLKEY` + See `https://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLKEY` - ``sslcrl`` (string): specifies the file name of the SSL certificate revocation list (CRL). - See `https://www.postgresql.org/docs/9.3/static/libpq-connect.html#LIBPQ-CONNECT-SSLCRL` + See `https://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNECT-SSLCRL` - ``application_name`` (string): Name of the application that is connecting to database. Optional. It will be displayed at ``pg_stat_activity``. diff --git a/docs/en/reference/platforms.rst b/docs/en/reference/platforms.rst index 12e292eec11..a2a23ab671f 100644 --- a/docs/en/reference/platforms.rst +++ b/docs/en/reference/platforms.rst @@ -56,8 +56,7 @@ Microsoft SQL Server PostgreSQL ^^^^^^^^^^ -- ``PostgreSqlPlatform`` for all versions. -- ``PostgreSQL94Platform`` for version 9.4 and above. +- ``PostgreSqlPlatform`` for version 9.4 and above. - ``PostgreSQL100Platform`` for version 10.0 and above. SAP Sybase SQL Anywhere diff --git a/docs/en/reference/types.rst b/docs/en/reference/types.rst index dd733f33a51..81efed85885 100644 --- a/docs/en/reference/types.rst +++ b/docs/en/reference/types.rst @@ -741,9 +741,7 @@ Please also notice the mapping specific footnotes for additional information. | | | | +----------------------------------------------------------+ | | | | | ``LONGTEXT`` [19]_ | | | +--------------------------+---------+----------------------------------------------------------+ -| | | **PostgreSQL** | < 9.4 | ``JSON`` | -| | | +---------+----------------------------------------------------------+ -| | | | >= 9.4 | ``JSON`` [20]_ | +| | | **PostgreSQL** | *all* | ``JSON`` [20]_ | | | | | +----------------------------------------------------------+ | | | | | ``JSONB`` [21]_ | | | +--------------------------+---------+----------------------------------------------------------+ diff --git a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php index c1052779f9d..8f067e1a732 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php @@ -12,7 +12,6 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\Exception\InvalidPlatformVersion; use Doctrine\DBAL\Platforms\PostgreSQL100Platform; -use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\PostgreSqlSchemaManager; @@ -29,7 +28,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri /** * {@inheritdoc} * - * @link http://www.postgresql.org/docs/9.3/static/errcodes-appendix.html + * @link http://www.postgresql.org/docs/9.4/static/errcodes-appendix.html */ public function convertException(string $message, DriverExceptionInterface $exception) : DriverException { @@ -97,14 +96,11 @@ public function createDatabasePlatformForVersion(string $version) : AbstractPlat $patchVersion = $versionParts['patch'] ?? 0; $version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion; - switch (true) { - case version_compare($version, '10.0', '>='): - return new PostgreSQL100Platform(); - case version_compare($version, '9.4', '>='): - return new PostgreSQL94Platform(); - default: - return new PostgreSqlPlatform(); + if (version_compare($version, '10.0', '>=')) { + return new PostgreSQL100Platform(); } + + return new PostgreSqlPlatform(); } /** diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php index 3402db1902c..80e4efadd60 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php @@ -7,7 +7,7 @@ /** * PostgreSQL 10.0 reserved keywords list. */ -class PostgreSQL100Keywords extends PostgreSQL94Keywords +class PostgreSQL100Keywords extends PostgreSQLKeywords { /** * {@inheritdoc} diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL94Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL94Keywords.php deleted file mode 100644 index f9244bb33d6..00000000000 --- a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL94Keywords.php +++ /dev/null @@ -1,34 +0,0 @@ -doctrineTypeMapping['jsonb'] = Types::JSON; - } -} diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php index 800b28a2b5b..3e045b62084 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php @@ -1136,6 +1136,7 @@ protected function initializeDoctrineTypeMappings() : void 'integer' => 'integer', 'interval' => 'string', 'json' => Type::JSON, + 'jsonb' => Type::JSON, 'money' => 'decimal', 'numeric' => 'decimal', 'serial' => 'integer', @@ -1213,6 +1214,10 @@ public function getColumnCollationDeclarationSQL(string $collation) : string */ public function getJsonTypeDeclarationSQL(array $field) : string { + if (! empty($field['jsonb'])) { + return 'JSONB'; + } + return 'JSON'; } diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php index 9c5ba8c79cd..0c60ea93d7d 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php @@ -6,12 +6,12 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Platforms\Keywords\DB2Keywords; +use Doctrine\DBAL\Platforms\Keywords\MariaDb102Keywords; use Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords; use Doctrine\DBAL\Platforms\Keywords\MySQL80Keywords; use Doctrine\DBAL\Platforms\Keywords\MySQLKeywords; use Doctrine\DBAL\Platforms\Keywords\OracleKeywords; use Doctrine\DBAL\Platforms\Keywords\PostgreSQL100Keywords; -use Doctrine\DBAL\Platforms\Keywords\PostgreSQL94Keywords; use Doctrine\DBAL\Platforms\Keywords\PostgreSQLKeywords; use Doctrine\DBAL\Platforms\Keywords\ReservedKeywordsValidator; use Doctrine\DBAL\Platforms\Keywords\SQLAnywhereKeywords; @@ -36,9 +36,9 @@ class ReservedWordsCommand extends Command 'mysql' => MySQLKeywords::class, 'mysql57' => MySQL57Keywords::class, 'mysql80' => MySQL80Keywords::class, + 'mariadb102' => MariaDb102Keywords::class, 'oracle' => OracleKeywords::class, 'pgsql' => PostgreSQLKeywords::class, - 'pgsql94' => PostgreSQL94Keywords::class, 'pgsql100' => PostgreSQL100Keywords::class, 'sqlanywhere' => SQLAnywhereKeywords::class, 'sqlite' => SQLiteKeywords::class, @@ -88,8 +88,8 @@ protected function configure() : void * mysql * mysql57 * mysql80 + * mariadb102 * pgsql - * pgsql94 * pgsql100 * sqlite * oracle diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php index 6e0ac2dd78c..4e0de15de2e 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php @@ -9,7 +9,6 @@ use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\PostgreSQL100Platform; -use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\PostgreSqlSchemaManager; @@ -37,12 +36,9 @@ protected function createSchemaManager(Connection $connection) : AbstractSchemaM protected function getDatabasePlatformsForVersions() : array { return [ - ['9.3', PostgreSqlPlatform::class], - ['9.3.0', PostgreSqlPlatform::class], - ['9.3.6', PostgreSqlPlatform::class], - ['9.4', PostgreSQL94Platform::class], - ['9.4.0', PostgreSQL94Platform::class], - ['9.4.1', PostgreSQL94Platform::class], + ['9.4', PostgreSqlPlatform::class], + ['9.4.0', PostgreSqlPlatform::class], + ['9.4.1', PostgreSqlPlatform::class], ['10', PostgreSQL100Platform::class], ]; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php index a749da18292..db16013f7a0 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php @@ -5,7 +5,7 @@ namespace Doctrine\Tests\DBAL\Functional\Schema; use Doctrine\DBAL\Platforms\AbstractPlatform; -use Doctrine\DBAL\Platforms\PostgreSQL94Platform; +use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\DBAL\Schema; use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\ForeignKeyConstraint; @@ -399,7 +399,7 @@ public function testPartialIndexes() : void public function testJsonbColumn() : void { - if (! $this->schemaManager->getDatabasePlatform() instanceof PostgreSQL94Platform) { + if (! $this->schemaManager->getDatabasePlatform() instanceof PostgreSqlPlatform) { $this->markTestSkipped('Requires PostgresSQL 9.4+'); return; diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php index 8eb58c98e72..4fb9c795371 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php @@ -7,7 +7,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\PostgreSQL100Platform; -class PostgreSQL100PlatformTest extends PostgreSQL94PlatformTest +class PostgreSQL100PlatformTest extends PostgreSqlPlatformTest { /** * {@inheritdoc} diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php deleted file mode 100644 index 4d18f199fc5..00000000000 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php +++ /dev/null @@ -1,34 +0,0 @@ -platform->getJsonTypeDeclarationSQL(['jsonb' => false])); - self::assertSame('JSONB', $this->platform->getJsonTypeDeclarationSQL(['jsonb' => true])); - } - - public function testInitializesJsonTypeMapping() : void - { - parent::testInitializesJsonTypeMapping(); - self::assertTrue($this->platform->hasDoctrineTypeMappingFor('jsonb')); - self::assertEquals(Types::JSON, $this->platform->getDoctrineTypeMapping('jsonb')); - } -} diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php index 478556f35d9..7209230ad3b 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php @@ -43,6 +43,8 @@ public function testHasNativeJsonType() : void public function testReturnsJsonTypeDeclarationSQL() : void { self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL([])); + self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL(['jsonb' => false])); + self::assertSame('JSONB', $this->platform->getJsonTypeDeclarationSQL(['jsonb' => true])); } public function testReturnsSmallIntTypeDeclarationSQL() : void @@ -70,6 +72,8 @@ public function testInitializesJsonTypeMapping() : void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('json')); self::assertEquals(Type::JSON, $this->platform->getDoctrineTypeMapping('json')); + self::assertTrue($this->platform->hasDoctrineTypeMappingFor('jsonb')); + self::assertEquals(Type::JSON, $this->platform->getDoctrineTypeMapping('jsonb')); } /**