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

MySQL 8.4 Platform #6385

Merged
merged 1 commit into from
May 16, 2024
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
1 change: 1 addition & 0 deletions docs/en/reference/platforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^
Expand Down
17 changes: 17 additions & 0 deletions src/Driver/AbstractMySQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -130,6 +145,8 @@ private function getOracleMysqlVersionNumber(string $versionString): string

if ($majorVersion === '5' && $minorVersion === '7') {
$patchVersion ??= '9';
} else {
$patchVersion ??= '0';
wmouwen marked this conversation as resolved.
Show resolved Hide resolved
}

return $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
Expand Down
54 changes: 54 additions & 0 deletions src/Platforms/Keywords/MySQL84Keywords.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace Doctrine\DBAL\Platforms\Keywords;

use Doctrine\Deprecations\Deprecation;

use function array_merge;

/**
* MySQL 8.4 reserved keywords list.
*/
class MySQL84Keywords extends MySQL80Keywords
{
/**
* {@inheritDoc}
*
* @deprecated
*/
public function getName()

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
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5433',
'MySQL84Keywords::getName() is deprecated.',
);

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

View check run for this annotation

Codecov / codecov/patch

src/Platforms/Keywords/MySQL84Keywords.php#L21-L25

Added lines #L21 - L25 were not covered by tests

return 'MySQL84';

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

View check run for this annotation

Codecov / codecov/patch

src/Platforms/Keywords/MySQL84Keywords.php#L27

Added line #L27 was not covered by tests
}

/**
* {@inheritDoc}
*
* @link https://dev.mysql.com/doc/refman/8.4/en/keywords.html#keywords-new-in-current-series
*/
protected function getKeywords()
{
$keywords = parent::getKeywords();

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

return $keywords;
}
}
28 changes: 28 additions & 0 deletions src/Platforms/MySQL84Platform.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Doctrine\DBAL\Platforms;

use Doctrine\Deprecations\Deprecation;

/**
* Provides the behavior, features and SQL dialect of the MySQL 8.4 (8.4 GA) database platform.
*/
class MySQL84Platform extends MySQL80Platform
{
/**
* {@inheritDoc}
*
* @deprecated Implement {@see createReservedKeywordsList()} instead.
*/
protected function getReservedKeywordsClass()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4510',
'MySQL84Platform::getReservedKeywordsClass() is deprecated,'
. ' use MySQL84Platform::createReservedKeywordsList() instead.',
);

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

View check run for this annotation

Codecov / codecov/patch

src/Platforms/MySQL84Platform.php#L24

Added line #L24 was not covered by tests

return Keywords\MySQL84Keywords::class;
}
}
3 changes: 3 additions & 0 deletions src/Tools/Console/Command/ReservedWordsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Doctrine\DBAL\Platforms\Keywords\MariaDb102Keywords;
use Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords;
use Doctrine\DBAL\Platforms\Keywords\MySQL80Keywords;
use Doctrine\DBAL\Platforms\Keywords\MySQL84Keywords;
use Doctrine\DBAL\Platforms\Keywords\MySQLKeywords;
use Doctrine\DBAL\Platforms\Keywords\OracleKeywords;
use Doctrine\DBAL\Platforms\Keywords\PostgreSQL100Keywords;
Expand Down Expand Up @@ -59,6 +60,7 @@
'mysql' => new MySQLKeywords(),
'mysql57' => new MySQL57Keywords(),
'mysql80' => new MySQL80Keywords(),
'mysql84' => new MySQL84Keywords(),

Check warning on line 63 in src/Tools/Console/Command/ReservedWordsCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Tools/Console/Command/ReservedWordsCommand.php#L63

Added line #L63 was not covered by tests
'oracle' => new OracleKeywords(),
'pgsql' => new PostgreSQL94Keywords(),
'pgsql100' => new PostgreSQL100Keywords(),
Expand Down Expand Up @@ -130,6 +132,7 @@
* mysql
* mysql57
* mysql80
* mysql84
* oracle
* pgsql
* pgsql100
Expand Down
3 changes: 3 additions & 0 deletions tests/Driver/VersionAwarePlatformDriverTest.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\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;
Expand Down Expand Up @@ -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],
Expand Down