mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-08 17:07:33 +08: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
@ -4,6 +4,7 @@ Yii Framework 2 Change Log
|
||||
2.0.26 under development
|
||||
------------------------
|
||||
|
||||
- Bug #17504: Fix upsert when `$updateColumns = true` but there are no columns to update in the table (alexkart)
|
||||
- Bug #17511: Fixed IPv6 subnets matching in `IpHelper::inRange()` (kamarton)
|
||||
|
||||
|
||||
|
||||
@ -70,6 +70,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;
|
||||
}
|
||||
|
||||
$onCondition = ['or'];
|
||||
$quotedTableName = $this->db->quoteTableName($table);
|
||||
|
||||
@ -454,6 +454,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;
|
||||
}
|
||||
|
||||
$onCondition = ['or'];
|
||||
$quotedTableName = $this->db->quoteTableName($table);
|
||||
|
||||
@ -278,6 +278,10 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
if (empty($uniqueNames)) {
|
||||
return $insertSql;
|
||||
}
|
||||
if ($updateNames === []) {
|
||||
// there are no columns to update
|
||||
$updateColumns = false;
|
||||
}
|
||||
|
||||
if ($updateColumns === true) {
|
||||
$updateColumns = [];
|
||||
|
||||
@ -218,6 +218,10 @@ EOD;
|
||||
if (empty($uniqueNames)) {
|
||||
return $this->insert($table, $insertColumns, $params);
|
||||
}
|
||||
if ($updateNames === []) {
|
||||
// there are no columns to update
|
||||
$updateColumns = false;
|
||||
}
|
||||
|
||||
$onCondition = ['or'];
|
||||
$quotedTableName = $this->db->quoteTableName($table);
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user