Merge branch 'CedricYii-patch-2'

This commit is contained in:
SilverFire - Dmitry Naumenko
2016-03-13 19:23:04 +02:00
3 changed files with 10 additions and 0 deletions

View File

@ -13,6 +13,7 @@ Yii Framework 2 Change Log
- Bug #10969: Fixed generator migration tool with decimal params in column (pana1990)
- Bug #10974: `yii.js` - fixed error in ajaxPrefilter event handler, caused by blocked frame (maximal)
- Bug #11038: Fixed handling of intervals of 0 seconds in `yii\i18n\Formatter::asDuration()` (VirtualRJ)
- Bug #11093: Fixed `yii\db\QueryBuilder::buildAndCondition()` to add query params passed directly by `yii\db\Expression` (CedricYii, silverfire)
- Bug: SQlite querybuilder did not create primary key with bigint for `TYPE_BIGPK` (cebe)
- Enh #5469: Add mimetype validation by mask in FileValidator (kirsenn, samdark, silverfire)
- Enh #8602: `yii\validators\DateValidator` skip validation for `timestampAttribute`, if it is already in correct format (klimov-paul)

View File

@ -1006,6 +1006,12 @@ class QueryBuilder extends \yii\base\Object
if (is_array($operand)) {
$operand = $this->buildCondition($operand, $params);
}
if ($operand instanceof Expression) {
foreach ($operand->params as $n => $v) {
$params[$n] = $v;
}
$operand = $operand->expression;
}
if ($operand !== '') {
$parts[] = $operand;
}

View File

@ -216,10 +216,13 @@ class QueryBuilderTest extends DatabaseTestCase
// and
[ ['and', 'id=1', 'id=2'], '(id=1) AND (id=2)', [] ],
[ ['and', 'type=1', ['or', 'id=1', 'id=2']], '(type=1) AND ((id=1) OR (id=2))', [] ],
[ ['and', 'id=1', new Expression('id=:qp0', [':qp0' => 2])], '(id=1) AND (id=:qp0)', [':qp0' => 2] ],
// or
[ ['or', 'id=1', 'id=2'], '(id=1) OR (id=2)', [] ],
[ ['or', 'type=1', ['or', 'id=1', 'id=2']], '(type=1) OR ((id=1) OR (id=2))', [] ],
[ ['or', 'type=1', new Expression('id=:qp0', [':qp0' => 1])], '(type=1) OR (id=:qp0)', [':qp0' => 1] ],
// between
[ ['between', 'id', 1, 10], '[[id]] BETWEEN :qp0 AND :qp1', [':qp0' => 1, ':qp1' => 10] ],