Skip to content

Commit

Permalink
Merge branch '3.9.x' into 4.1.x
Browse files Browse the repository at this point in the history
* 3.9.x:
  MySQL 8.4 Platform (doctrine#6385)
  • Loading branch information
derrabus committed May 16, 2024
2 parents 22f1d3a + 8141266 commit 002a4d9
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 @@ -13,6 +13,7 @@
use Doctrine\DBAL\Platforms\MariaDB1060Platform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQL80Platform;
use Doctrine\DBAL\Platforms\MySQL84Platform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\ServerVersionProvider;
use Doctrine\Deprecations\Deprecation;
Expand Down Expand Up @@ -53,6 +54,10 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): Abs
return new MariaDBPlatform();
}

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

if (version_compare($version, '8.0.0', '>=')) {
return new MySQL80Platform();
}
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 MySQL80Keywords
{
/**
* {@inheritDoc}
*
* @link https://dev.mysql.com/doc/refman/8.4/en/keywords.html#keywords-new-in-current-series
*/
protected function getKeywords(): array
{
$keywords = parent::getKeywords();

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

return $keywords;
}
}
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 MySQL80Platform
{
protected function createReservedKeywordsList(): KeywordList
{
return new MySQL84Keywords();
}
}
2 changes: 2 additions & 0 deletions tests/Driver/VersionAwarePlatformDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Doctrine\DBAL\Platforms\MariaDB1060Platform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQL80Platform;
use Doctrine\DBAL\Platforms\MySQL84Platform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use PHPUnit\Framework\Attributes\DataProvider;
Expand All @@ -36,6 +37,7 @@ public static function mySQLVersionProvider(): array
return [
['5.7.0', MySQLPlatform::class],
['8.0.11', MySQL80Platform::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 002a4d9

Please sign in to comment.