From 49f4e1c5e3d32c272b4e0207347a85f672d30587 Mon Sep 17 00:00:00 2001 From: butschster Date: Wed, 25 Aug 2021 16:06:22 +0300 Subject: [PATCH 1/4] Removed support for descending index for MYSQL 5.7 @see https://dev.mysql.com/doc/refman/5.7/en/create-index.html --- src/Driver/MySQL/Schema/MySQLTable.php | 10 ++++++---- tests/Database/Driver/MySQL/IndexesTest.php | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) 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..e155d070 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->isSupported()) { + $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->isSupported()) { + $this->expectExceptionMessageMatches('/column sorting is not supported$/'); } parent::testDropOrderedIndex(); } + + protected function isSupported(): bool + { + if (getenv('MYSQL') === '5.7') { + return false; + } + + return getenv('DB') !== 'mariadb'; + } } From 935fedc2b68a72d1a339c293274427010b0e973d Mon Sep 17 00:00:00 2001 From: Pavel Buchnev Date: Mon, 30 Aug 2021 19:44:09 +0300 Subject: [PATCH 2/4] Update tests/Database/Driver/MySQL/IndexesTest.php Co-authored-by: Aleksei Gagarin --- tests/Database/Driver/MySQL/IndexesTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Database/Driver/MySQL/IndexesTest.php b/tests/Database/Driver/MySQL/IndexesTest.php index e155d070..80590948 100644 --- a/tests/Database/Driver/MySQL/IndexesTest.php +++ b/tests/Database/Driver/MySQL/IndexesTest.php @@ -21,7 +21,7 @@ class IndexesTest extends \Cycle\Database\Tests\IndexesTest public function testCreateOrderedIndex(): void { - if (!$this->isSupported()) { + if (!$this->isOrderedIndexSupported()) { $this->expectExceptionMessageMatches('/column sorting is not supported$/'); } From e81efdc27f241a4e292473fdf84fba0aaa2ebd9d Mon Sep 17 00:00:00 2001 From: Pavel Buchnev Date: Mon, 30 Aug 2021 19:50:54 +0300 Subject: [PATCH 3/4] Update tests/Database/Driver/MySQL/IndexesTest.php Co-authored-by: Aleksei Gagarin --- tests/Database/Driver/MySQL/IndexesTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Database/Driver/MySQL/IndexesTest.php b/tests/Database/Driver/MySQL/IndexesTest.php index 80590948..e8e6f571 100644 --- a/tests/Database/Driver/MySQL/IndexesTest.php +++ b/tests/Database/Driver/MySQL/IndexesTest.php @@ -30,7 +30,7 @@ public function testCreateOrderedIndex(): void public function testDropOrderedIndex(): void { - if (!$this->isSupported()) { + if (!$this->isOrderedIndexSupported()) { $this->expectExceptionMessageMatches('/column sorting is not supported$/'); } From 3da186be0bc4acf74dabe8cabe17097211a11452 Mon Sep 17 00:00:00 2001 From: Pavel Buchnev Date: Mon, 30 Aug 2021 19:51:00 +0300 Subject: [PATCH 4/4] Update tests/Database/Driver/MySQL/IndexesTest.php Co-authored-by: Aleksei Gagarin --- tests/Database/Driver/MySQL/IndexesTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Database/Driver/MySQL/IndexesTest.php b/tests/Database/Driver/MySQL/IndexesTest.php index e8e6f571..0011b146 100644 --- a/tests/Database/Driver/MySQL/IndexesTest.php +++ b/tests/Database/Driver/MySQL/IndexesTest.php @@ -37,7 +37,7 @@ public function testDropOrderedIndex(): void parent::testDropOrderedIndex(); } - protected function isSupported(): bool + protected function isOrderedIndexSupported(): bool { if (getenv('MYSQL') === '5.7') { return false;