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 +18 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4385,14 +4385,7 @@ const pushInsertSql = (ctx, q, query, quotedAs) => {
|
|
|
4385
4385
|
const name = ((_c = shape[merge]) == null ? void 0 : _c.data.name) || merge;
|
|
4386
4386
|
sql = `"${name}" = excluded."${name}"`;
|
|
4387
4387
|
} else if ("except" in merge) {
|
|
4388
|
-
|
|
4389
|
-
const except = toArray(merge.except);
|
|
4390
|
-
for (let i = 0; i < columns.length; i++) {
|
|
4391
|
-
if (!except.includes(columns[i])) {
|
|
4392
|
-
notExcluded.push(quotedColumns[i]);
|
|
4393
|
-
}
|
|
4394
|
-
}
|
|
4395
|
-
sql = mergeColumnsSql(notExcluded);
|
|
4388
|
+
sql = mergeColumnsSql(columns, quotedColumns, target, merge.except);
|
|
4396
4389
|
} else {
|
|
4397
4390
|
sql = merge.reduce((sql2, item, i) => {
|
|
4398
4391
|
var _a2;
|
|
@@ -4401,7 +4394,7 @@ const pushInsertSql = (ctx, q, query, quotedAs) => {
|
|
|
4401
4394
|
}, "");
|
|
4402
4395
|
}
|
|
4403
4396
|
} else {
|
|
4404
|
-
sql = mergeColumnsSql(quotedColumns);
|
|
4397
|
+
sql = mergeColumnsSql(columns, quotedColumns, target);
|
|
4405
4398
|
}
|
|
4406
4399
|
ctx.sql.push("DO UPDATE SET", sql);
|
|
4407
4400
|
} else if (query.onConflict.set) {
|
|
@@ -4429,8 +4422,22 @@ const pushInsertSql = (ctx, q, query, quotedAs) => {
|
|
|
4429
4422
|
pushWhereStatementSql(ctx, q, query, quotedAs);
|
|
4430
4423
|
return pushReturningSql(ctx, q, query, quotedAs, query.afterCreateSelect);
|
|
4431
4424
|
};
|
|
4432
|
-
const mergeColumnsSql = (quotedColumns2) => {
|
|
4433
|
-
|
|
4425
|
+
const mergeColumnsSql = (columns, quotedColumns2, target, except) => {
|
|
4426
|
+
const notExcluded = [];
|
|
4427
|
+
const exclude = typeof target === "string" ? [target] : Array.isArray(target) ? [...target] : [];
|
|
4428
|
+
if (except) {
|
|
4429
|
+
if (typeof except === "string") {
|
|
4430
|
+
exclude.push(except);
|
|
4431
|
+
} else {
|
|
4432
|
+
exclude.push(...except);
|
|
4433
|
+
}
|
|
4434
|
+
}
|
|
4435
|
+
for (let i = 0; i < columns.length; i++) {
|
|
4436
|
+
if (!exclude.includes(columns[i])) {
|
|
4437
|
+
notExcluded.push(quotedColumns2[i]);
|
|
4438
|
+
}
|
|
4439
|
+
}
|
|
4440
|
+
return notExcluded.map((column) => `${column} = excluded.${column}`).join(", ");
|
|
4434
4441
|
};
|
|
4435
4442
|
const encodeRow = (ctx, q, QueryClass, row, runtimeDefaults, quotedAs) => {
|
|
4436
4443
|
const arr = row.map((value) => {
|