Skip to content

Commit

Permalink
Fixes yiisoft#14334: Fixed \yii\db\QueryBuilder::buildNotCondition
Browse files Browse the repository at this point in the history
…loses params when operand is `\yii\db\Expression`
  • Loading branch information
pchapl authored and samdark committed Jun 27, 2017
1 parent d4c15c3 commit e383105
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Yii Framework 2 Change Log
- Chg #14286: Used primary inputmask package name instead of an alias (samdark)
- Enh #14298: The default response formatter configs defined by `yii\web\Response::defaultFormatters()` now use the array syntax (brandonkelly)
- Bug #14304: Fixed `yii\validators\UniqueValidator` and `yii\validators\ExistValidator` to skip prefixes in case expressions are used (samdark)
- Bug #14334: Fixed `\yii\db\QueryBuilder::buildNotCondition` loses params when operand is `\yii\db\Expression` (Ni-san)
- Bug #14341: Fixed regression in error handling introduced by fixing #14264 (samdark)

2.0.12 June 05, 2017
Expand Down
2 changes: 1 addition & 1 deletion framework/db/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ public function buildNotCondition($operator, $operands, &$params)
}

$operand = reset($operands);
if (is_array($operand)) {
if (is_array($operand) || $operand instanceof Expression) {
$operand = $this->buildCondition($operand, $params);
}
if ($operand === '') {
Expand Down
4 changes: 4 additions & 0 deletions tests/framework/db/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,10 @@ public function conditionProvider()
// direct conditions
['a = CONCAT(col1, col2)', 'a = CONCAT(col1, col2)', []],
[new Expression('a = CONCAT(col1, :param1)', ['param1' => 'value1']), 'a = CONCAT(col1, :param1)', ['param1' => 'value1']],

// Expression with params as operand of 'not'
[['not', new Expression('any_expression(:a)', [':a' => 1])], 'NOT (any_expression(:a))', [':a' => 1]],
[new Expression('NOT (any_expression(:a))', [':a' => 1]), 'NOT (any_expression(:a))', [':a' => 1]],
];
switch ($this->driverName) {
case 'sqlsrv':
Expand Down

0 comments on commit e383105

Please sign in to comment.