mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 13:58:55 +08:00
Fix #17549: Fix yii\db\ExpressionInterface not supported in yii\db\conditions\SimpleConditionBuilder
This commit is contained in:
committed by
Alexander Makarov
parent
c75ef05539
commit
062ebf5c0b
@ -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)
|
||||
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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]],
|
||||
|
||||
Reference in New Issue
Block a user