Commit e98d2416 authored by Marco Pivetta's avatar Marco Pivetta Committed by GitHub

Merge pull request #2653 from deeky666/fix-mysql57-platform

Merge MySQL 5.7.9 (GA) semantics into MySQL57Platform
parents 3632e03c f4381c58
...@@ -34,7 +34,7 @@ MySQL ...@@ -34,7 +34,7 @@ MySQL
^^^^^ ^^^^^
- ``MySqlPlatform`` for version 5.0 and above. - ``MySqlPlatform`` for version 5.0 and above.
- ``MySQL57Platform`` for version 5.7 and above. - ``MySQL57Platform`` for version 5.7 (5.7.9 GA) and above.
Oracle Oracle
^^^^^^ ^^^^^^
......
...@@ -138,10 +138,15 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, ...@@ -138,10 +138,15 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
$majorVersion = $versionParts['major']; $majorVersion = $versionParts['major'];
$minorVersion = isset($versionParts['minor']) ? $versionParts['minor'] : 0; $minorVersion = isset($versionParts['minor']) ? $versionParts['minor'] : 0;
$patchVersion = isset($versionParts['patch']) ? $versionParts['patch'] : 0; $patchVersion = isset($versionParts['patch']) ? $versionParts['patch'] : null;
$version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
if (version_compare($version, '5.7', '>=')) { if ('5' === $majorVersion && '7' === $minorVersion && null === $patchVersion) {
$patchVersion = '9';
}
$version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
if (version_compare($version, '5.7.9', '>=')) {
return new MySQL57Platform(); return new MySQL57Platform();
} }
......
...@@ -119,6 +119,7 @@ class MySQL57Keywords extends MySQLKeywords ...@@ -119,6 +119,7 @@ class MySQL57Keywords extends MySQLKeywords
'FOREIGN', 'FOREIGN',
'FROM', 'FROM',
'FULLTEXT', 'FULLTEXT',
'GENERATED',
'GET', 'GET',
'GRANT', 'GRANT',
'GROUP', 'GROUP',
...@@ -183,12 +184,12 @@ class MySQL57Keywords extends MySQLKeywords ...@@ -183,12 +184,12 @@ class MySQL57Keywords extends MySQLKeywords
'MODIFIES', 'MODIFIES',
'NATURAL', 'NATURAL',
'NO_WRITE_TO_BINLOG', 'NO_WRITE_TO_BINLOG',
'NONBLOCKING',
'NOT', 'NOT',
'NULL', 'NULL',
'NUMERIC', 'NUMERIC',
'ON', 'ON',
'OPTIMIZE', 'OPTIMIZE',
'OPTIMIZER_COSTS',
'OPTION', 'OPTION',
'OPTIONALLY', 'OPTIONALLY',
'OR', 'OR',
...@@ -240,6 +241,7 @@ class MySQL57Keywords extends MySQLKeywords ...@@ -240,6 +241,7 @@ class MySQL57Keywords extends MySQLKeywords
'SQLWARNING', 'SQLWARNING',
'SSL', 'SSL',
'STARTING', 'STARTING',
'STORED',
'STRAIGHT_JOIN', 'STRAIGHT_JOIN',
'TABLE', 'TABLE',
'TERMINATED', 'TERMINATED',
...@@ -268,6 +270,7 @@ class MySQL57Keywords extends MySQLKeywords ...@@ -268,6 +270,7 @@ class MySQL57Keywords extends MySQLKeywords
'VARCHAR', 'VARCHAR',
'VARCHARACTER', 'VARCHARACTER',
'VARYING', 'VARYING',
'VIRTUAL',
'WHEN', 'WHEN',
'WHERE', 'WHERE',
'WHILE', 'WHILE',
......
...@@ -23,14 +23,31 @@ use Doctrine\DBAL\Schema\Index; ...@@ -23,14 +23,31 @@ use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Schema\TableDiff;
/** /**
* Provides the behavior, features and SQL dialect of the MySQL 5.7 database platform. * Provides the behavior, features and SQL dialect of the MySQL 5.7 (5.7.9 GA) database platform.
* *
* @author İsmail BASKIN <ismailbaskin1@gmail.com>
* @author Steve Müller <st.mueller@dzh-online.de> * @author Steve Müller <st.mueller@dzh-online.de>
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.5 * @since 2.5
*/ */
class MySQL57Platform extends MySqlPlatform class MySQL57Platform extends MySqlPlatform
{ {
/**
* {@inheritdoc}
*/
public function hasNativeJsonType()
{
return true;
}
/**
* {@inheritdoc}
*/
public function getJsonTypeDeclarationSQL(array $field)
{
return 'JSON';
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -64,4 +81,14 @@ class MySQL57Platform extends MySqlPlatform ...@@ -64,4 +81,14 @@ class MySQL57Platform extends MySqlPlatform
{ {
return 'Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords'; return 'Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords';
} }
/**
* {@inheritdoc}
*/
protected function initializeDoctrineTypeMappings()
{
parent::initializeDoctrineTypeMappings();
$this->doctrineTypeMapping['json'] = 'json_array';
}
} }
...@@ -57,8 +57,10 @@ class AbstractMySQLDriverTest extends AbstractDriverTest ...@@ -57,8 +57,10 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
return array( return array(
array('5.6.9', 'Doctrine\DBAL\Platforms\MySqlPlatform'), array('5.6.9', 'Doctrine\DBAL\Platforms\MySqlPlatform'),
array('5.7', 'Doctrine\DBAL\Platforms\MySQL57Platform'), array('5.7', 'Doctrine\DBAL\Platforms\MySQL57Platform'),
array('5.7.0', 'Doctrine\DBAL\Platforms\MySQL57Platform'), array('5.7.0', 'Doctrine\DBAL\Platforms\MySqlPlatform'),
array('5.7.1', 'Doctrine\DBAL\Platforms\MySQL57Platform'), array('5.7.8', 'Doctrine\DBAL\Platforms\MySqlPlatform'),
array('5.7.9', 'Doctrine\DBAL\Platforms\MySQL57Platform'),
array('5.7.10', 'Doctrine\DBAL\Platforms\MySQL57Platform'),
array('6', 'Doctrine\DBAL\Platforms\MySQL57Platform'), array('6', 'Doctrine\DBAL\Platforms\MySQL57Platform'),
array('10.0.15-MariaDB-1~wheezy', 'Doctrine\DBAL\Platforms\MySqlPlatform'), array('10.0.15-MariaDB-1~wheezy', 'Doctrine\DBAL\Platforms\MySqlPlatform'),
array('10.1.2a-MariaDB-a1~lenny-log', 'Doctrine\DBAL\Platforms\MySqlPlatform'), array('10.1.2a-MariaDB-a1~lenny-log', 'Doctrine\DBAL\Platforms\MySqlPlatform'),
......
...@@ -14,6 +14,22 @@ class MySQL57PlatformTest extends AbstractMySQLPlatformTestCase ...@@ -14,6 +14,22 @@ class MySQL57PlatformTest extends AbstractMySQLPlatformTestCase
return new MySQL57Platform(); return new MySQL57Platform();
} }
public function testHasNativeJsonType()
{
$this->assertTrue($this->_platform->hasNativeJsonType());
}
public function testReturnsJsonTypeDeclarationSQL()
{
$this->assertSame('JSON', $this->_platform->getJsonTypeDeclarationSQL(array()));
}
public function testInitializesJsonTypeMapping()
{
$this->assertTrue($this->_platform->hasDoctrineTypeMappingFor('json'));
$this->assertSame('json_array', $this->_platform->getDoctrineTypeMapping('json'));
}
/** /**
* @group DBAL-234 * @group DBAL-234
*/ */
......
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