mirror of
https://github.com/yiisoft/yii2.git
synced 2026-03-12 02:09:48 +01:00
Fix #17504: Fix upsert when $updateColumns = true but there are no columns to update in the table
This commit is contained in:
committed by
Alexander Makarov
parent
f72f7c7406
commit
cdd40b8dfb
@@ -338,6 +338,10 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
if (empty($uniqueNames)) {
|
||||
return $insertSql;
|
||||
}
|
||||
if ($updateNames === []) {
|
||||
// there are no columns to update
|
||||
$updateColumns = false;
|
||||
}
|
||||
|
||||
if ($updateColumns === false) {
|
||||
return "$insertSql ON CONFLICT DO NOTHING";
|
||||
@@ -368,6 +372,10 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
if (empty($uniqueNames)) {
|
||||
return $this->insert($table, $insertColumns, $params);
|
||||
}
|
||||
if ($updateNames === []) {
|
||||
// there are no columns to update
|
||||
$updateColumns = false;
|
||||
}
|
||||
|
||||
/** @var Schema $schema */
|
||||
$schema = $this->db->getSchema();
|
||||
|
||||
Reference in New Issue
Block a user