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

Drop support for MariaDB 10.2 and 10.3 #6122

Merged
merged 1 commit into from
Aug 8, 2023
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
3 changes: 1 addition & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ jobs:
php-version:
- "8.1"
mariadb-version:
- "10.2" # Oldest version supported by DBAL
- "10.4" # LTS (Jun 2024)
- "10.4" # Oldest version supported by DBAL, LTS (Jun 2024)
- "10.5" # LTS (Jun 2025)
- "10.6" # LTS (Jul 2026)
- "10.9" # STS (Aug 2023)
Expand Down
5 changes: 3 additions & 2 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,12 @@ The `Doctrine\DBAL\Schema\Visitor\Graphviz` class has been removed.

Oracle 12c (12.2.0.1) and older are not supported anymore.

## BC BREAK: Removed support for MariaDB 10.2.6 and older
## BC BREAK: Removed support for MariaDB 10.4.2 and older

MariaDB 10.2.6 and older are not supported anymore. The following classes have been removed:
MariaDB 10.4.2 and older are not supported anymore. The following classes have been removed:

* `Doctrine\DBAL\Platforms\MariaDb1027Platform`
* `Doctrine\DBAL\Platforms\MariaDB1043Platform`
* `Doctrine\DBAL\Platforms\Keywords\MariaDb102Keywords`

## BC BREAK: Removed support for MySQL 5.6 and older
Expand Down
3 changes: 2 additions & 1 deletion docs/en/reference/platforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ MySQL
MariaDB
^^^^^

- ``MariaDBPlatform`` for version 10.2 (10.2.7 GA) and above.
- ``MariaDBPlatform`` for version 10.4 (10.4.3 GA) and above.
- ``MariaDB1052Platform`` for version 10.5 (10.5.2 GA) and above.

Oracle
^^^^^^
Expand Down
5 changes: 0 additions & 5 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
<file name="src/Driver/OCI8/ConvertPositionalToNamedPlaceholders.php"/>
</errorLevel>
</ConflictingReferenceConstraint>
<DeprecatedClass>
<errorLevel type="suppress">
<referencedClass name="Doctrine\DBAL\Platforms\MariaDB1043Platform"/>
</errorLevel>
</DeprecatedClass>
<DeprecatedMethod>
<errorLevel type="suppress">
<!-- TODO for PHPUnit 10 -->
Expand Down
5 changes: 0 additions & 5 deletions src/Driver/AbstractMySQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\Exception\InvalidPlatformVersion;
use Doctrine\DBAL\Platforms\MariaDB1043Platform;
use Doctrine\DBAL\Platforms\MariaDB1052Platform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQL80Platform;
Expand Down Expand Up @@ -38,10 +37,6 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): Abs
return new MariaDB1052Platform();
}

if (version_compare($mariaDbVersion, '10.4.3', '>=')) {
return new MariaDB1043Platform();
}

return new MariaDBPlatform();
}

Expand Down
80 changes: 0 additions & 80 deletions src/Platforms/MariaDB1043Platform.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Platforms/MariaDB1052Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* Note: Should not be used with versions prior to 10.5.2.
*/
class MariaDB1052Platform extends MariaDB1043Platform
class MariaDB1052Platform extends MariaDBPlatform
{
/**
* {@inheritDoc}
Expand Down
58 changes: 56 additions & 2 deletions src/Platforms/MariaDBPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\DBAL\Platforms\Keywords\MariaDBKeywords;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\JsonType;

use function array_diff_key;
use function array_merge;
Expand All @@ -20,13 +21,53 @@
class MariaDBPlatform extends AbstractMySQLPlatform
{
/**
* {@inheritDoc}
* Use JSON rather than LONGTEXT for json columns. Since it is not a true native type, do not override
* hasNativeJsonType() so the DC2Type comment will still be set.
*
* @link https://mariadb.com/kb/en/library/json-data-type/
*
* {@inheritDoc}
*/
public function getJsonTypeDeclarationSQL(array $column): string
{
return 'LONGTEXT';
return 'JSON';
}

/**
* Generate SQL snippets to reverse the aliasing of JSON to LONGTEXT.
*
* MariaDb aliases columns specified as JSON to LONGTEXT and sets a CHECK constraint to ensure the column
* is valid json. This function generates the SQL snippets which reverse this aliasing i.e. report a column
* as JSON where it was originally specified as such instead of LONGTEXT.
*
* The CHECK constraints are stored in information_schema.CHECK_CONSTRAINTS so JOIN that table.
*
* @return array{string, string}
*/
public function getColumnTypeSQLSnippets(string $tableAlias = 'c'): array
{
if ($this->getJsonTypeDeclarationSQL([]) !== 'JSON') {
return parent::getColumnTypeSQLSnippets($tableAlias);

Check warning on line 50 in src/Platforms/MariaDBPlatform.php

View check run for this annotation

Codecov / codecov/patch

src/Platforms/MariaDBPlatform.php#L50

Added line #L50 was not covered by tests
}

$columnTypeSQL = <<<SQL
IF(
x.CHECK_CLAUSE IS NOT NULL AND $tableAlias.COLUMN_TYPE = 'longtext',
'json',
$tableAlias.COLUMN_TYPE
)
SQL;

$joinCheckConstraintSQL = <<<SQL
LEFT JOIN information_schema.CHECK_CONSTRAINTS x
ON (
$tableAlias.TABLE_SCHEMA = x.CONSTRAINT_SCHEMA
AND $tableAlias.TABLE_NAME = x.TABLE_NAME
AND x.CHECK_CLAUSE = CONCAT('json_valid(`', $tableAlias.COLUMN_NAME , '`)')
)
SQL;

return [$columnTypeSQL, $joinCheckConstraintSQL];
}

/**
Expand Down Expand Up @@ -119,6 +160,19 @@
return $foreignKeys;
}

/** {@inheritDoc} */
public function getColumnDeclarationSQL(string $name, array $column): string
{
// MariaDb forces column collation to utf8mb4_bin where the column was declared as JSON so ignore
// collation and character set for json columns as attempting to set them can cause an error.
if ($this->getJsonTypeDeclarationSQL([]) === 'JSON' && ($column['type'] ?? null) instanceof JsonType) {
unset($column['collation']);
unset($column['charset']);
}

return parent::getColumnDeclarationSQL($name, $column);
}

protected function createReservedKeywordsList(): KeywordList
{
return new MariaDBKeywords();
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Schema/MySQL/ComparatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MariaDB1043Platform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Comparator;
Expand Down Expand Up @@ -177,7 +177,7 @@ public static function tableAndColumnOptionsProvider(): iterable

public function testMariaDb1043NativeJsonUpgradeDetected(): void
{
if (! $this->platform instanceof MariaDB1043Platform) {
if (! $this->platform instanceof MariaDBPlatform) {
self::markTestSkipped();
}

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

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MariaDB1043Platform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Table;
Expand All @@ -31,7 +31,7 @@ protected function setUp(): void
{
$this->platform = $this->connection->getDatabasePlatform();

if (! $this->platform instanceof MariaDB1043Platform) {
if (! $this->platform instanceof MariaDBPlatform) {
self::markTestSkipped();
}

Expand Down
39 changes: 0 additions & 39 deletions tests/Platforms/MariaDB1043PlatformTest.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Platforms/MariaDB1052PlatformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MariaDB1052Platform;

class MariaDB1052PlatformTest extends MariaDB1043PlatformTest
class MariaDB1052PlatformTest extends MariaDBPlatformTest
{
public function createPlatform(): AbstractPlatform
{
Expand Down
5 changes: 3 additions & 2 deletions tests/Platforms/MariaDBPlatformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ public function createPlatform(): AbstractPlatform
}

/**
* From MariaDB 10.2.7, JSON type is an alias to LONGTEXT
* From MariaDB 10.2.7, JSON type is an alias to LONGTEXT however from 10.4.3 setting a column
* as JSON adds additional functionality so use JSON.
*
* @link https://mariadb.com/kb/en/library/json-data-type/
*/
public function testReturnsJsonTypeDeclarationSQL(): void
{
self::assertSame('LONGTEXT', $this->platform->getJsonTypeDeclarationSQL([]));
self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL([]));
}

public function testInitializesJsonTypeMapping(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Platforms/MySQL/MariaDBJsonComparatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Doctrine\DBAL\Tests\Platforms\MySQL;

use Doctrine\DBAL\Platforms\MariaDB1043Platform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQL\CharsetMetadataProvider;
use Doctrine\DBAL\Platforms\MySQL\CollationMetadataProvider;
use Doctrine\DBAL\Platforms\MySQL\Comparator;
Expand All @@ -25,7 +25,7 @@ class MariaDBJsonComparatorTest extends TestCase
protected function setUp(): void
{
$this->comparator = new Comparator(
new MariaDB1043Platform(),
new MariaDBPlatform(),
new class implements CharsetMetadataProvider {
public function getDefaultCharsetCollation(string $charset): ?string
{
Expand Down