pqb 0.48.5 → 0.48.6

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 CHANGED
@@ -373,7 +373,7 @@ interface CommonQueryData {
373
373
  aliases: string[];
374
374
  };
375
375
  selectAllColumns?: string[];
376
- selectAllKeys?: RecordUnknown;
376
+ selectableShape: RecordUnknown;
377
377
  /**
378
378
  * column type for query with 'value' or 'valueOrThrow' return type
379
379
  * Is needed in {@link getShapeFromSelect} to get shape of sub-select that returns a single value.
package/dist/index.js CHANGED
@@ -4337,14 +4337,14 @@ function queryFrom(self, arg) {
4337
4337
  data.batchParsers = q.q.batchParsers;
4338
4338
  }
4339
4339
  data.from = arg;
4340
- data.selectAllColumns = data.selectAllKeys = data.scopes = void 0;
4340
+ data.selectAllColumns = data.scopes = void 0;
4341
4341
  return self;
4342
4342
  }
4343
4343
  function queryFromSql(self, args) {
4344
4344
  const data = self.q;
4345
4345
  data.as || (data.as = "t");
4346
4346
  data.from = sqlQueryArgsToExpression(args);
4347
- data.selectAllColumns = data.selectAllKeys = void 0;
4347
+ data.selectAllColumns = void 0;
4348
4348
  return self;
4349
4349
  }
4350
4350
  class FromMethods {
@@ -4816,7 +4816,7 @@ const selectToSql = (ctx, table, query, quotedAs, hookSelect = query.hookSelect,
4816
4816
  if (item === "*") {
4817
4817
  if (hookSelect) {
4818
4818
  selected ?? (selected = {});
4819
- for (const key in query.selectAllKeys || query.shape) {
4819
+ for (const key in query.selectableShape) {
4820
4820
  selected[key] = quotedAs;
4821
4821
  }
4822
4822
  }
@@ -4942,10 +4942,7 @@ function selectedObjectToSQL(ctx, quotedAs, item) {
4942
4942
  }
4943
4943
  const selectAllSql = (query, quotedAs, jsonList) => {
4944
4944
  if (jsonList) {
4945
- Object.assign(
4946
- jsonList,
4947
- query.selectAllKeys || query.shape
4948
- );
4945
+ Object.assign(jsonList, query.selectableShape);
4949
4946
  }
4950
4947
  return query.join?.length ? query.selectAllColumns?.map((item) => `${quotedAs}.${item}`).join(", ") || `${quotedAs}.*` : query.selectAllColumns?.join(", ") || "*";
4951
4948
  };
@@ -10249,7 +10246,7 @@ const mergableObjects = /* @__PURE__ */ new Set([
10249
10246
  "joinedBatchParsers",
10250
10247
  "selectedComputeds"
10251
10248
  ]);
10252
- const dontMergeArrays = /* @__PURE__ */ new Set(["selectAllColumns", "selectAllKeys"]);
10249
+ const dontMergeArrays = /* @__PURE__ */ new Set(["selectAllColumns"]);
10253
10250
  class MergeQueryMethods {
10254
10251
  merge(q) {
10255
10252
  const query = _clone(this);
@@ -12751,20 +12748,26 @@ class Db extends QueryMethods {
12751
12748
  );
12752
12749
  this.columns = columns;
12753
12750
  if (options.computed) applyComputedColumns(this, options.computed);
12751
+ const selectableShape = this.q.selectableShape = {};
12754
12752
  if (prepareSelectAll) {
12755
12753
  const list = [];
12756
- const keys = {};
12757
12754
  for (const key in shape) {
12758
12755
  const column = shape[key];
12759
- if (!column.data.explicitSelect) {
12756
+ if (!column.data.explicitSelect && !(column instanceof VirtualColumn)) {
12760
12757
  list.push(
12761
12758
  column.data.name ? `"${column.data.name}" "${key}"` : `"${key}"`
12762
12759
  );
12763
- keys[key] = column;
12760
+ selectableShape[key] = column;
12764
12761
  }
12765
12762
  }
12766
12763
  this.q.selectAllColumns = list;
12767
- this.q.selectAllKeys = keys;
12764
+ } else {
12765
+ for (const key in shape) {
12766
+ const column = shape[key];
12767
+ if (column instanceof VirtualColumn) {
12768
+ selectableShape[key] = column;
12769
+ }
12770
+ }
12768
12771
  }
12769
12772
  if (modifyQuery) {
12770
12773
  for (const cb of modifyQuery) {