Skip to content

Commit

Permalink
Don't test the max_length attribute on MySQL >= 8.0.17
Browse files Browse the repository at this point in the history
As of MySQL 8.0.17, the display width attribute for integer data types
is deprecated and is not reported back anymore.

https://dev.mysql.com/doc/refman/8.0/en/numeric-type-attributes.html
  • Loading branch information
jeromegamez committed May 22, 2021
1 parent 1a8b05e commit e0c8b86
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tests/system/Database/Live/ForgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,16 @@ public function testCreateTableWithArrayFieldConstraints()
public function testCreateTableWithNullableFieldsGivesNullDataType(): void
{
$this->forge->addField([
'id' => ['type' => 'INT', 'constraint' => 11, 'auto_increment' => true],
'name' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'id' => [
'type' => 'INT',
'constraint' => 11,
'auto_increment' => true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => 255,
'null' => true,
],
]);

$createTable = $this->getPrivateMethodInvoker($this->forge, '_createTable');
Expand Down Expand Up @@ -620,7 +628,13 @@ public function testAddFields()
$this->assertEquals($fieldsData[0]->type, 'int');
$this->assertEquals($fieldsData[1]->type, 'varchar');

$this->assertEquals($fieldsData[0]->max_length, 11);
if (version_compare($this->db->getVersion(), '8.0.17', '<'))
{
// As of MySQL 8.0.17, the display width attribute for integer data types
// is deprecated and is not reported back anymore.
// @see https://dev.mysql.com/doc/refman/8.0/en/numeric-type-attributes.html
$this->assertEquals($fieldsData[0]->max_length, 11);
}

$this->assertNull($fieldsData[0]->default);
$this->assertNull($fieldsData[1]->default);
Expand Down

0 comments on commit e0c8b86

Please sign in to comment.