pqb 0.51.2 → 0.51.3

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
@@ -380,7 +380,10 @@ interface CommonQueryData {
380
380
  aliases: string[];
381
381
  };
382
382
  selectAllColumns?: string[];
383
- selectableShape: RecordUnknown;
383
+ /**
384
+ * Subset of the `shape` that only includes columns with no `data.explicitSelect`.
385
+ */
386
+ selectAllShape: RecordUnknown;
384
387
  /**
385
388
  * column type for query with 'value' or 'valueOrThrow' return type
386
389
  * Is needed in {@link getShapeFromSelect} to get shape of sub-select that returns a single value.
package/dist/index.js CHANGED
@@ -4232,9 +4232,6 @@ const setParserForSelectedString = (query, arg, as, columnAs, columnAlias) => {
4232
4232
  return arg;
4233
4233
  };
4234
4234
  const selectColumn = (query, q, key, columnAs, columnAlias) => {
4235
- if (columnAlias === "pluck") {
4236
- throw new Error("?");
4237
- }
4238
4235
  if (columnAs && q.parsers) {
4239
4236
  const parser = q.parsers[key];
4240
4237
  if (parser) orchidCore.setObjectValueImmutable(q, "parsers", columnAs, parser);
@@ -4271,7 +4268,9 @@ const getShapeFromSelect = (q, isSubQuery) => {
4271
4268
  result = {};
4272
4269
  for (const key in shape) {
4273
4270
  const column = shape[key];
4274
- result[key] = column.data.name ? orchidCore.setColumnData(column, "name", void 0) : column;
4271
+ if (!column.data.explicitSelect) {
4272
+ result[key] = column.data.name ? orchidCore.setColumnData(column, "name", void 0) : column;
4273
+ }
4275
4274
  }
4276
4275
  } else {
4277
4276
  result = shape;
@@ -4331,10 +4330,12 @@ const addColumnToShapeFromSelect = (q, arg, shape, query, result, isSubQuery, ke
4331
4330
  }
4332
4331
  } else if (arg === "*") {
4333
4332
  for (const key2 in shape) {
4334
- result[key2] = mapSubSelectColumn(
4335
- shape[key2],
4336
- isSubQuery
4337
- );
4333
+ if (!shape[key2].data.explicitSelect) {
4334
+ result[key2] = mapSubSelectColumn(
4335
+ shape[key2],
4336
+ isSubQuery
4337
+ );
4338
+ }
4338
4339
  }
4339
4340
  } else {
4340
4341
  result[key || arg] = mapSubSelectColumn(
@@ -4863,7 +4864,7 @@ const selectToSql = (ctx, table, query, quotedAs, hookSelect = query.hookSelect,
4863
4864
  if (hookSelect) {
4864
4865
  selected ?? (selected = {});
4865
4866
  selectedAs ?? (selectedAs = {});
4866
- for (const key in query.selectableShape) {
4867
+ for (const key in query.selectAllShape) {
4867
4868
  selected[key] = quotedAs;
4868
4869
  selectedAs[key] = key;
4869
4870
  }
@@ -5012,7 +5013,7 @@ function selectedObjectToSQL(ctx, quotedAs, item) {
5012
5013
  }
5013
5014
  const selectAllSql = (query, quotedAs, jsonList) => {
5014
5015
  if (jsonList) {
5015
- Object.assign(jsonList, query.selectableShape);
5016
+ Object.assign(jsonList, query.selectAllShape);
5016
5017
  }
5017
5018
  return query.join?.length ? query.selectAllColumns?.map((item) => `${quotedAs}.${item}`).join(", ") || `${quotedAs}.*` : query.selectAllColumns?.join(", ") || "*";
5018
5019
  };
@@ -11812,7 +11813,7 @@ class ExpressionMethods {
11812
11813
  column(name) {
11813
11814
  const column = this.shape[name];
11814
11815
  return new ColumnRefExpression(
11815
- column,
11816
+ column || UnknownColumn.instance,
11816
11817
  name
11817
11818
  );
11818
11819
  }
@@ -11854,12 +11855,12 @@ class ExpressionMethods {
11854
11855
  if (table === as) {
11855
11856
  column = shape[col];
11856
11857
  } else {
11857
- column = q.q.joinedShapes[table][col];
11858
+ column = q.q.joinedShapes?.[table][col];
11858
11859
  }
11859
11860
  } else {
11860
11861
  column = shape[arg];
11861
11862
  }
11862
- return new RefExpression(column, q, arg);
11863
+ return new RefExpression(column || UnknownColumn.instance, q, arg);
11863
11864
  }
11864
11865
  val(value) {
11865
11866
  return new orchidCore.ValExpression(value);
@@ -12739,7 +12740,7 @@ const parseIndexOrExclude = (item) => {
12739
12740
 
12740
12741
  const anyShape = {};
12741
12742
  class Db extends QueryMethods {
12742
- constructor(adapter, queryBuilder, table = void 0, shape = anyShape, columnTypes, transactionStorage, options, tableData = orchidCore.emptyObject) {
12743
+ constructor(adapter, queryBuilder, table = void 0, shape = anyShape, columnTypes, transactionStorage, options, tableData = {}) {
12743
12744
  super();
12744
12745
  this.adapter = adapter;
12745
12746
  this.queryBuilder = queryBuilder;
@@ -12833,26 +12834,21 @@ class Db extends QueryMethods {
12833
12834
  );
12834
12835
  this.columns = columns;
12835
12836
  if (options.computed) applyComputedColumns(this, options.computed);
12836
- const selectableShape = this.q.selectableShape = {};
12837
12837
  if (prepareSelectAll) {
12838
+ const selectAllShape = this.q.selectAllShape = {};
12838
12839
  const list = [];
12839
12840
  for (const key in shape) {
12840
12841
  const column = shape[key];
12841
- if (!column.data.explicitSelect && !(column instanceof VirtualColumn)) {
12842
+ if (!column.data.explicitSelect) {
12842
12843
  list.push(
12843
12844
  column.data.name ? `"${column.data.name}" "${key}"` : `"${key}"`
12844
12845
  );
12845
- selectableShape[key] = column;
12846
+ selectAllShape[key] = column;
12846
12847
  }
12847
12848
  }
12848
12849
  this.q.selectAllColumns = list;
12849
12850
  } else {
12850
- for (const key in shape) {
12851
- const column = shape[key];
12852
- if (column instanceof VirtualColumn) {
12853
- selectableShape[key] = column;
12854
- }
12855
- }
12851
+ this.q.selectAllShape = shape;
12856
12852
  }
12857
12853
  if (modifyQuery) {
12858
12854
  for (const cb of modifyQuery) {