Browse Source

Merge branch 'CedricYii-patch-2'

batch-query-test
SilverFire - Dmitry Naumenko 9 years ago
parent
commit
b182586cd3
  1. 1
      framework/CHANGELOG.md
  2. 6
      framework/db/QueryBuilder.php
  3. 3
      tests/framework/db/QueryBuilderTest.php

1
framework/CHANGELOG.md

@ -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)

6
framework/db/QueryBuilder.php

@ -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;
}

3
tests/framework/db/QueryBuilderTest.php

@ -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] ],

Loading…
Cancel
Save