pqb 0.47.2 → 0.47.4
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 +13 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2998,12 +2998,7 @@ const runAfterCommit = async (afterCommit, result) => {
|
|
|
2998
2998
|
const applyBatchTransforms = (q, batches) => {
|
|
2999
2999
|
if (q.transform) {
|
|
3000
3000
|
for (const item of batches) {
|
|
3001
|
-
item.parent[item.key] = applyTransforms(
|
|
3002
|
-
q,
|
|
3003
|
-
q.returnType,
|
|
3004
|
-
q.transform,
|
|
3005
|
-
item.data
|
|
3006
|
-
);
|
|
3001
|
+
item.parent[item.key] = item.data === null ? void 0 : applyTransforms(q, q.returnType, q.transform, item.data);
|
|
3007
3002
|
}
|
|
3008
3003
|
}
|
|
3009
3004
|
};
|
|
@@ -3102,13 +3097,15 @@ const processComputedResult = (query, result) => {
|
|
|
3102
3097
|
};
|
|
3103
3098
|
const processComputedBatches = (query, batches, originalReturnType, returnType, tempColumns, renames, key) => {
|
|
3104
3099
|
let promises;
|
|
3105
|
-
|
|
3106
|
-
|
|
3100
|
+
const plainValue = originalReturnType === "value" || originalReturnType === "valueOrThrow";
|
|
3101
|
+
for (const computedKey in query.selectedComputeds) {
|
|
3102
|
+
const setAsKey = plainValue ? key : computedKey;
|
|
3103
|
+
const computed = query.selectedComputeds[computedKey];
|
|
3107
3104
|
if (computed.kind === "one") {
|
|
3108
3105
|
for (const { data } of batches) {
|
|
3109
3106
|
for (const record of data) {
|
|
3110
3107
|
if (record) {
|
|
3111
|
-
record[
|
|
3108
|
+
record[setAsKey] = computed.fn(record);
|
|
3112
3109
|
}
|
|
3113
3110
|
}
|
|
3114
3111
|
}
|
|
@@ -3131,11 +3128,11 @@ const processComputedBatches = (query, batches, originalReturnType, returnType,
|
|
|
3131
3128
|
}
|
|
3132
3129
|
const res = computed.fn(present);
|
|
3133
3130
|
if (Array.isArray(res)) {
|
|
3134
|
-
saveBatchComputed(
|
|
3131
|
+
saveBatchComputed(setAsKey, data, res, blanks);
|
|
3135
3132
|
} else {
|
|
3136
3133
|
(promises ?? (promises = [])).push(
|
|
3137
3134
|
res.then(
|
|
3138
|
-
(res2) => saveBatchComputed(
|
|
3135
|
+
(res2) => saveBatchComputed(setAsKey, data, res2, blanks)
|
|
3139
3136
|
)
|
|
3140
3137
|
);
|
|
3141
3138
|
}
|
|
@@ -4701,7 +4698,11 @@ const mergeColumnsSql = (columns, quotedColumns2, target, except) => {
|
|
|
4701
4698
|
notExcluded.push(quotedColumns2[i]);
|
|
4702
4699
|
}
|
|
4703
4700
|
}
|
|
4704
|
-
return notExcluded.length ? `DO UPDATE SET ${notExcluded.map((column) => `${column} = excluded.${column}`).join(", ")}` :
|
|
4701
|
+
return notExcluded.length ? `DO UPDATE SET ${notExcluded.map((column) => `${column} = excluded.${column}`).join(", ")}` : (
|
|
4702
|
+
// update whatever is the first column because DO NOTHING prevents RETURNING,
|
|
4703
|
+
// and we might want to return data from the insert
|
|
4704
|
+
`DO UPDATE SET ${quotedColumns2[0]} = excluded.${quotedColumns2[0]}`
|
|
4705
|
+
);
|
|
4705
4706
|
};
|
|
4706
4707
|
const encodeRow = (ctx, values, q, QueryClass, row, runtimeDefaults, quotedAs) => {
|
|
4707
4708
|
const arr = row.map((value) => {
|