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.mjs CHANGED
@@ -4230,9 +4230,6 @@ const setParserForSelectedString = (query, arg, as, columnAs, columnAlias) => {
4230
4230
  return arg;
4231
4231
  };
4232
4232
  const selectColumn = (query, q, key, columnAs, columnAlias) => {
4233
- if (columnAlias === "pluck") {
4234
- throw new Error("?");
4235
- }
4236
4233
  if (columnAs && q.parsers) {
4237
4234
  const parser = q.parsers[key];
4238
4235
  if (parser) setObjectValueImmutable(q, "parsers", columnAs, parser);
@@ -4269,7 +4266,9 @@ const getShapeFromSelect = (q, isSubQuery) => {
4269
4266
  result = {};
4270
4267
  for (const key in shape) {
4271
4268
  const column = shape[key];
4272
- result[key] = column.data.name ? setColumnData(column, "name", void 0) : column;
4269
+ if (!column.data.explicitSelect) {
4270
+ result[key] = column.data.name ? setColumnData(column, "name", void 0) : column;
4271
+ }
4273
4272
  }
4274
4273
  } else {
4275
4274
  result = shape;
@@ -4329,10 +4328,12 @@ const addColumnToShapeFromSelect = (q, arg, shape, query, result, isSubQuery, ke
4329
4328
  }
4330
4329
  } else if (arg === "*") {
4331
4330
  for (const key2 in shape) {
4332
- result[key2] = mapSubSelectColumn(
4333
- shape[key2],
4334
- isSubQuery
4335
- );
4331
+ if (!shape[key2].data.explicitSelect) {
4332
+ result[key2] = mapSubSelectColumn(
4333
+ shape[key2],
4334
+ isSubQuery
4335
+ );
4336
+ }
4336
4337
  }
4337
4338
  } else {
4338
4339
  result[key || arg] = mapSubSelectColumn(
@@ -4861,7 +4862,7 @@ const selectToSql = (ctx, table, query, quotedAs, hookSelect = query.hookSelect,
4861
4862
  if (hookSelect) {
4862
4863
  selected ?? (selected = {});
4863
4864
  selectedAs ?? (selectedAs = {});
4864
- for (const key in query.selectableShape) {
4865
+ for (const key in query.selectAllShape) {
4865
4866
  selected[key] = quotedAs;
4866
4867
  selectedAs[key] = key;
4867
4868
  }
@@ -5010,7 +5011,7 @@ function selectedObjectToSQL(ctx, quotedAs, item) {
5010
5011
  }
5011
5012
  const selectAllSql = (query, quotedAs, jsonList) => {
5012
5013
  if (jsonList) {
5013
- Object.assign(jsonList, query.selectableShape);
5014
+ Object.assign(jsonList, query.selectAllShape);
5014
5015
  }
5015
5016
  return query.join?.length ? query.selectAllColumns?.map((item) => `${quotedAs}.${item}`).join(", ") || `${quotedAs}.*` : query.selectAllColumns?.join(", ") || "*";
5016
5017
  };
@@ -11810,7 +11811,7 @@ class ExpressionMethods {
11810
11811
  column(name) {
11811
11812
  const column = this.shape[name];
11812
11813
  return new ColumnRefExpression(
11813
- column,
11814
+ column || UnknownColumn.instance,
11814
11815
  name
11815
11816
  );
11816
11817
  }
@@ -11852,12 +11853,12 @@ class ExpressionMethods {
11852
11853
  if (table === as) {
11853
11854
  column = shape[col];
11854
11855
  } else {
11855
- column = q.q.joinedShapes[table][col];
11856
+ column = q.q.joinedShapes?.[table][col];
11856
11857
  }
11857
11858
  } else {
11858
11859
  column = shape[arg];
11859
11860
  }
11860
- return new RefExpression(column, q, arg);
11861
+ return new RefExpression(column || UnknownColumn.instance, q, arg);
11861
11862
  }
11862
11863
  val(value) {
11863
11864
  return new ValExpression(value);
@@ -12737,7 +12738,7 @@ const parseIndexOrExclude = (item) => {
12737
12738
 
12738
12739
  const anyShape = {};
12739
12740
  class Db extends QueryMethods {
12740
- constructor(adapter, queryBuilder, table = void 0, shape = anyShape, columnTypes, transactionStorage, options, tableData = emptyObject) {
12741
+ constructor(adapter, queryBuilder, table = void 0, shape = anyShape, columnTypes, transactionStorage, options, tableData = {}) {
12741
12742
  super();
12742
12743
  this.adapter = adapter;
12743
12744
  this.queryBuilder = queryBuilder;
@@ -12831,26 +12832,21 @@ class Db extends QueryMethods {
12831
12832
  );
12832
12833
  this.columns = columns;
12833
12834
  if (options.computed) applyComputedColumns(this, options.computed);
12834
- const selectableShape = this.q.selectableShape = {};
12835
12835
  if (prepareSelectAll) {
12836
+ const selectAllShape = this.q.selectAllShape = {};
12836
12837
  const list = [];
12837
12838
  for (const key in shape) {
12838
12839
  const column = shape[key];
12839
- if (!column.data.explicitSelect && !(column instanceof VirtualColumn)) {
12840
+ if (!column.data.explicitSelect) {
12840
12841
  list.push(
12841
12842
  column.data.name ? `"${column.data.name}" "${key}"` : `"${key}"`
12842
12843
  );
12843
- selectableShape[key] = column;
12844
+ selectAllShape[key] = column;
12844
12845
  }
12845
12846
  }
12846
12847
  this.q.selectAllColumns = list;
12847
12848
  } else {
12848
- for (const key in shape) {
12849
- const column = shape[key];
12850
- if (column instanceof VirtualColumn) {
12851
- selectableShape[key] = column;
12852
- }
12853
- }
12849
+ this.q.selectAllShape = shape;
12854
12850
  }
12855
12851
  if (modifyQuery) {
12856
12852
  for (const cb of modifyQuery) {