pqb 0.71.2 → 0.71.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 +22 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6566,7 +6566,8 @@ const tableColumnToSql = (ctx, queryData, shape, table, key, quotedAs, select, a
|
|
|
6566
6566
|
} else {
|
|
6567
6567
|
const tableName = _getQueryAliasOrName(queryData, table);
|
|
6568
6568
|
const quoted = `"${table}"`;
|
|
6569
|
-
const
|
|
6569
|
+
const joined = queryData.joinedShapes?.[tableName];
|
|
6570
|
+
const col = joined ? joined[key] : quoted === quotedAs ? shape[key] : void 0;
|
|
6570
6571
|
if (jsonList && as) jsonList[as] = col && getSelectedColumnData(col);
|
|
6571
6572
|
if (col?.data.selectSql) sql = `(${col.data.selectSql.toSQL(ctx, quoted)})`;
|
|
6572
6573
|
else if (col?.data.name) sql = `"${tableName}"."${col.data.name}"`;
|
|
@@ -10046,7 +10047,16 @@ const _joinLateral = (self, type, joinQuery, as, innerJoinLateral) => {
|
|
|
10046
10047
|
const joinedAs = getQueryAs(query);
|
|
10047
10048
|
setObjectValueImmutable(joinQuery.q, "joinedShapes", joinedAs, query.q.selectShape);
|
|
10048
10049
|
}
|
|
10049
|
-
const
|
|
10050
|
+
const joinedShapeMayHaveNames = joinQuery.table && joinQuery.q.joinedShapes?.[joinQuery.table] || joinQuery.q.joinedShapes?.[joinAs];
|
|
10051
|
+
let joinedShape;
|
|
10052
|
+
if (joinedShapeMayHaveNames) {
|
|
10053
|
+
joinedShape = {};
|
|
10054
|
+
for (const key in joinedShapeMayHaveNames) {
|
|
10055
|
+
const column = joinedShapeMayHaveNames[key];
|
|
10056
|
+
joinedShape[key] = column.data.name ? setColumnData(column, "name", void 0) : column;
|
|
10057
|
+
}
|
|
10058
|
+
}
|
|
10059
|
+
const shape = joinedShape || getShapeFromSelect(joinQuery, true);
|
|
10050
10060
|
setObjectValueImmutable(query.q, "joinedShapes", joinAs, shape);
|
|
10051
10061
|
if (joinValue) setObjectValueImmutable(query.q, "valuesJoinedAs", joinAs, joinValueAs);
|
|
10052
10062
|
setObjectValueImmutable(query.q, "joinedParsers", joinValueAs || joinAs, getQueryParsers(joinQuery));
|
|
@@ -11074,7 +11084,7 @@ const selectColumn = (query, q, key, columnAs, columnAlias) => {
|
|
|
11074
11084
|
};
|
|
11075
11085
|
const getShapeFromSelect = (q, isSubQuery) => {
|
|
11076
11086
|
const query = q.q;
|
|
11077
|
-
const { selectShape
|
|
11087
|
+
const { selectShape } = query;
|
|
11078
11088
|
let select;
|
|
11079
11089
|
if (query.selectedComputeds) {
|
|
11080
11090
|
select = query.select ? [...query.select] : [];
|
|
@@ -11084,18 +11094,18 @@ const getShapeFromSelect = (q, isSubQuery) => {
|
|
|
11084
11094
|
if (!select) if (query.type) result = {};
|
|
11085
11095
|
else if (isSubQuery) {
|
|
11086
11096
|
result = {};
|
|
11087
|
-
for (const key in
|
|
11088
|
-
const column =
|
|
11097
|
+
for (const key in selectShape) {
|
|
11098
|
+
const column = selectShape[key];
|
|
11089
11099
|
if (!column.data.explicitSelect) result[key] = column.data.name ? setColumnData(column, "name", void 0) : column;
|
|
11090
11100
|
}
|
|
11091
|
-
} else result =
|
|
11101
|
+
} else result = selectShape;
|
|
11092
11102
|
else {
|
|
11093
11103
|
result = {};
|
|
11094
|
-
for (const item of select) if (typeof item === "string") addColumnToShapeFromSelect(q, item,
|
|
11104
|
+
for (const item of select) if (typeof item === "string") addColumnToShapeFromSelect(q, item, selectShape, query, result, isSubQuery);
|
|
11095
11105
|
else if (isExpression(item)) result.value = item.result.value;
|
|
11096
11106
|
else if (item && "selectAs" in item) for (const key in item.selectAs) {
|
|
11097
11107
|
const it = item.selectAs[key];
|
|
11098
|
-
if (typeof it === "string") addColumnToShapeFromSelect(q, it,
|
|
11108
|
+
if (typeof it === "string") addColumnToShapeFromSelect(q, it, selectShape, query, result, isSubQuery, key);
|
|
11099
11109
|
else if (isExpression(it)) result[key] = it.result.value || UnknownColumn.instance;
|
|
11100
11110
|
else if (it) {
|
|
11101
11111
|
const { returnType } = it.q;
|
|
@@ -12384,6 +12394,10 @@ var QueryExpressions = class {
|
|
|
12384
12394
|
if (table === as) column = selectShape[col];
|
|
12385
12395
|
else column = q.q.joinedShapes?.[table][col];
|
|
12386
12396
|
} else column = selectShape[arg];
|
|
12397
|
+
q.q.batchParsers = void 0;
|
|
12398
|
+
q.q.transform = void 0;
|
|
12399
|
+
q.q.hookSelect = void 0;
|
|
12400
|
+
q.q.returnType = void 0;
|
|
12387
12401
|
return new RefExpression(column || UnknownColumn.instance, q, arg);
|
|
12388
12402
|
}
|
|
12389
12403
|
val(value) {
|