mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #1 from gurucomkz/patch-9453-mysql8-ints
fix: don't use int width for mysql > 8.0.17 #9453
This commit is contained in:
commit
f4f5138c33
@ -241,6 +241,14 @@ class MySQLSchemaManager extends DBSchemaManager
|
|||||||
|
|
||||||
protected static $_cache_collation_info = [];
|
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)
|
public function fieldList($table)
|
||||||
{
|
{
|
||||||
$fields = $this->query("SHOW FULL FIELDS IN \"$table\"");
|
$fields = $this->query("SHOW FULL FIELDS IN \"$table\"");
|
||||||
@ -405,7 +413,8 @@ class MySQLSchemaManager extends DBSchemaManager
|
|||||||
//'default'=>$this->default);
|
//'default'=>$this->default);
|
||||||
//DB::requireField($this->tableName, $this->name, "tinyint(1) unsigned not null default
|
//DB::requireField($this->tableName, $this->name, "tinyint(1) unsigned not null default
|
||||||
//'{$this->defaultVal}'");
|
//'{$this->defaultVal}'");
|
||||||
return 'tinyint(1) unsigned not null' . $this->defaultClause($values);
|
$width = $this->shouldUseIntegerWidth() ? '(1)' : '';
|
||||||
|
return 'tinyint'.$width.' unsigned not null' . $this->defaultClause($values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -518,7 +527,8 @@ class MySQLSchemaManager extends DBSchemaManager
|
|||||||
//For reference, this is what typically gets passed to this function:
|
//For reference, this is what typically gets passed to this function:
|
||||||
//$parts=Array('datatype'=>'int', 'precision'=>11, 'null'=>'not null', 'default'=>(int)$this->default);
|
//$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}'");
|
//DB::requireField($this->tableName, $this->name, "int(11) not null default '{$this->defaultVal}'");
|
||||||
return "int(11) not null" . $this->defaultClause($values);
|
$width = $this->shouldUseIntegerWidth() ? '(11)' : '';
|
||||||
|
return "int$width not null" . $this->defaultClause($values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -534,8 +544,8 @@ class MySQLSchemaManager extends DBSchemaManager
|
|||||||
// 'arrayValue'=>$this->arrayValue);
|
// 'arrayValue'=>$this->arrayValue);
|
||||||
//$values=Array('type'=>'bigint', 'parts'=>$parts);
|
//$values=Array('type'=>'bigint', 'parts'=>$parts);
|
||||||
//DB::requireField($this->tableName, $this->name, $values);
|
//DB::requireField($this->tableName, $this->name, $values);
|
||||||
|
$width = $this->shouldUseIntegerWidth() ? '(20)' : '';
|
||||||
return 'bigint(20) not null' . $this->defaultClause($values);
|
return 'bigint'.$width.' not null' . $this->defaultClause($values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -616,7 +626,8 @@ class MySQLSchemaManager extends DBSchemaManager
|
|||||||
|
|
||||||
public function IdColumn($asDbValue = false, $hasAutoIncPK = true)
|
public function IdColumn($asDbValue = false, $hasAutoIncPK = true)
|
||||||
{
|
{
|
||||||
return 'int(11) not null auto_increment';
|
$width = $this->shouldUseIntegerWidth() ? '(11)' : '';
|
||||||
|
return 'int'.$width.' not null auto_increment';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user