pqb 0.31.5 → 0.31.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4387,14 +4387,7 @@ const pushInsertSql = (ctx, q, query, quotedAs) => {
4387
4387
  const name = ((_c = shape[merge]) == null ? void 0 : _c.data.name) || merge;
4388
4388
  sql = `"${name}" = excluded."${name}"`;
4389
4389
  } else if ("except" in merge) {
4390
- const notExcluded = [];
4391
- const except = orchidCore.toArray(merge.except);
4392
- for (let i = 0; i < columns.length; i++) {
4393
- if (!except.includes(columns[i])) {
4394
- notExcluded.push(quotedColumns[i]);
4395
- }
4396
- }
4397
- sql = mergeColumnsSql(notExcluded);
4390
+ sql = mergeColumnsSql(columns, quotedColumns, target, merge.except);
4398
4391
  } else {
4399
4392
  sql = merge.reduce((sql2, item, i) => {
4400
4393
  var _a2;
@@ -4403,7 +4396,7 @@ const pushInsertSql = (ctx, q, query, quotedAs) => {
4403
4396
  }, "");
4404
4397
  }
4405
4398
  } else {
4406
- sql = mergeColumnsSql(quotedColumns);
4399
+ sql = mergeColumnsSql(columns, quotedColumns, target);
4407
4400
  }
4408
4401
  ctx.sql.push("DO UPDATE SET", sql);
4409
4402
  } else if (query.onConflict.set) {
@@ -4431,8 +4424,22 @@ const pushInsertSql = (ctx, q, query, quotedAs) => {
4431
4424
  pushWhereStatementSql(ctx, q, query, quotedAs);
4432
4425
  return pushReturningSql(ctx, q, query, quotedAs, query.afterCreateSelect);
4433
4426
  };
4434
- const mergeColumnsSql = (quotedColumns2) => {
4435
- return quotedColumns2.map((column) => `${column} = excluded.${column}`).join(", ");
4427
+ const mergeColumnsSql = (columns, quotedColumns2, target, except) => {
4428
+ const notExcluded = [];
4429
+ const exclude = typeof target === "string" ? [target] : Array.isArray(target) ? [...target] : [];
4430
+ if (except) {
4431
+ if (typeof except === "string") {
4432
+ exclude.push(except);
4433
+ } else {
4434
+ exclude.push(...except);
4435
+ }
4436
+ }
4437
+ for (let i = 0; i < columns.length; i++) {
4438
+ if (!exclude.includes(columns[i])) {
4439
+ notExcluded.push(quotedColumns2[i]);
4440
+ }
4441
+ }
4442
+ return notExcluded.map((column) => `${column} = excluded.${column}`).join(", ");
4436
4443
  };
4437
4444
  const encodeRow = (ctx, q, QueryClass, row, runtimeDefaults, quotedAs) => {
4438
4445
  const arr = row.map((value) => {