Skip to content

Commit 9c5cdde

Browse files
committed
test: fix assertions on MySQL 5.7
1 parent e029c30 commit 9c5cdde

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tests/system/Database/Live/MySQLi/GetFieldDataTest.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ protected function createForge(): void
3030
$this->forge = Database::forge($this->db);
3131
}
3232

33+
/**
34+
* As of MySQL 8.0.17, the display width attribute for integer data types
35+
* is deprecated and is not reported back anymore.
36+
*
37+
* @see https://dev.mysql.com/doc/refman/8.0/en/numeric-type-attributes.html
38+
*/
39+
private function isOldMySQL(): bool
40+
{
41+
return ! (
42+
version_compare($this->db->getVersion(), '8.0.17', '>=')
43+
&& strpos($this->db->getVersion(), 'MariaDB') === false
44+
);
45+
}
46+
3347
public function testGetFieldData(): void
3448
{
3549
$fields = $this->db->getFieldData('test1');
@@ -39,7 +53,7 @@ public function testGetFieldData(): void
3953
(object) [
4054
'name' => 'id',
4155
'type' => 'int',
42-
'max_length' => null,
56+
'max_length' => $this->isOldMySQL() ? 11 : null,
4357
'default' => null, // The default value is not defined.
4458
'primary_key' => 1,
4559
'nullable' => false,
@@ -63,7 +77,7 @@ public function testGetFieldData(): void
6377
(object) [
6478
'name' => 'int_default_0',
6579
'type' => 'int',
66-
'max_length' => null,
80+
'max_length' => $this->isOldMySQL() ? 11 : null,
6781
'default' => '0', // int 0
6882
'primary_key' => 0,
6983
'nullable' => false,

0 commit comments

Comments
 (0)