Fix #17504: Fix upsert when $updateColumns = true but there are no columns to update in the table

This commit is contained in:
Alexander Kartavenko
2019-08-21 11:56:20 +03:00
committed by Alexander Makarov
parent f72f7c7406
commit cdd40b8dfb
18 changed files with 90 additions and 0 deletions

View File

@ -74,6 +74,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;
}
list(, $placeholders, $values, $params) = $this->prepareInsertValues($table, $insertColumns, $params);
$insertSql = 'INSERT OR IGNORE INTO ' . $this->db->quoteTableName($table)