Skip to content

Commit 2ac13d5

Browse files
committed
MySQL 8.4 Platform
1 parent 5dc61db commit 2ac13d5

File tree

6 files changed

+112
-0
lines changed

6 files changed

+112
-0
lines changed

docs/en/reference/platforms.rst

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ MySQL
3636
- ``MySQLPlatform`` for version 5.0 and above.
3737
- ``MySQL57Platform`` for version 5.7 (5.7.9 GA) and above.
3838
- ``MySQL80Platform`` for version 8.0 (8.0 GA) and above.
39+
- ``MySQL84Platform`` for version 8.4 (8.4 GA) and above.
3940

4041
MariaDB
4142
^^^^^

src/Driver/AbstractMySQLDriver.php

+17
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\DBAL\Platforms\MariaDb1060Platform;
1515
use Doctrine\DBAL\Platforms\MySQL57Platform;
1616
use Doctrine\DBAL\Platforms\MySQL80Platform;
17+
use Doctrine\DBAL\Platforms\MySQL84Platform;
1718
use Doctrine\DBAL\Platforms\MySQLPlatform;
1819
use Doctrine\DBAL\Schema\MySQLSchemaManager;
1920
use Doctrine\DBAL\VersionAwarePlatformDriver;
@@ -64,6 +65,20 @@ public function createDatabasePlatformForVersion($version)
6465
}
6566
} else {
6667
$oracleMysqlVersion = $this->getOracleMysqlVersionNumber($version);
68+
69+
if (version_compare($oracleMysqlVersion, '8.4.0', '>=')) {
70+
if (! version_compare($version, '8.4.0', '>=')) {
71+
Deprecation::trigger(
72+
'doctrine/orm',
73+
'https://github.com/doctrine/dbal/pull/5779',
74+
'Version detection logic for MySQL will change in DBAL 4. '
75+
. 'Please specify the version as the server reports it, e.g. "8.4.0" instead of "8.4".',
76+
);
77+
}
78+
79+
return new MySQL84Platform();
80+
}
81+
6782
if (version_compare($oracleMysqlVersion, '8', '>=')) {
6883
if (! version_compare($version, '8.0.0', '>=')) {
6984
Deprecation::trigger(
@@ -130,6 +145,8 @@ private function getOracleMysqlVersionNumber(string $versionString): string
130145

131146
if ($majorVersion === '5' && $minorVersion === '7') {
132147
$patchVersion ??= '9';
148+
} else {
149+
$patchVersion ??= '0';
133150
}
134151

135152
return $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
namespace Doctrine\DBAL\Platforms\Keywords;
4+
5+
use Doctrine\Deprecations\Deprecation;
6+
7+
use function array_merge;
8+
9+
/**
10+
* MySQL 8.4 reserved keywords list.
11+
*/
12+
class MySQL84Keywords extends MySQL80Keywords
13+
{
14+
/**
15+
* {@inheritDoc}
16+
*
17+
* @deprecated
18+
*/
19+
public function getName()
20+
{
21+
Deprecation::triggerIfCalledFromOutside(
22+
'doctrine/dbal',
23+
'https://github.com/doctrine/dbal/pull/5433',
24+
'MySQL84Keywords::getName() is deprecated.',
25+
);
26+
27+
return 'MySQL84';
28+
}
29+
30+
/**
31+
* {@inheritDoc}
32+
*
33+
* @link https://dev.mysql.com/doc/refman/8.4/en/keywords.html#keywords-new-in-current-series
34+
*/
35+
protected function getKeywords()
36+
{
37+
$keywords = parent::getKeywords();
38+
39+
$keywords = array_merge($keywords, [
40+
'AUTO',
41+
'BERNOULLI',
42+
'GTIDS',
43+
'LOG',
44+
'MANUAL',
45+
'PARALLEL',
46+
'PARSE_TREE',
47+
'QUALIFY',
48+
'S3',
49+
'TABLESAMPLE',
50+
]);
51+
52+
return $keywords;
53+
}
54+
}

src/Platforms/MySQL84Platform.php

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Doctrine\DBAL\Platforms;
4+
5+
use Doctrine\DBAL\SQL\Builder\SelectSQLBuilder;
6+
use Doctrine\Deprecations\Deprecation;
7+
8+
/**
9+
* Provides the behavior, features and SQL dialect of the MySQL 8.4 (8.4 GA) database platform.
10+
*/
11+
class MySQL84Platform extends MySQL80Platform
12+
{
13+
/**
14+
* {@inheritDoc}
15+
*
16+
* @deprecated Implement {@see createReservedKeywordsList()} instead.
17+
*/
18+
protected function getReservedKeywordsClass()
19+
{
20+
Deprecation::triggerIfCalledFromOutside(
21+
'doctrine/dbal',
22+
'https://github.com/doctrine/dbal/issues/4510',
23+
'MySQL84Platform::getReservedKeywordsClass() is deprecated,'
24+
. ' use MySQL84Platform::createReservedKeywordsList() instead.',
25+
);
26+
27+
return Keywords\MySQL84Keywords::class;
28+
}
29+
30+
public function createSelectSQLBuilder(): SelectSQLBuilder
31+
{
32+
return AbstractPlatform::createSelectSQLBuilder();
33+
}
34+
}

src/Tools/Console/Command/ReservedWordsCommand.php

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Doctrine\DBAL\Platforms\Keywords\MariaDb102Keywords;
1010
use Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords;
1111
use Doctrine\DBAL\Platforms\Keywords\MySQL80Keywords;
12+
use Doctrine\DBAL\Platforms\Keywords\MySQL84Keywords;
1213
use Doctrine\DBAL\Platforms\Keywords\MySQLKeywords;
1314
use Doctrine\DBAL\Platforms\Keywords\OracleKeywords;
1415
use Doctrine\DBAL\Platforms\Keywords\PostgreSQL100Keywords;
@@ -59,6 +60,7 @@ public function __construct(ConnectionProvider $connectionProvider)
5960
'mysql' => new MySQLKeywords(),
6061
'mysql57' => new MySQL57Keywords(),
6162
'mysql80' => new MySQL80Keywords(),
63+
'mysql84' => new MySQL84Keywords(),
6264
'oracle' => new OracleKeywords(),
6365
'pgsql' => new PostgreSQL94Keywords(),
6466
'pgsql100' => new PostgreSQL100Keywords(),
@@ -130,6 +132,7 @@ protected function configure()
130132
* mysql
131133
* mysql57
132134
* mysql80
135+
* mysql84
133136
* oracle
134137
* pgsql
135138
* pgsql100

tests/Driver/VersionAwarePlatformDriverTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Doctrine\DBAL\Platforms\MariaDb1060Platform;
1414
use Doctrine\DBAL\Platforms\MySQL57Platform;
1515
use Doctrine\DBAL\Platforms\MySQL80Platform;
16+
use Doctrine\DBAL\Platforms\MySQL84Platform;
1617
use Doctrine\DBAL\Platforms\MySQLPlatform;
1718
use Doctrine\DBAL\Platforms\PostgreSQL100Platform;
1819
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
@@ -51,6 +52,8 @@ public static function mySQLVersionProvider(): array
5152
['8', MySQL80Platform::class],
5253
['8.0', MySQL80Platform::class],
5354
['8.0.11', MySQL80Platform::class],
55+
['8.4', MySQL84Platform::class],
56+
['8.4.0', MySQL84Platform::class],
5457
['6', MySQL57Platform::class],
5558
['10.0.15-MariaDB-1~wheezy', MySQLPlatform::class],
5659
['5.5.5-10.1.25-MariaDB', MySQLPlatform::class],

0 commit comments

Comments
 (0)