Fix #17473: Fixed SimpleConditionBuilder::build() when column is not a string

This commit is contained in:
Alexander Kartavenko
2019-08-01 13:20:37 +03:00
committed by Alexander Makarov
parent e615f0f43e
commit 69cf9de56b
3 changed files with 3 additions and 2 deletions

View File

@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.25 under development
------------------------
- Bug #17473: Fixed `SimpleConditionBuilder::build()` when column is not a string (alexkart)
- Bug #17486: Fixed error when using `batch()` without `$db` parameter with MSSQL (alexkart)

View File

@ -10,7 +10,6 @@ namespace yii\db\conditions;
use yii\db\ExpressionBuilderInterface;
use yii\db\ExpressionBuilderTrait;
use yii\db\ExpressionInterface;
use yii\db\Query;
/**
* Class NotConditionBuilder builds objects of [[SimpleCondition]]
@ -37,7 +36,7 @@ class SimpleConditionBuilder implements ExpressionBuilderInterface
$column = $expression->getColumn();
$value = $expression->getValue();
if (strpos($column, '(') === false) {
if (is_string($column) && strpos($column, '(') === false) {
$column = $this->queryBuilder->db->quoteColumnName($column);
}

View File

@ -1201,6 +1201,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
[['>=', 'date', new Expression('DATE_SUB(NOW(), INTERVAL 1 MONTH)')], '[[date]] >= DATE_SUB(NOW(), INTERVAL 1 MONTH)', []],
[['>=', '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
// hash condition
[['a' => 1, 'b' => 2], '([[a]]=:qp0) AND ([[b]]=:qp1)', [':qp0' => 1, ':qp1' => 2]],