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