Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mlocati committed Jun 9, 2018
1 parent 2edb7da commit a2aa359
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Database/Driver/PDOMySqlConcrete5/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Concrete\Core\Database\Driver\PDOMySqlConcrete5;

use Concrete\Core\Database\Connection\PDOConnection;
use Concrete\Core\Database\Platforms\MySQL80Platform;

/**
* PDO MySql driver.
Expand All @@ -22,6 +23,24 @@ public function connect(array $params, $username = null, $password = null, array
return $conn;
}

/**
* {@inheritdoc}
*
* @see \Doctrine\DBAL\Driver\AbstractMySQLDriver::createDatabasePlatformForVersion()
*/
public function createDatabasePlatformForVersion($version)
{
if (false === stripos($version, 'mariadb')) {
if (preg_match('/^(\d+)/', $version, $match)) {
if ((int) $match[1] >= 8) {
return new MySQL80Platform();
}
}
}

return parent::createDatabasePlatformForVersion($version);
}

/**
* Constructs the MySql PDO DSN.
*
Expand Down
64 changes: 64 additions & 0 deletions src/Database/Platforms/Keywords/MySQL80Keywords.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace Concrete\Core\Database\Platforms\Keywords;

use Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords;

/**
* Backport of https://github.com/doctrine/dbal/pull/3128.
*/
class MySQL80Keywords extends MySQL57Keywords
{
/**
* {@inheritdoc}
*
* @see \Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords::getName()
*/
public function getName()
{
return 'MySQL80';
}

/**
* {@inheritdoc}
*
* @see \Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords::getKeywords()
*/
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;
}
}
22 changes: 22 additions & 0 deletions src/Database/Platforms/MySQL80Platform.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Concrete\Core\Database\Platforms;

use Concrete\Core\Database\Platforms\Keywords\MySQL80Keywords;
use Doctrine\DBAL\Platforms\MySQL57Platform;

/**
* Backport of https://github.com/doctrine/dbal/pull/3128.
*/
class MySQL80Platform extends MySQL57Platform
{
/**
* {@inheritdoc}
*
* @see \Doctrine\DBAL\Platforms\MySQL57Platform::getReservedKeywordsClass()
*/
protected function getReservedKeywordsClass()
{
return MySQL80Keywords::class;
}
}

0 comments on commit a2aa359

Please sign in to comment.