mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-15 14:50:56 +08:00
Fix ODBC Driver 13 for SQL Server error on null (#16039)
This commit is contained in:

committed by
Dmitry Naumenko

parent
f5665a0544
commit
cb15a413a7
@ -334,7 +334,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
|||||||
$columnSchemas = $tableSchema->columns;
|
$columnSchemas = $tableSchema->columns;
|
||||||
foreach ($columns as $name => $value) {
|
foreach ($columns as $name => $value) {
|
||||||
// @see https://github.com/yiisoft/yii2/issues/12599
|
// @see https://github.com/yiisoft/yii2/issues/12599
|
||||||
if (isset($columnSchemas[$name]) && $columnSchemas[$name]->type === Schema::TYPE_BINARY && $columnSchemas[$name]->dbType === 'varbinary' && is_string($value)) {
|
if (isset($columnSchemas[$name]) && $columnSchemas[$name]->type === Schema::TYPE_BINARY && $columnSchemas[$name]->dbType === 'varbinary' && (is_string($value) || $value === null)) {
|
||||||
$exParams = [];
|
$exParams = [];
|
||||||
$phName = $this->bindParam($value, $exParams);
|
$phName = $this->bindParam($value, $exParams);
|
||||||
$columns[$name] = new Expression("CONVERT(VARBINARY, $phName)", $exParams);
|
$columns[$name] = new Expression("CONVERT(VARBINARY, $phName)", $exParams);
|
||||||
|
Reference in New Issue
Block a user