From 02f2f7c91cb31b1dcb5660a4a78ae3448f012bc1 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Wed, 29 May 2024 08:21:36 -0400 Subject: [PATCH] Fix `testColumnSchema` in `MariaDB` 10.4 or higher. --- tests/framework/db/mysql/SchemaTest.php | 61 +++++++++++++++++-------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/tests/framework/db/mysql/SchemaTest.php b/tests/framework/db/mysql/SchemaTest.php index ba98f45e385..aa2634ff307 100644 --- a/tests/framework/db/mysql/SchemaTest.php +++ b/tests/framework/db/mysql/SchemaTest.php @@ -146,87 +146,108 @@ public function testAlternativeDisplayOfDefaultCurrentTimestampAsNullInMariaDB() public function getExpectedColumns() { - $version = $this->getConnection()->getSchema()->getServerVersion(); + $version = $this->getConnection(false)->getServerVersion(); $columns = array_merge( parent::getExpectedColumns(), [ 'int_col' => [ 'type' => 'integer', - 'dbType' => \version_compare($version, '8.0.17', '>') ? 'int' : 'int(11)', + 'dbType' => 'int(11)', 'phpType' => 'integer', 'allowNull' => false, 'autoIncrement' => false, 'enumValues' => null, - 'size' => \version_compare($version, '8.0.17', '>') ? null : 11, - 'precision' => \version_compare($version, '8.0.17', '>') ? null : 11, + 'size' => 11, + 'precision' => 11, 'scale' => null, 'defaultValue' => null, ], 'int_col2' => [ 'type' => 'integer', - 'dbType' => \version_compare($version, '8.0.17', '>') ? 'int' : 'int(11)', + 'dbType' => 'int(11)', 'phpType' => 'integer', 'allowNull' => true, 'autoIncrement' => false, 'enumValues' => null, - 'size' => \version_compare($version, '8.0.17', '>') ? null : 11, - 'precision' => \version_compare($version, '8.0.17', '>') ? null : 11, + 'size' => 11, + 'precision' => 11, 'scale' => null, 'defaultValue' => 1, ], 'int_col3' => [ 'type' => 'integer', - 'dbType' => \version_compare($version, '8.0.17', '>') ? 'int unsigned' : 'int(11) unsigned', + 'dbType' => 'int(11) unsigned', 'phpType' => 'integer', 'allowNull' => true, 'autoIncrement' => false, 'enumValues' => null, - 'size' => \version_compare($version, '8.0.17', '>') ? null : 11, - 'precision' => \version_compare($version, '8.0.17', '>') ? null : 11, + 'size' => 11, + 'precision' => 11, 'scale' => null, 'defaultValue' => 1, ], 'tinyint_col' => [ 'type' => 'tinyint', - 'dbType' => \version_compare($version, '8.0.17', '>') ? 'tinyint' : 'tinyint(3)', + 'dbType' => 'tinyint(3)', 'phpType' => 'integer', 'allowNull' => true, 'autoIncrement' => false, 'enumValues' => null, - 'size' => \version_compare($version, '8.0.17', '>') ? null : 3, - 'precision' => \version_compare($version, '8.0.17', '>') ? null : 3, + 'size' => 3, + 'precision' => 3, 'scale' => null, 'defaultValue' => 1, ], 'smallint_col' => [ 'type' => 'smallint', - 'dbType' => \version_compare($version, '8.0.17', '>') ? 'smallint' : 'smallint(1)', + 'dbType' => 'smallint(1)', 'phpType' => 'integer', 'allowNull' => true, 'autoIncrement' => false, 'enumValues' => null, - 'size' => \version_compare($version, '8.0.17', '>') ? null : 1, - 'precision' => \version_compare($version, '8.0.17', '>') ? null : 1, + 'size' => 1, + 'precision' => 1, 'scale' => null, 'defaultValue' => 1, ], 'bigint_col' => [ 'type' => 'bigint', - 'dbType' => \version_compare($version, '8.0.17', '>') ? 'bigint unsigned' : 'bigint(20) unsigned', + 'dbType' => 'bigint(20) unsigned', 'phpType' => 'string', 'allowNull' => true, 'autoIncrement' => false, 'enumValues' => null, - 'size' => \version_compare($version, '8.0.17', '>') ? null : 20, - 'precision' => \version_compare($version, '8.0.17', '>') ? null : 20, + 'size' => 20, + 'precision' => 20, 'scale' => 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['json_col']['type'] = 'text'; $columns['json_col']['dbType'] = 'longtext';