9
9
use InvalidArgumentException ;
10
10
use Yiisoft \Db \Exception \InvalidConfigException ;
11
11
use Yiisoft \Db \Exception \NotSupportedException ;
12
- use Yiisoft \Db \Expression \Expression ;
13
12
use Yiisoft \Db \Query \QueryInterface ;
14
13
use Yiisoft \Db \QueryBuilder \AbstractDMLQueryBuilder ;
15
14
@@ -213,7 +212,7 @@ private function prepareUpsertParts(
213
212
214
213
foreach ($ columnNames as $ name ) {
215
214
$ quotedName = $ this ->quoter ->quoteColumnName ($ name );
216
- $ constraintCondition [] = "$ quotedTableName. $ quotedName=[ EXCLUDED] . $ quotedName " ;
215
+ $ constraintCondition [] = "$ quotedTableName. $ quotedName=EXCLUDED. $ quotedName " ;
217
216
}
218
217
219
218
$ onCondition [] = $ constraintCondition ;
@@ -227,18 +226,18 @@ private function prepareUpsertParts(
227
226
228
227
$ mergeSql = 'MERGE ' . $ quotedTableName . ' WITH (HOLDLOCK) USING ( '
229
228
. (!empty ($ placeholders ) ? 'VALUES ( ' . implode (', ' , $ placeholders ) . ') ' : $ values )
230
- . ') AS [ EXCLUDED] ( ' . implode (', ' , $ quotedInsertNames ) . ') ' . "ON ( $ on) " ;
229
+ . ') AS EXCLUDED ( ' . implode (', ' , $ quotedInsertNames ) . ') ' . "ON ( $ on) " ;
231
230
232
231
$ insertValues = [];
233
232
234
233
foreach ($ quotedInsertNames as $ quotedName ) {
235
- $ insertValues [] = '[ EXCLUDED] . ' . $ quotedName ;
234
+ $ insertValues [] = 'EXCLUDED. ' . $ quotedName ;
236
235
}
237
236
238
237
$ insertSql = 'INSERT ( ' . implode (', ' , $ quotedInsertNames ) . ') '
239
238
. ' VALUES ( ' . implode (', ' , $ insertValues ) . ') ' ;
240
239
241
- if ($ updateColumns === false || $ updateNames === []) {
240
+ if (empty ( $ updateColumns) || $ updateNames === []) {
242
241
/** there are no columns to update */
243
242
return [
244
243
$ mergeSql ,
@@ -247,16 +246,7 @@ private function prepareUpsertParts(
247
246
];
248
247
}
249
248
250
- if ($ updateColumns === true ) {
251
- $ updateColumns = [];
252
-
253
- /** @psalm-var string[] $updateNames */
254
- foreach ($ updateNames as $ name ) {
255
- $ updateColumns [$ name ] = new Expression ('[EXCLUDED]. ' . $ this ->quoter ->quoteColumnName ($ name ));
256
- }
257
- }
258
-
259
- $ updates = $ this ->prepareUpdateSets ($ table , $ updateColumns , $ params );
249
+ $ updates = $ this ->prepareUpsertSets ($ table , $ updateColumns , $ updateNames , $ params );
260
250
261
251
return [
262
252
$ mergeSql ,
0 commit comments