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.js
CHANGED
|
@@ -6589,7 +6589,8 @@ const tableColumnToSql = (ctx, queryData, shape, table, key, quotedAs, select, a
|
|
|
6589
6589
|
} else {
|
|
6590
6590
|
const tableName = _getQueryAliasOrName(queryData, table);
|
|
6591
6591
|
const quoted = `"${table}"`;
|
|
6592
|
-
const
|
|
6592
|
+
const joined = queryData.joinedShapes?.[tableName];
|
|
6593
|
+
const col = joined ? joined[key] : quoted === quotedAs ? shape[key] : void 0;
|
|
6593
6594
|
if (jsonList && as) jsonList[as] = col && getSelectedColumnData(col);
|
|
6594
6595
|
if (col?.data.selectSql) sql = `(${col.data.selectSql.toSQL(ctx, quoted)})`;
|
|
6595
6596
|
else if (col?.data.name) sql = `"${tableName}"."${col.data.name}"`;
|
|
@@ -10069,7 +10070,16 @@ const _joinLateral = (self, type, joinQuery, as, innerJoinLateral) => {
|
|
|
10069
10070
|
const joinedAs = getQueryAs(query);
|
|
10070
10071
|
setObjectValueImmutable(joinQuery.q, "joinedShapes", joinedAs, query.q.selectShape);
|
|
10071
10072
|
}
|
|
10072
|
-
const
|
|
10073
|
+
const joinedShapeMayHaveNames = joinQuery.table && joinQuery.q.joinedShapes?.[joinQuery.table] || joinQuery.q.joinedShapes?.[joinAs];
|
|
10074
|
+
let joinedShape;
|
|
10075
|
+
if (joinedShapeMayHaveNames) {
|
|
10076
|
+
joinedShape = {};
|
|
10077
|
+
for (const key in joinedShapeMayHaveNames) {
|
|
10078
|
+
const column = joinedShapeMayHaveNames[key];
|
|
10079
|
+
joinedShape[key] = column.data.name ? setColumnData(column, "name", void 0) : column;
|
|
10080
|
+
}
|
|
10081
|
+
}
|
|
10082
|
+
const shape = joinedShape || getShapeFromSelect(joinQuery, true);
|
|
10073
10083
|
setObjectValueImmutable(query.q, "joinedShapes", joinAs, shape);
|
|
10074
10084
|
if (joinValue) setObjectValueImmutable(query.q, "valuesJoinedAs", joinAs, joinValueAs);
|
|
10075
10085
|
setObjectValueImmutable(query.q, "joinedParsers", joinValueAs || joinAs, getQueryParsers(joinQuery));
|
|
@@ -11097,7 +11107,7 @@ const selectColumn = (query, q, key, columnAs, columnAlias) => {
|
|
|
11097
11107
|
};
|
|
11098
11108
|
const getShapeFromSelect = (q, isSubQuery) => {
|
|
11099
11109
|
const query = q.q;
|
|
11100
|
-
const { selectShape
|
|
11110
|
+
const { selectShape } = query;
|
|
11101
11111
|
let select;
|
|
11102
11112
|
if (query.selectedComputeds) {
|
|
11103
11113
|
select = query.select ? [...query.select] : [];
|
|
@@ -11107,18 +11117,18 @@ const getShapeFromSelect = (q, isSubQuery) => {
|
|
|
11107
11117
|
if (!select) if (query.type) result = {};
|
|
11108
11118
|
else if (isSubQuery) {
|
|
11109
11119
|
result = {};
|
|
11110
|
-
for (const key in
|
|
11111
|
-
const column =
|
|
11120
|
+
for (const key in selectShape) {
|
|
11121
|
+
const column = selectShape[key];
|
|
11112
11122
|
if (!column.data.explicitSelect) result[key] = column.data.name ? setColumnData(column, "name", void 0) : column;
|
|
11113
11123
|
}
|
|
11114
|
-
} else result =
|
|
11124
|
+
} else result = selectShape;
|
|
11115
11125
|
else {
|
|
11116
11126
|
result = {};
|
|
11117
|
-
for (const item of select) if (typeof item === "string") addColumnToShapeFromSelect(q, item,
|
|
11127
|
+
for (const item of select) if (typeof item === "string") addColumnToShapeFromSelect(q, item, selectShape, query, result, isSubQuery);
|
|
11118
11128
|
else if (isExpression(item)) result.value = item.result.value;
|
|
11119
11129
|
else if (item && "selectAs" in item) for (const key in item.selectAs) {
|
|
11120
11130
|
const it = item.selectAs[key];
|
|
11121
|
-
if (typeof it === "string") addColumnToShapeFromSelect(q, it,
|
|
11131
|
+
if (typeof it === "string") addColumnToShapeFromSelect(q, it, selectShape, query, result, isSubQuery, key);
|
|
11122
11132
|
else if (isExpression(it)) result[key] = it.result.value || UnknownColumn.instance;
|
|
11123
11133
|
else if (it) {
|
|
11124
11134
|
const { returnType } = it.q;
|
|
@@ -12407,6 +12417,10 @@ var QueryExpressions = class {
|
|
|
12407
12417
|
if (table === as) column = selectShape[col];
|
|
12408
12418
|
else column = q.q.joinedShapes?.[table][col];
|
|
12409
12419
|
} else column = selectShape[arg];
|
|
12420
|
+
q.q.batchParsers = void 0;
|
|
12421
|
+
q.q.transform = void 0;
|
|
12422
|
+
q.q.hookSelect = void 0;
|
|
12423
|
+
q.q.returnType = void 0;
|
|
12410
12424
|
return new RefExpression(column || UnknownColumn.instance, q, arg);
|
|
12411
12425
|
}
|
|
12412
12426
|
val(value) {
|