From ce35719f17abd8600af84853b114e1190d0e812f Mon Sep 17 00:00:00 2001 From: Wilmer Arambula <42547589+terabytesoftw@users.noreply.github.com> Date: Thu, 10 Sep 2020 14:36:04 -0300 Subject: [PATCH] Fix #18040, fix #15265, fix #18232 database issues (#18225) - Bug #18040: Display width specification for integer data types was deprecated in MySQL 8.0.19 - Bug #15265: PostgreSQL > 10.0 is not pass tests with default value of timestamp CURRENT_TIMESTAMP - Bug #18232: Fail tests pgsql v-10.14, v-11.9, v-12-latest --- CHANGELOG.md | 3 +++ db/pgsql/Schema.php | 13 ++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3984eba57..ed63efbbf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ Yii Framework 2 Change Log - Bug #18239: Fix support of no-extension files for `FileValidator::validateExtension()` (darkdef) - Bug #18229: Add flag for recognize SyBase databases on uses pdo_dblib (darkdef) - Bug #13973: Correct alterColumn for MSSQL & drop constraints before drop column (darkdef) +- Bug #18040: Display width specification for integer data types was deprecated in MySQL 8.0.19 (terabytesoftw) +- Bug #15265: PostgreSQL > 10.0 is not pass tests with default value of timestamp CURRENT_TIMESTAMP (terabytesoftw) +- Bug #18232: Fail tests pgsql v-10.14, v-11.9, v-12-latest (terabytesoftw) 2.0.37 August 07, 2020 diff --git a/db/pgsql/Schema.php b/db/pgsql/Schema.php index 938cff6a34..75793d16d2 100644 --- a/db/pgsql/Schema.php +++ b/db/pgsql/Schema.php @@ -548,14 +548,21 @@ protected function findColumns($table) } $column->defaultValue = null; } elseif ($column->defaultValue) { - if ($column->type === 'timestamp' && $column->defaultValue === 'now()') { + if ( + in_array($column->type, [self::TYPE_TIMESTAMP, self::TYPE_DATE, self::TYPE_TIME], true) && + in_array( + strtoupper($column->defaultValue), + ['NOW()', 'CURRENT_TIMESTAMP', 'CURRENT_DATE', 'CURRENT_TIME'], + true + ) + ) { $column->defaultValue = new Expression($column->defaultValue); } elseif ($column->type === 'boolean') { $column->defaultValue = ($column->defaultValue === 'true'); } elseif (preg_match("/^B'(.*?)'::/", $column->defaultValue, $matches)) { $column->defaultValue = bindec($matches[1]); - } elseif (strncasecmp($column->dbType, 'bit', 3) === 0 || strncasecmp($column->dbType, 'varbit', 6) === 0) { - $column->defaultValue = bindec(trim($column->defaultValue, 'B\'')); + } elseif (preg_match("/^'(\d+)'::\"bit\"$/", $column->defaultValue, $matches)) { + $column->defaultValue = bindec($matches[1]); } elseif (preg_match("/^'(.*?)'::/", $column->defaultValue, $matches)) { $column->defaultValue = $column->phpTypecast($matches[1]); } elseif (preg_match('/^(\()?(.*?)(?(1)\))(?:::.+)?$/', $column->defaultValue, $matches)) {