Fix #17549: Fix yii\db\ExpressionInterface not supported in yii\db\conditions\SimpleConditionBuilder

This commit is contained in:
Razvan Grigore
2019-09-10 17:21:53 +02:00
committed by Alexander Makarov
parent c75ef05539
commit 062ebf5c0b
3 changed files with 5 additions and 1 deletions

View File

@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.27 under development
------------------------
- Bug #17549: Fix `yii\db\ExpressionInterface` not supported in `yii\db\conditions\SimpleConditionBuilder` (razvanphp)
- Bug #17434: Fix regular expression illegal character; Repeated fix for Internet Explorer 11 AJAX redirect bug in case of 301 and 302 response codes (`XMLHttpRequest: Network Error 0x800c0008`) (kamarton)

View File

@ -36,7 +36,9 @@ class SimpleConditionBuilder implements ExpressionBuilderInterface
$column = $expression->getColumn();
$value = $expression->getValue();
if (is_string($column) && strpos($column, '(') === false) {
if ($column instanceof ExpressionInterface) {
$column = $this->queryBuilder->buildExpression($column, $params);
} elseif (is_string($column) && strpos($column, '(') === false) {
$column = $this->queryBuilder->db->quoteColumnName($column);
}

View File

@ -1202,6 +1202,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
[['>=', 'date', new Expression('DATE_SUB(NOW(), INTERVAL :month MONTH)', [':month' => 2])], '[[date]] >= DATE_SUB(NOW(), INTERVAL :month MONTH)', [':month' => 2]],
[['=', 'date', (new Query())->select('max(date)')->from('test')->where(['id' => 5])], '[[date]] = (SELECT max(date) FROM [[test]] WHERE [[id]]=:qp0)', [':qp0' => 5]],
[['=', new Expression('date'), '2019-08-01'], 'date = :qp0', [':qp0' => '2019-08-01']], // operand1 is Expression
[['=', (new Query())->select('COUNT(*)')->from('test')->where(['id' => 6]), 0], '(SELECT COUNT(*) FROM [[test]] WHERE [[id]]=:qp0) = :qp1', [':qp0' => 6, ':qp1' => 0]],
// hash condition
[['a' => 1, 'b' => 2], '([[a]]=:qp0) AND ([[b]]=:qp1)', [':qp0' => 1, ':qp1' => 2]],