Add MySQL 8 reserved keywords

parent e4af109a
...@@ -35,6 +35,7 @@ MySQL ...@@ -35,6 +35,7 @@ MySQL
- ``MySqlPlatform`` for version 5.0 and above. - ``MySqlPlatform`` for version 5.0 and above.
- ``MySQL57Platform`` for version 5.7 (5.7.9 GA) and above. - ``MySQL57Platform`` for version 5.7 (5.7.9 GA) and above.
- ``MySQL80Platform`` for version 8.0 (8.0 GA) and above.
Oracle Oracle
^^^^^^ ^^^^^^
......
...@@ -24,6 +24,7 @@ use Doctrine\DBAL\Driver; ...@@ -24,6 +24,7 @@ use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\MariaDb1027Platform; use Doctrine\DBAL\Platforms\MariaDb1027Platform;
use Doctrine\DBAL\Platforms\MySQL57Platform; use Doctrine\DBAL\Platforms\MySQL57Platform;
use Doctrine\DBAL\Platforms\MySQL80Platform;
use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\MySqlSchemaManager; use Doctrine\DBAL\Schema\MySqlSchemaManager;
use Doctrine\DBAL\VersionAwarePlatformDriver; use Doctrine\DBAL\VersionAwarePlatformDriver;
...@@ -137,9 +138,15 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, ...@@ -137,9 +138,15 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
return new MariaDb1027Platform(); return new MariaDb1027Platform();
} }
if ( ! $mariadb && version_compare($this->getOracleMysqlVersionNumber($version), '5.7.9', '>=')) { if (! $mariadb) {
$oracleMysqlVersion = $this->getOracleMysqlVersionNumber($version);
if (version_compare($oracleMysqlVersion, '8', '>=')) {
return new MySQL80Platform();
}
if (version_compare($oracleMysqlVersion, '5.7.9', '>=')) {
return new MySQL57Platform(); return new MySQL57Platform();
} }
}
return $this->getDatabasePlatform(); return $this->getDatabasePlatform();
} }
......
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Platforms\Keywords;
use function array_merge;
/**
* MySQL 8.0 reserved keywords list.
*
* @link www.doctrine-project.org
*/
class MySQL80Keywords extends MySQL57Keywords
{
/**
* {@inheritdoc}
*/
public function getName()
{
return 'MySQL80';
}
/**
* {@inheritdoc}
*
* @link https://dev.mysql.com/doc/refman/8.0/en/keywords.html
*/
protected function getKeywords()
{
$keywords = parent::getKeywords();
$keywords = array_merge($keywords, [
'ADMIN',
'CUBE',
'CUME_DIST',
'DENSE_RANK',
'EMPTY',
'EXCEPT',
'FIRST_VALUE',
'FUNCTION',
'GROUPING',
'GROUPS',
'JSON_TABLE',
'LAG',
'LAST_VALUE',
'LEAD',
'NTH_VALUE',
'NTILE',
'OF',
'OVER',
'PERCENT_RANK',
'PERSIST',
'PERSIST_ONLY',
'RANK',
'RECURSIVE',
'ROW',
'ROWS',
'ROW_NUMBER',
'SYSTEM',
'WINDOW',
]);
return $keywords;
}
}
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Platforms;
/**
* Provides the behavior, features and SQL dialect of the MySQL 8.0 (8.0 GA) database platform.
*
* @link www.doctrine-project.org
*/
class MySQL80Platform extends MySQL57Platform
{
/**
* {@inheritdoc}
*/
protected function getReservedKeywordsClass()
{
return Keywords\MySQL80Keywords::class;
}
}
...@@ -36,6 +36,7 @@ class ReservedWordsCommand extends Command ...@@ -36,6 +36,7 @@ class ReservedWordsCommand extends Command
private $keywordListClasses = [ private $keywordListClasses = [
'mysql' => 'Doctrine\DBAL\Platforms\Keywords\MySQLKeywords', 'mysql' => 'Doctrine\DBAL\Platforms\Keywords\MySQLKeywords',
'mysql57' => 'Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords', 'mysql57' => 'Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords',
'mysql80' => 'Doctrine\DBAL\Platforms\Keywords\MySQL80Keywords',
'sqlserver' => 'Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords', 'sqlserver' => 'Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords',
'sqlserver2005' => 'Doctrine\DBAL\Platforms\Keywords\SQLServer2005Keywords', 'sqlserver2005' => 'Doctrine\DBAL\Platforms\Keywords\SQLServer2005Keywords',
'sqlserver2008' => 'Doctrine\DBAL\Platforms\Keywords\SQLServer2008Keywords', 'sqlserver2008' => 'Doctrine\DBAL\Platforms\Keywords\SQLServer2008Keywords',
...@@ -96,6 +97,7 @@ The following keyword lists are currently shipped with Doctrine: ...@@ -96,6 +97,7 @@ The following keyword lists are currently shipped with Doctrine:
* mysql * mysql
* mysql57 * mysql57
* mysql80
* pgsql * pgsql
* pgsql92 * pgsql92
* sqlite * sqlite
...@@ -126,6 +128,7 @@ EOT ...@@ -126,6 +128,7 @@ EOT
$keywordLists = [ $keywordLists = [
'mysql', 'mysql',
'mysql57', 'mysql57',
'mysql80',
'pgsql', 'pgsql',
'pgsql92', 'pgsql92',
'sqlite', 'sqlite',
......
...@@ -5,6 +5,7 @@ namespace Doctrine\Tests\DBAL\Driver; ...@@ -5,6 +5,7 @@ namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\MariaDb1027Platform; use Doctrine\DBAL\Platforms\MariaDb1027Platform;
use Doctrine\DBAL\Platforms\MySQL57Platform; use Doctrine\DBAL\Platforms\MySQL57Platform;
use Doctrine\DBAL\Platforms\MySQL80Platform;
use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\MySqlSchemaManager; use Doctrine\DBAL\Schema\MySqlSchemaManager;
...@@ -63,6 +64,9 @@ class AbstractMySQLDriverTest extends AbstractDriverTest ...@@ -63,6 +64,9 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
['5.7.8', MySqlPlatform::class], ['5.7.8', MySqlPlatform::class],
['5.7.9', MySQL57Platform::class], ['5.7.9', MySQL57Platform::class],
['5.7.10', MySQL57Platform::class], ['5.7.10', MySQL57Platform::class],
['8', MySQL80Platform::class],
['8.0', MySQL80Platform::class],
['8.0.11', MySQL80Platform::class],
['6', MySQL57Platform::class], ['6', MySQL57Platform::class],
['10.0.15-MariaDB-1~wheezy', MySqlPlatform::class], ['10.0.15-MariaDB-1~wheezy', MySqlPlatform::class],
['5.5.5-10.1.25-MariaDB', MySqlPlatform::class], ['5.5.5-10.1.25-MariaDB', MySqlPlatform::class],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment