Skip to content

Commit

Permalink
MySQL 8.4 Platform
Browse files Browse the repository at this point in the history
  • Loading branch information
wmouwen committed May 5, 2024
1 parent d0f6167 commit 569e4c5
Show file tree
Hide file tree
Showing 6 changed files with 112 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 @@ -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';
}

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()

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

View check run for this annotation

Codecov / codecov/patch

src/Platforms/Keywords/MySQL84Keywords.php#L35

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

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

View check run for this annotation

Codecov / codecov/patch

src/Platforms/Keywords/MySQL84Keywords.php#L37

Added line #L37 was not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

src/Platforms/Keywords/MySQL84Keywords.php#L39-L50

Added lines #L39 - L50 were not covered by tests

return $keywords;

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

View check run for this annotation

Codecov / codecov/patch

src/Platforms/Keywords/MySQL84Keywords.php#L52

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

namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\SQL\Builder\SelectSQLBuilder;
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()

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

View check run for this annotation

Codecov / codecov/patch

src/Platforms/MySQL84Platform.php#L18

Added line #L18 was not covered by tests
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4510',
'MySQL84Platform::getReservedKeywordsClass() is deprecated,'
. ' use MySQL84Platform::createReservedKeywordsList() instead.',
);

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

View check run for this annotation

Codecov / codecov/patch

src/Platforms/MySQL84Platform.php#L20-L25

Added lines #L20 - L25 were not covered by tests

return Keywords\MySQL84Keywords::class;

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

View check run for this annotation

Codecov / codecov/patch

src/Platforms/MySQL84Platform.php#L27

Added line #L27 was not covered by tests
}

public function createSelectSQLBuilder(): SelectSQLBuilder

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

View check run for this annotation

Codecov / codecov/patch

src/Platforms/MySQL84Platform.php#L30

Added line #L30 was not covered by tests
{
return AbstractPlatform::createSelectSQLBuilder();

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

View check run for this annotation

Codecov / codecov/patch

src/Platforms/MySQL84Platform.php#L32

Added line #L32 was not covered by tests
}
}
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 @@ public function __construct(ConnectionProvider $connectionProvider)
'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 @@ protected function configure()
* 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

0 comments on commit 569e4c5

Please sign in to comment.