Skip to content
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
10 changes: 6 additions & 4 deletions src/Driver/MySQL/Schema/MySQLTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ protected function initSchema(State $state): void
protected function isIndexColumnSortingSupported(): bool
{
if (!$this->version) {
$this->version = $this->driver->query('SELECT VERSION() AS version')
->fetch()['version'];
$this->version = $this->driver->query('SELECT VERSION() AS version')->fetch()['version'];
}

$isMariaDB = strpos($this->version, 'MariaDB') !== false;
return !$isMariaDB;
if (strpos($this->version, 'MariaDB') !== false) {
return false;
}

return version_compare($this->version, '8.0', '>=');
}

/**
Expand Down
17 changes: 13 additions & 4 deletions tests/Database/Driver/MySQL/IndexesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,28 @@ class IndexesTest extends \Cycle\Database\Tests\IndexesTest

public function testCreateOrderedIndex(): void
{
if (getenv('DB') === 'mariadb') {
$this->expectExceptionMessageRegExp('/column sorting is not supported$/');
if (!$this->isOrderedIndexSupported()) {
$this->expectExceptionMessageMatches('/column sorting is not supported$/');
}

parent::testCreateOrderedIndex();
}

public function testDropOrderedIndex(): void
{
if (getenv('DB') === 'mariadb') {
$this->expectExceptionMessageRegExp('/column sorting is not supported$/');
if (!$this->isOrderedIndexSupported()) {
$this->expectExceptionMessageMatches('/column sorting is not supported$/');
}

parent::testDropOrderedIndex();
}

protected function isOrderedIndexSupported(): bool
{
if (getenv('MYSQL') === '5.7') {
return false;
}

return getenv('DB') !== 'mariadb';
}
}