Skip to content

Commit

Permalink
Revert "fix: don't use int width for mysql > 8.0.17 silverstripe#9453"
Browse files Browse the repository at this point in the history
  • Loading branch information
gurucomkz committed Oct 28, 2020
1 parent f4f5138 commit cfc1941
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions src/ORM/Connect/MySQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,6 @@ public function renameField($tableName, $oldName, $newName)

protected static $_cache_collation_info = [];

public function shouldUseIntegerWidth()
{
// MySQL 8.0.17 stopped reporting the width attribute for integers
// https://github.com/silverstripe/silverstripe-framework/issues/9453
$v = $this->database->getVersion();
return version_compare($v,'8.0.17','<');
}

public function fieldList($table)
{
$fields = $this->query("SHOW FULL FIELDS IN \"$table\"");
Expand Down Expand Up @@ -413,8 +405,7 @@ public function boolean($values)
//'default'=>$this->default);
//DB::requireField($this->tableName, $this->name, "tinyint(1) unsigned not null default
//'{$this->defaultVal}'");
$width = $this->shouldUseIntegerWidth() ? '(1)' : '';
return 'tinyint'.$width.' unsigned not null' . $this->defaultClause($values);
return 'tinyint(1) unsigned not null' . $this->defaultClause($values);
}

/**
Expand Down Expand Up @@ -527,8 +518,7 @@ public function int($values)
//For reference, this is what typically gets passed to this function:
//$parts=Array('datatype'=>'int', 'precision'=>11, 'null'=>'not null', 'default'=>(int)$this->default);
//DB::requireField($this->tableName, $this->name, "int(11) not null default '{$this->defaultVal}'");
$width = $this->shouldUseIntegerWidth() ? '(11)' : '';
return "int$width not null" . $this->defaultClause($values);
return "int(11) not null" . $this->defaultClause($values);
}

/**
Expand All @@ -544,8 +534,8 @@ public function bigint($values)
// 'arrayValue'=>$this->arrayValue);
//$values=Array('type'=>'bigint', 'parts'=>$parts);
//DB::requireField($this->tableName, $this->name, $values);
$width = $this->shouldUseIntegerWidth() ? '(20)' : '';
return 'bigint'.$width.' not null' . $this->defaultClause($values);

return 'bigint(20) not null' . $this->defaultClause($values);
}

/**
Expand Down Expand Up @@ -626,8 +616,7 @@ public function year($values)

public function IdColumn($asDbValue = false, $hasAutoIncPK = true)
{
$width = $this->shouldUseIntegerWidth() ? '(11)' : '';
return 'int'.$width.' not null auto_increment';
return 'int(11) not null auto_increment';
}

/**
Expand Down

0 comments on commit cfc1941

Please sign in to comment.