Skip to content

Commit

Permalink
Merge branch '4.1.x' into 5.0.x
Browse files Browse the repository at this point in the history
* 4.1.x:
  MySQL 8.4 Platform (#6385)
  • Loading branch information
derrabus committed May 16, 2024
2 parents 5433383 + 002a4d9 commit 8c43133
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/en/reference/platforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ MySQL

- ``MySQLPlatform`` for version 5.7 (5.7.9 GA) and above.
- ``MySQL80Platform`` for version 8.0 (8.0 GA) and above.
- ``MySQL84Platform`` for version 8.4 (8.4 GA) and above.

MariaDB
^^^^^
Expand Down
5 changes: 5 additions & 0 deletions src/Driver/AbstractMySQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Doctrine\DBAL\Platforms\Exception\InvalidPlatformVersion;
use Doctrine\DBAL\Platforms\MariaDB1060Platform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQL84Platform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\ServerVersionProvider;

Expand Down Expand Up @@ -40,6 +41,10 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): Abs
return new MariaDBPlatform();
}

if (version_compare($version, '8.4.0', '>=')) {
return new MySQL84Platform();
}

return new MySQLPlatform();
}

Expand Down
38 changes: 38 additions & 0 deletions src/Platforms/Keywords/MySQL84Keywords.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace Doctrine\DBAL\Platforms\Keywords;

use function array_merge;

/**
* MySQL 8.4 reserved keywords list.
*/
class MySQL84Keywords extends MySQLKeywords
{
/**
* {@inheritDoc}
*
* @link https://dev.mysql.com/doc/refman/8.4/en/keywords.html#keywords-new-in-current-series
*/
protected function getKeywords(): array

Check warning on line 19 in src/Platforms/Keywords/MySQL84Keywords.php

View check run for this annotation

Codecov / codecov/patch

src/Platforms/Keywords/MySQL84Keywords.php#L19

Added line #L19 was not covered by tests
{
$keywords = parent::getKeywords();

Check warning on line 21 in src/Platforms/Keywords/MySQL84Keywords.php

View check run for this annotation

Codecov / codecov/patch

src/Platforms/Keywords/MySQL84Keywords.php#L21

Added line #L21 was not covered by tests

$keywords = array_merge($keywords, [
'AUTO',
'BERNOULLI',
'GTIDS',
'LOG',
'MANUAL',
'PARALLEL',
'PARSE_TREE',
'QUALIFY',
'S3',
'TABLESAMPLE',
]);

Check warning on line 34 in src/Platforms/Keywords/MySQL84Keywords.php

View check run for this annotation

Codecov / codecov/patch

src/Platforms/Keywords/MySQL84Keywords.php#L23-L34

Added lines #L23 - L34 were not covered by tests

return $keywords;

Check warning on line 36 in src/Platforms/Keywords/MySQL84Keywords.php

View check run for this annotation

Codecov / codecov/patch

src/Platforms/Keywords/MySQL84Keywords.php#L36

Added line #L36 was not covered by tests
}
}
19 changes: 19 additions & 0 deletions src/Platforms/MySQL84Platform.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Platforms\Keywords\KeywordList;
use Doctrine\DBAL\Platforms\Keywords\MySQL84Keywords;

/**
* Provides the behavior, features and SQL dialect of the MySQL 8.4 (8.4 GA) database platform.
*/
class MySQL84Platform extends MySQLPlatform
{
protected function createReservedKeywordsList(): KeywordList

Check warning on line 15 in src/Platforms/MySQL84Platform.php

View check run for this annotation

Codecov / codecov/patch

src/Platforms/MySQL84Platform.php#L15

Added line #L15 was not covered by tests
{
return new MySQL84Keywords();

Check warning on line 17 in src/Platforms/MySQL84Platform.php

View check run for this annotation

Codecov / codecov/patch

src/Platforms/MySQL84Platform.php#L17

Added line #L17 was not covered by tests
}
}
2 changes: 2 additions & 0 deletions tests/Driver/VersionAwarePlatformDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MariaDB1060Platform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQL84Platform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use PHPUnit\Framework\Attributes\DataProvider;
Expand All @@ -33,6 +34,7 @@ public static function mySQLVersionProvider(): array
{
return [
['8.0.11', MySQLPlatform::class],
['8.4.0', MySQL84Platform::class],
['5.5.40-MariaDB-1~wheezy', MariaDBPlatform::class],
['5.5.5-MariaDB-10.2.8+maria~xenial-log', MariaDBPlatform::class],
['10.2.8-MariaDB-10.2.8+maria~xenial-log', MariaDBPlatform::class],
Expand Down

0 comments on commit 8c43133

Please sign in to comment.