pqb 0.48.5 → 0.49.0
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.d.ts +17 -8
- package/dist/index.js +29 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3000,7 +3000,12 @@ 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] =
|
|
3003
|
+
item.parent[item.key] = applyTransforms(
|
|
3004
|
+
q,
|
|
3005
|
+
q.returnType,
|
|
3006
|
+
q.transform,
|
|
3007
|
+
item.data
|
|
3008
|
+
);
|
|
3004
3009
|
}
|
|
3005
3010
|
}
|
|
3006
3011
|
};
|
|
@@ -3782,8 +3787,9 @@ const addParserForSelectItem = (q, as, key, arg, joinQuery) => {
|
|
|
3782
3787
|
const { parsers } = query;
|
|
3783
3788
|
if (parsers) {
|
|
3784
3789
|
if (returnType === "one") {
|
|
3785
|
-
for (const
|
|
3786
|
-
if (data) parseRecord(parsers, data);
|
|
3790
|
+
for (const batch of batches) {
|
|
3791
|
+
if (batch.data) parseRecord(parsers, batch.data);
|
|
3792
|
+
else batch.data = void 0;
|
|
3787
3793
|
}
|
|
3788
3794
|
} else {
|
|
3789
3795
|
for (const { data } of batches) {
|
|
@@ -3791,7 +3797,11 @@ const addParserForSelectItem = (q, as, key, arg, joinQuery) => {
|
|
|
3791
3797
|
parseRecord(parsers, data);
|
|
3792
3798
|
}
|
|
3793
3799
|
}
|
|
3794
|
-
} else if (returnType
|
|
3800
|
+
} else if (returnType === "one") {
|
|
3801
|
+
for (const batch of batches) {
|
|
3802
|
+
if (!batch.data) batch.data = void 0;
|
|
3803
|
+
}
|
|
3804
|
+
} else {
|
|
3795
3805
|
for (const { data } of batches) {
|
|
3796
3806
|
if (!data) throw new NotFoundError(arg);
|
|
3797
3807
|
}
|
|
@@ -4335,14 +4345,14 @@ function queryFrom(self, arg) {
|
|
|
4335
4345
|
data.batchParsers = q.q.batchParsers;
|
|
4336
4346
|
}
|
|
4337
4347
|
data.from = arg;
|
|
4338
|
-
data.selectAllColumns = data.
|
|
4348
|
+
data.selectAllColumns = data.scopes = void 0;
|
|
4339
4349
|
return self;
|
|
4340
4350
|
}
|
|
4341
4351
|
function queryFromSql(self, args) {
|
|
4342
4352
|
const data = self.q;
|
|
4343
4353
|
data.as || (data.as = "t");
|
|
4344
4354
|
data.from = sqlQueryArgsToExpression(args);
|
|
4345
|
-
data.selectAllColumns =
|
|
4355
|
+
data.selectAllColumns = void 0;
|
|
4346
4356
|
return self;
|
|
4347
4357
|
}
|
|
4348
4358
|
class FromMethods {
|
|
@@ -4814,7 +4824,7 @@ const selectToSql = (ctx, table, query, quotedAs, hookSelect = query.hookSelect,
|
|
|
4814
4824
|
if (item === "*") {
|
|
4815
4825
|
if (hookSelect) {
|
|
4816
4826
|
selected ?? (selected = {});
|
|
4817
|
-
for (const key in query.
|
|
4827
|
+
for (const key in query.selectableShape) {
|
|
4818
4828
|
selected[key] = quotedAs;
|
|
4819
4829
|
}
|
|
4820
4830
|
}
|
|
@@ -4940,10 +4950,7 @@ function selectedObjectToSQL(ctx, quotedAs, item) {
|
|
|
4940
4950
|
}
|
|
4941
4951
|
const selectAllSql = (query, quotedAs, jsonList) => {
|
|
4942
4952
|
if (jsonList) {
|
|
4943
|
-
Object.assign(
|
|
4944
|
-
jsonList,
|
|
4945
|
-
query.selectAllKeys || query.shape
|
|
4946
|
-
);
|
|
4953
|
+
Object.assign(jsonList, query.selectableShape);
|
|
4947
4954
|
}
|
|
4948
4955
|
return query.join?.length ? query.selectAllColumns?.map((item) => `${quotedAs}.${item}`).join(", ") || `${quotedAs}.*` : query.selectAllColumns?.join(", ") || "*";
|
|
4949
4956
|
};
|
|
@@ -10247,7 +10254,7 @@ const mergableObjects = /* @__PURE__ */ new Set([
|
|
|
10247
10254
|
"joinedBatchParsers",
|
|
10248
10255
|
"selectedComputeds"
|
|
10249
10256
|
]);
|
|
10250
|
-
const dontMergeArrays = /* @__PURE__ */ new Set(["selectAllColumns"
|
|
10257
|
+
const dontMergeArrays = /* @__PURE__ */ new Set(["selectAllColumns"]);
|
|
10251
10258
|
class MergeQueryMethods {
|
|
10252
10259
|
merge(q) {
|
|
10253
10260
|
const query = _clone(this);
|
|
@@ -12749,20 +12756,26 @@ class Db extends QueryMethods {
|
|
|
12749
12756
|
);
|
|
12750
12757
|
this.columns = columns;
|
|
12751
12758
|
if (options.computed) applyComputedColumns(this, options.computed);
|
|
12759
|
+
const selectableShape = this.q.selectableShape = {};
|
|
12752
12760
|
if (prepareSelectAll) {
|
|
12753
12761
|
const list = [];
|
|
12754
|
-
const keys = {};
|
|
12755
12762
|
for (const key in shape) {
|
|
12756
12763
|
const column = shape[key];
|
|
12757
|
-
if (!column.data.explicitSelect) {
|
|
12764
|
+
if (!column.data.explicitSelect && !(column instanceof VirtualColumn)) {
|
|
12758
12765
|
list.push(
|
|
12759
12766
|
column.data.name ? `"${column.data.name}" "${key}"` : `"${key}"`
|
|
12760
12767
|
);
|
|
12761
|
-
|
|
12768
|
+
selectableShape[key] = column;
|
|
12762
12769
|
}
|
|
12763
12770
|
}
|
|
12764
12771
|
this.q.selectAllColumns = list;
|
|
12765
|
-
|
|
12772
|
+
} else {
|
|
12773
|
+
for (const key in shape) {
|
|
12774
|
+
const column = shape[key];
|
|
12775
|
+
if (column instanceof VirtualColumn) {
|
|
12776
|
+
selectableShape[key] = column;
|
|
12777
|
+
}
|
|
12778
|
+
}
|
|
12766
12779
|
}
|
|
12767
12780
|
if (modifyQuery) {
|
|
12768
12781
|
for (const cb of modifyQuery) {
|