From 8141266069c9f66c0d11a6574fc3222bb669f937 Mon Sep 17 00:00:00 2001 From: Willem Mouwen <13197752+wmouwen@users.noreply.github.com> Date: Thu, 16 May 2024 10:51:06 +0200 Subject: [PATCH] MySQL 8.4 Platform (#6385) | Q | A |------------- | ----------- | Type | improvement | Fixed issues | none #### Summary MySQL 8.4 introduces a new set of reserved keywords ([link][8.4-reserved-keywords]). This PR adds a new platform definition for MySQL 8.4 and higher. [8.4-reserved-keywords]: https://dev.mysql.com/doc/refman/8.4/en/keywords.html#keywords-new-in-current-series #### Related - #6386 --- docs/en/reference/platforms.rst | 1 + src/Driver/AbstractMySQLDriver.php | 17 ++++++ src/Platforms/Keywords/MySQL84Keywords.php | 54 +++++++++++++++++++ src/Platforms/MySQL84Platform.php | 28 ++++++++++ .../Console/Command/ReservedWordsCommand.php | 3 ++ .../Driver/VersionAwarePlatformDriverTest.php | 3 ++ 6 files changed, 106 insertions(+) create mode 100644 src/Platforms/Keywords/MySQL84Keywords.php create mode 100644 src/Platforms/MySQL84Platform.php diff --git a/docs/en/reference/platforms.rst b/docs/en/reference/platforms.rst index 4cf60ca186f..c28e119aed4 100644 --- a/docs/en/reference/platforms.rst +++ b/docs/en/reference/platforms.rst @@ -36,6 +36,7 @@ MySQL - ``MySQLPlatform`` for version 5.0 and above. - ``MySQL57Platform`` 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 ^^^^^ diff --git a/src/Driver/AbstractMySQLDriver.php b/src/Driver/AbstractMySQLDriver.php index 83159a540da..8942795d8fa 100644 --- a/src/Driver/AbstractMySQLDriver.php +++ b/src/Driver/AbstractMySQLDriver.php @@ -14,6 +14,7 @@ use Doctrine\DBAL\Platforms\MariaDb1060Platform; use Doctrine\DBAL\Platforms\MySQL57Platform; use Doctrine\DBAL\Platforms\MySQL80Platform; +use Doctrine\DBAL\Platforms\MySQL84Platform; use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\DBAL\Schema\MySQLSchemaManager; use Doctrine\DBAL\VersionAwarePlatformDriver; @@ -64,6 +65,20 @@ public function createDatabasePlatformForVersion($version) } } else { $oracleMysqlVersion = $this->getOracleMysqlVersionNumber($version); + + if (version_compare($oracleMysqlVersion, '8.4.0', '>=')) { + if (! version_compare($version, '8.4.0', '>=')) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/dbal/pull/5779', + 'Version detection logic for MySQL will change in DBAL 4. ' + . 'Please specify the version as the server reports it, e.g. "8.4.0" instead of "8.4".', + ); + } + + return new MySQL84Platform(); + } + if (version_compare($oracleMysqlVersion, '8', '>=')) { if (! version_compare($version, '8.0.0', '>=')) { Deprecation::trigger( @@ -130,6 +145,8 @@ private function getOracleMysqlVersionNumber(string $versionString): string if ($majorVersion === '5' && $minorVersion === '7') { $patchVersion ??= '9'; + } else { + $patchVersion ??= '0'; } return $majorVersion . '.' . $minorVersion . '.' . $patchVersion; diff --git a/src/Platforms/Keywords/MySQL84Keywords.php b/src/Platforms/Keywords/MySQL84Keywords.php new file mode 100644 index 00000000000..1813f77abc2 --- /dev/null +++ b/src/Platforms/Keywords/MySQL84Keywords.php @@ -0,0 +1,54 @@ + new MySQLKeywords(), 'mysql57' => new MySQL57Keywords(), 'mysql80' => new MySQL80Keywords(), + 'mysql84' => new MySQL84Keywords(), 'oracle' => new OracleKeywords(), 'pgsql' => new PostgreSQL94Keywords(), 'pgsql100' => new PostgreSQL100Keywords(), @@ -130,6 +132,7 @@ protected function configure() * mysql * mysql57 * mysql80 + * mysql84 * oracle * pgsql * pgsql100 diff --git a/tests/Driver/VersionAwarePlatformDriverTest.php b/tests/Driver/VersionAwarePlatformDriverTest.php index 8a84607f954..897dd9ba19e 100644 --- a/tests/Driver/VersionAwarePlatformDriverTest.php +++ b/tests/Driver/VersionAwarePlatformDriverTest.php @@ -13,6 +13,7 @@ use Doctrine\DBAL\Platforms\MariaDb1060Platform; use Doctrine\DBAL\Platforms\MySQL57Platform; use Doctrine\DBAL\Platforms\MySQL80Platform; +use Doctrine\DBAL\Platforms\MySQL84Platform; use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\DBAL\Platforms\PostgreSQL100Platform; use Doctrine\DBAL\Platforms\PostgreSQL94Platform; @@ -51,6 +52,8 @@ public static function mySQLVersionProvider(): array ['8', MySQL80Platform::class], ['8.0', MySQL80Platform::class], ['8.0.11', MySQL80Platform::class], + ['8.4', MySQL84Platform::class], + ['8.4.0', MySQL84Platform::class], ['6', MySQL57Platform::class], ['10.0.15-MariaDB-1~wheezy', MySQLPlatform::class], ['5.5.5-10.1.25-MariaDB', MySQLPlatform::class],