Merge branch 'fphammerle-mysql-comma-in-enum-fix'

This commit is contained in:
SilverFire - Dmitry Naumenko
2016-11-29 00:22:32 +02:00
5 changed files with 7 additions and 6 deletions

View File

@ -6,6 +6,7 @@ Yii Framework 2 Change Log
- Bug #4113: Error page stacktrace was generating links to private methods which are not part of the API docs (samdark) - Bug #4113: Error page stacktrace was generating links to private methods which are not part of the API docs (samdark)
- Bug #9305: Fixed MSSQL `Schema::TYPE_TIMESTAMP` to be 'datetime' instead of 'timestamp', which is just an incremental number (nkovacs) - Bug #9305: Fixed MSSQL `Schema::TYPE_TIMESTAMP` to be 'datetime' instead of 'timestamp', which is just an incremental number (nkovacs)
- Bug #9616: Fixed mysql\Schema::loadColumnSchema to set enumValues attribute correctly if enum definition contains commas (fphammerle)
- Bug #9796: Initialization of not existing `yii\grid\ActionColumn` default buttons (arogachev) - Bug #9796: Initialization of not existing `yii\grid\ActionColumn` default buttons (arogachev)
- Bug #12681: Changed `data` column type from `text` to `blob` to handle null-byte (`\0`) in serialized RBAC rule properly (silverfire) - Bug #12681: Changed `data` column type from `text` to `blob` to handle null-byte (`\0`) in serialized RBAC rule properly (silverfire)
- Bug #12714: Fixed `yii\validation\EmailValidator` to prevent false-positives checks when property `checkDns` is set to `true` (silverfire) - Bug #12714: Fixed `yii\validation\EmailValidator` to prevent false-positives checks when property `checkDns` is set to `true` (silverfire)

View File

@ -147,8 +147,8 @@ class Schema extends \yii\db\Schema
} }
if (!empty($matches[2])) { if (!empty($matches[2])) {
if ($type === 'enum') { if ($type === 'enum') {
$values = explode(',', $matches[2]); preg_match_all("/'[^']*'/", $matches[2], $values);
foreach ($values as $i => $value) { foreach ($values[0] as $i => $value) {
$values[$i] = trim($value, "'"); $values[$i] = trim($value, "'");
} }
$column->enumValues = $values; $column->enumValues = $values;

View File

@ -117,7 +117,7 @@ CREATE TABLE "type" (
"char_col" char(100) NOT NULL, "char_col" char(100) NOT NULL,
"char_col2" varchar(100) DEFAULT 'something', "char_col2" varchar(100) DEFAULT 'something',
"char_col3" string, "char_col3" string,
"enum_col" enum('a','B'), "enum_col" enum('a','B','c,D'),
"float_col" double NOT NULL, "float_col" double NOT NULL,
"float_col2" double DEFAULT '1.23', "float_col2" double DEFAULT '1.23',
"blob_col" blob, "blob_col" blob,

View File

@ -128,7 +128,7 @@ CREATE TABLE `type` (
`char_col` char(100) NOT NULL, `char_col` char(100) NOT NULL,
`char_col2` varchar(100) DEFAULT 'something', `char_col2` varchar(100) DEFAULT 'something',
`char_col3` text, `char_col3` text,
`enum_col` enum('a', 'B'), `enum_col` enum('a', 'B', 'c,D'),
`float_col` double(4,3) NOT NULL, `float_col` double(4,3) NOT NULL,
`float_col2` double DEFAULT '1.23', `float_col2` double DEFAULT '1.23',
`blob_col` blob, `blob_col` blob,

View File

@ -218,11 +218,11 @@ abstract class SchemaTest extends DatabaseTestCase
], ],
'enum_col' => [ 'enum_col' => [
'type' => 'string', 'type' => 'string',
'dbType' => "enum('a','B')", 'dbType' => "enum('a','B','c,D')",
'phpType' => 'string', 'phpType' => 'string',
'allowNull' => true, 'allowNull' => true,
'autoIncrement' => false, 'autoIncrement' => false,
'enumValues' => ['a', 'B'], 'enumValues' => ['a', 'B','c,D'],
'size' => null, 'size' => null,
'precision' => null, 'precision' => null,
'scale' => null, 'scale' => null,