Skip to content

Commit

Permalink
Fix #18040, fix #15265, fix #18232 database issues (#18225)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
terabytesoftw authored Sep 10, 2020
1 parent 5b1b475 commit ce35719
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions db/pgsql/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit ce35719

Please sign in to comment.