mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
@ -8,6 +8,7 @@ Yii Framework 2 Change Log
|
||||
- Bug #15792: Added missing `yii\db\QueryBuilder::conditionClasses` setter (silverfire)
|
||||
- Bug #15822: Fixed `yii\base\Component::off()` not to throw an exception when handler does not exist (silverfire)
|
||||
- Bug #15817: Fixed support of deprecated array format type casting in `yii\db\Command::bindValues()` (silverfire)
|
||||
- Bug #15804: Fixed `null` values handling for PostgresSQL arrays (silverfire)
|
||||
|
||||
|
||||
2.0.14.1 February 24, 2018
|
||||
|
@ -182,10 +182,14 @@ class ArrayExpression implements ExpressionInterface, \ArrayAccess, \Countable,
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
if ($this->getValue() instanceof QueryInterface) {
|
||||
$value = $this->getValue();
|
||||
if ($value instanceof QueryInterface) {
|
||||
throw new InvalidConfigException('The ArrayExpression class can not be iterated when the value is a QueryInterface object');
|
||||
}
|
||||
if ($value === null) {
|
||||
$value = [];
|
||||
}
|
||||
|
||||
return new \ArrayIterator($this->getValue());
|
||||
return new \ArrayIterator($value);
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,9 @@ class ArrayExpressionBuilder implements ExpressionBuilderInterface
|
||||
public function build(ExpressionInterface $expression, array &$params = [])
|
||||
{
|
||||
$value = $expression->getValue();
|
||||
if ($value === null) {
|
||||
return 'NULL';
|
||||
}
|
||||
|
||||
if ($value instanceof Query) {
|
||||
list ($sql, $params) = $this->queryBuilder->build($value, $params);
|
||||
|
@ -102,6 +102,8 @@ class ArrayParser
|
||||
|
||||
if (!$isQuoted && $result === 'NULL') {
|
||||
$result = null;
|
||||
} elseif ($isQuoted && $result === '{}') {
|
||||
$result = [];
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
@ -83,6 +83,8 @@ class ColumnSchema extends \yii\db\ColumnSchema
|
||||
array_walk_recursive($value, function (&$val, $key) {
|
||||
$val = $this->phpTypecastValue($val);
|
||||
});
|
||||
} elseif ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->deserializeArrayColumnToArrayExpression
|
||||
|
@ -228,6 +228,27 @@ class ActiveRecordTest extends \yiiunit\framework\db\ActiveRecordTest
|
||||
'jsonb_col' => [[null, 'a', 'b', '\"', '{"af"}']],
|
||||
'jsonarray_col' => [new ArrayExpression([[',', 'null', true, 'false', 'f']], 'json')],
|
||||
]],
|
||||
'null arrays values' => [[
|
||||
'intarray_col' => [
|
||||
null,
|
||||
],
|
||||
'textarray2_col' => [
|
||||
[null, null],
|
||||
new ArrayExpression([null, null], 'text', 2),
|
||||
],
|
||||
'json_col' => [
|
||||
null
|
||||
],
|
||||
'jsonarray_col' => [
|
||||
null
|
||||
],
|
||||
]],
|
||||
'empty arrays values' => [[
|
||||
'textarray2_col' => [
|
||||
['', ''],
|
||||
new ArrayExpression([[], []], 'text', 2),
|
||||
],
|
||||
]],
|
||||
'arrays packed in classes' => [[
|
||||
'intarray_col' => [
|
||||
new ArrayExpression([1,-2,null,'42'], 'int', 1),
|
||||
@ -257,7 +278,7 @@ class ActiveRecordTest extends \yiiunit\framework\db\ActiveRecordTest
|
||||
'jsonb_col' => [
|
||||
pi()
|
||||
],
|
||||
]]
|
||||
]],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user