Fixes #15167: Fixed loading of default value current_timestamp() for MariaDB >= 10.2.3

This commit is contained in:
Pavel Ivanov
2019-01-12 00:47:40 +02:00
committed by Alexander Makarov
parent c59df914c1
commit 7ccadb4a79
3 changed files with 40 additions and 1 deletions

View File

@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.16 under development
------------------------
- Bug #15167: Fixed loading of default value `current_timestamp()` for MariaDB >= 10.2.3 (rugabarbo, bloodrain777, Skinka)
- Bug #16253: Fixed empty checkboxlist validation (GHopperMSK)
- Bug #15286: Fixed incorrect formatting of time with timezone information (rugabarbo)
- Bug #17021: Fix to do not remove existing message category files in a subfolder (albertborsos)

View File

@ -287,7 +287,14 @@ SQL;
$column->phpType = $this->getColumnPhpType($column);
if (!$column->isPrimaryKey) {
if (($column->type === 'timestamp' || $column->type ==='datetime') && $info['default'] === 'CURRENT_TIMESTAMP') {
/**
* When displayed in the INFORMATION_SCHEMA.COLUMNS table, a default CURRENT TIMESTAMP is displayed
* as CURRENT_TIMESTAMP up until MariaDB 10.2.2, and as current_timestamp() from MariaDB 10.2.3.
*
* See details here: https://mariadb.com/kb/en/library/now/#description
*/
if (($column->type === 'timestamp' || $column->type === 'datetime') &&
($info['default'] === 'CURRENT_TIMESTAMP' || $info['default'] === 'current_timestamp()')) {
$column->defaultValue = new Expression('CURRENT_TIMESTAMP');
} elseif (isset($type) && $type === 'bit') {
$column->defaultValue = bindec(trim($info['default'], 'b\''));