diff --git a/src/Driver/MySQL/Schema/MySQLTable.php b/src/Driver/MySQL/Schema/MySQLTable.php index 99262b8e..3ec4bfe2 100644 --- a/src/Driver/MySQL/Schema/MySQLTable.php +++ b/src/Driver/MySQL/Schema/MySQLTable.php @@ -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', '>='); } /** diff --git a/tests/Database/Driver/MySQL/IndexesTest.php b/tests/Database/Driver/MySQL/IndexesTest.php index 1306559e..0011b146 100644 --- a/tests/Database/Driver/MySQL/IndexesTest.php +++ b/tests/Database/Driver/MySQL/IndexesTest.php @@ -21,8 +21,8 @@ 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(); @@ -30,10 +30,19 @@ public function testCreateOrderedIndex(): void 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'; + } }