pqb 0.49.0 → 0.49.1

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.mjs CHANGED
@@ -4074,7 +4074,16 @@ const handleComputed = (q, computeds, column) => {
4074
4074
  };
4075
4075
  const getShapeFromSelect = (q, isSubQuery) => {
4076
4076
  const query = q.q;
4077
- const { select, shape } = query;
4077
+ const { shape } = query;
4078
+ let select;
4079
+ if (query.selectedComputeds) {
4080
+ select = query.select ? [...query.select] : [];
4081
+ for (const key in query.selectedComputeds) {
4082
+ select.push(...query.selectedComputeds[key].deps);
4083
+ }
4084
+ } else {
4085
+ select = query.select;
4086
+ }
4078
4087
  let result;
4079
4088
  if (!select) {
4080
4089
  if (isSubQuery) {
@@ -4133,18 +4142,33 @@ const addColumnToShapeFromSelect = (q, arg, shape, query, result, isSubQuery, ke
4133
4142
  result[key || column] = shape[column];
4134
4143
  } else {
4135
4144
  const it = query.joinedShapes?.[table]?.[column];
4136
- if (it) result[key || column] = maybeUnNameColumn(it, isSubQuery);
4145
+ if (it)
4146
+ result[key || column] = mapSubSelectColumn(
4147
+ it,
4148
+ isSubQuery
4149
+ );
4137
4150
  }
4138
4151
  } else if (arg === "*") {
4139
4152
  for (const key2 in shape) {
4140
- result[key2] = maybeUnNameColumn(shape[key2], isSubQuery);
4153
+ result[key2] = mapSubSelectColumn(
4154
+ shape[key2],
4155
+ isSubQuery
4156
+ );
4141
4157
  }
4142
4158
  } else {
4143
- result[key || arg] = maybeUnNameColumn(shape[arg], isSubQuery);
4159
+ result[key || arg] = mapSubSelectColumn(
4160
+ shape[arg],
4161
+ isSubQuery
4162
+ );
4144
4163
  }
4145
4164
  };
4146
- const maybeUnNameColumn = (column, isSubQuery) => {
4147
- return isSubQuery && column?.data.name ? setColumnData(column, "name", void 0) : column;
4165
+ const mapSubSelectColumn = (column, isSubQuery) => {
4166
+ if (!isSubQuery || !column || !column.data.name && !column.data.explicitSelect) {
4167
+ return column;
4168
+ }
4169
+ const cloned = Object.create(column);
4170
+ cloned.data = { ...column.data, name: void 0, explicitSelect: void 0 };
4171
+ return cloned;
4148
4172
  };
4149
4173
  function _querySelect(q, args) {
4150
4174
  var _a;