Fix testColumnSchema in MariaDB 10.4 or higher. (#20172)

This commit is contained in:
Wilmer Arambula
2024-05-30 04:02:18 -04:00
committed by GitHub
parent 5ebc175768
commit e1268d1f15

View File

@ -146,87 +146,108 @@ SQL;
public function getExpectedColumns() public function getExpectedColumns()
{ {
$version = $this->getConnection()->getSchema()->getServerVersion(); $version = $this->getConnection(false)->getServerVersion();
$columns = array_merge( $columns = array_merge(
parent::getExpectedColumns(), parent::getExpectedColumns(),
[ [
'int_col' => [ 'int_col' => [
'type' => 'integer', 'type' => 'integer',
'dbType' => \version_compare($version, '8.0.17', '>') ? 'int' : 'int(11)', 'dbType' => 'int(11)',
'phpType' => 'integer', 'phpType' => 'integer',
'allowNull' => false, 'allowNull' => false,
'autoIncrement' => false, 'autoIncrement' => false,
'enumValues' => null, 'enumValues' => null,
'size' => \version_compare($version, '8.0.17', '>') ? null : 11, 'size' => 11,
'precision' => \version_compare($version, '8.0.17', '>') ? null : 11, 'precision' => 11,
'scale' => null, 'scale' => null,
'defaultValue' => null, 'defaultValue' => null,
], ],
'int_col2' => [ 'int_col2' => [
'type' => 'integer', 'type' => 'integer',
'dbType' => \version_compare($version, '8.0.17', '>') ? 'int' : 'int(11)', 'dbType' => 'int(11)',
'phpType' => 'integer', 'phpType' => 'integer',
'allowNull' => true, 'allowNull' => true,
'autoIncrement' => false, 'autoIncrement' => false,
'enumValues' => null, 'enumValues' => null,
'size' => \version_compare($version, '8.0.17', '>') ? null : 11, 'size' => 11,
'precision' => \version_compare($version, '8.0.17', '>') ? null : 11, 'precision' => 11,
'scale' => null, 'scale' => null,
'defaultValue' => 1, 'defaultValue' => 1,
], ],
'int_col3' => [ 'int_col3' => [
'type' => 'integer', 'type' => 'integer',
'dbType' => \version_compare($version, '8.0.17', '>') ? 'int unsigned' : 'int(11) unsigned', 'dbType' => 'int(11) unsigned',
'phpType' => 'integer', 'phpType' => 'integer',
'allowNull' => true, 'allowNull' => true,
'autoIncrement' => false, 'autoIncrement' => false,
'enumValues' => null, 'enumValues' => null,
'size' => \version_compare($version, '8.0.17', '>') ? null : 11, 'size' => 11,
'precision' => \version_compare($version, '8.0.17', '>') ? null : 11, 'precision' => 11,
'scale' => null, 'scale' => null,
'defaultValue' => 1, 'defaultValue' => 1,
], ],
'tinyint_col' => [ 'tinyint_col' => [
'type' => 'tinyint', 'type' => 'tinyint',
'dbType' => \version_compare($version, '8.0.17', '>') ? 'tinyint' : 'tinyint(3)', 'dbType' => 'tinyint(3)',
'phpType' => 'integer', 'phpType' => 'integer',
'allowNull' => true, 'allowNull' => true,
'autoIncrement' => false, 'autoIncrement' => false,
'enumValues' => null, 'enumValues' => null,
'size' => \version_compare($version, '8.0.17', '>') ? null : 3, 'size' => 3,
'precision' => \version_compare($version, '8.0.17', '>') ? null : 3, 'precision' => 3,
'scale' => null, 'scale' => null,
'defaultValue' => 1, 'defaultValue' => 1,
], ],
'smallint_col' => [ 'smallint_col' => [
'type' => 'smallint', 'type' => 'smallint',
'dbType' => \version_compare($version, '8.0.17', '>') ? 'smallint' : 'smallint(1)', 'dbType' => 'smallint(1)',
'phpType' => 'integer', 'phpType' => 'integer',
'allowNull' => true, 'allowNull' => true,
'autoIncrement' => false, 'autoIncrement' => false,
'enumValues' => null, 'enumValues' => null,
'size' => \version_compare($version, '8.0.17', '>') ? null : 1, 'size' => 1,
'precision' => \version_compare($version, '8.0.17', '>') ? null : 1, 'precision' => 1,
'scale' => null, 'scale' => null,
'defaultValue' => 1, 'defaultValue' => 1,
], ],
'bigint_col' => [ 'bigint_col' => [
'type' => 'bigint', 'type' => 'bigint',
'dbType' => \version_compare($version, '8.0.17', '>') ? 'bigint unsigned' : 'bigint(20) unsigned', 'dbType' => 'bigint(20) unsigned',
'phpType' => 'string', 'phpType' => 'string',
'allowNull' => true, 'allowNull' => true,
'autoIncrement' => false, 'autoIncrement' => false,
'enumValues' => null, 'enumValues' => null,
'size' => \version_compare($version, '8.0.17', '>') ? null : 20, 'size' => 20,
'precision' => \version_compare($version, '8.0.17', '>') ? null : 20, 'precision' => 20,
'scale' => null, 'scale' => null,
'defaultValue' => null, 'defaultValue' => null,
], ],
] ]
); );
if (version_compare($version, '5.7', '<')) { if (\version_compare($version, '8.0.17', '>') && \stripos($version, 'MariaDb') === false) {
$columns['int_col']['dbType'] = 'int';
$columns['int_col']['size'] = null;
$columns['int_col']['precision'] = null;
$columns['int_col2']['dbType'] = 'int';
$columns['int_col2']['size'] = null;
$columns['int_col2']['precision'] = null;
$columns['int_col3']['dbType'] = 'int unsigned';
$columns['int_col3']['size'] = null;
$columns['int_col3']['precision'] = null;
$columns['tinyint_col']['dbType'] = 'tinyint';
$columns['tinyint_col']['size'] = null;
$columns['tinyint_col']['precision'] = null;
$columns['smallint_col']['dbType'] = 'smallint';
$columns['smallint_col']['size'] = null;
$columns['smallint_col']['precision'] = null;
$columns['bigint_col']['dbType'] = 'bigint unsigned';
$columns['bigint_col']['size'] = null;
$columns['bigint_col']['precision'] = null;
}
if (version_compare($version, '5.7', '<') && \stripos($version, 'MariaDb') === false) {
$columns['int_col3']['phpType'] = 'string'; $columns['int_col3']['phpType'] = 'string';
$columns['json_col']['type'] = 'text'; $columns['json_col']['type'] = 'text';
$columns['json_col']['dbType'] = 'longtext'; $columns['json_col']['dbType'] = 'longtext';