mirror of
https://github.com/yiisoft/yii2.git
synced 2025-10-30 10:08:08 +08:00
Fix #17473: Fixed SimpleConditionBuilder::build() when column is not a string
This commit is contained in:
committed by
Alexander Makarov
parent
e615f0f43e
commit
69cf9de56b
@ -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)
|
||||
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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]],
|
||||
|
||||
Reference in New Issue
Block a user