typeorm 0.3.26 → 0.3.27-dev.1f90467

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.
@@ -8,6 +8,11 @@ export interface VirtualColumnOptions {
8
8
  * Column type. Must be one of the value from the ColumnTypes class.
9
9
  */
10
10
  type?: ColumnType;
11
+ /**
12
+ * Indicates if column is always selected by QueryBuilder and find operations.
13
+ * Default value is "true".
14
+ */
15
+ select?: boolean;
11
16
  /**
12
17
  * Return type of HSTORE column.
13
18
  * Returns value as string or as object.
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/decorator/options/VirtualColumnOptions.ts"],"names":[],"mappings":"","file":"VirtualColumnOptions.js","sourcesContent":["import { ColumnType } from \"../../driver/types/ColumnTypes\"\nimport { ValueTransformer } from \"./ValueTransformer\"\n\n/**\n * Describes all calculated column's options.\n */\nexport interface VirtualColumnOptions {\n /**\n * Column type. Must be one of the value from the ColumnTypes class.\n */\n type?: ColumnType\n\n /**\n * Return type of HSTORE column.\n * Returns value as string or as object.\n */\n hstoreType?: \"object\" | \"string\"\n\n /**\n * Query to be used to populate the column data. This query is used when generating the relational db script.\n * The query function is called with the current entities alias either defined by the Entity Decorator or automatically\n * @See https://typeorm.io/decorator-reference#virtualcolumn for more details.\n */\n query: (alias: string) => string\n\n /**\n * Specifies a value transformer(s) that is to be used to unmarshal\n * this column when reading from the database.\n */\n transformer?: ValueTransformer | ValueTransformer[]\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../browser/src/decorator/options/VirtualColumnOptions.ts"],"names":[],"mappings":"","file":"VirtualColumnOptions.js","sourcesContent":["import { ColumnType } from \"../../driver/types/ColumnTypes\"\nimport { ValueTransformer } from \"./ValueTransformer\"\n\n/**\n * Describes all calculated column's options.\n */\nexport interface VirtualColumnOptions {\n /**\n * Column type. Must be one of the value from the ColumnTypes class.\n */\n type?: ColumnType\n\n /**\n * Indicates if column is always selected by QueryBuilder and find operations.\n * Default value is \"true\".\n */\n select?: boolean\n\n /**\n * Return type of HSTORE column.\n * Returns value as string or as object.\n */\n hstoreType?: \"object\" | \"string\"\n\n /**\n * Query to be used to populate the column data. This query is used when generating the relational db script.\n * The query function is called with the current entities alias either defined by the Entity Decorator or automatically\n * @See https://typeorm.io/decorator-reference#virtualcolumn for more details.\n */\n query: (alias: string) => string\n\n /**\n * Specifies a value transformer(s) that is to be used to unmarshal\n * this column when reading from the database.\n */\n transformer?: ValueTransformer | ValueTransformer[]\n}\n"],"sourceRoot":"../.."}
@@ -904,6 +904,11 @@ export class SelectQueryBuilder extends QueryBuilder {
904
904
  const hasOffset = this.expressionMap.offset !== undefined &&
905
905
  this.expressionMap.offset !== null &&
906
906
  this.expressionMap.offset > 0;
907
+ if (entitiesAndRaw.entities.length === 0 && (hasSkip || hasOffset)) {
908
+ // when skip or offset were used and no results found, we need to execute a full count
909
+ // (the given offset may have exceeded the actual number of rows)
910
+ return undefined;
911
+ }
907
912
  // offset overrides skip when no join is defined
908
913
  const previousResults = hasOffset
909
914
  ? this.expressionMap.offset
@@ -1667,12 +1672,9 @@ export class SelectQueryBuilder extends QueryBuilder {
1667
1672
  return finalSelects;
1668
1673
  }
1669
1674
  findEntityColumnSelects(aliasName, metadata) {
1670
- const mainSelect = this.expressionMap.selects.find((select) => select.selection === aliasName);
1671
- if (mainSelect)
1672
- return [mainSelect];
1673
- return this.expressionMap.selects.filter((select) => {
1674
- return metadata.columns.some((column) => select.selection === aliasName + "." + column.propertyPath);
1675
- });
1675
+ return this.expressionMap.selects.filter((select) => select.selection === aliasName ||
1676
+ metadata.columns.some((column) => select.selection ===
1677
+ aliasName + "." + column.propertyPath));
1676
1678
  }
1677
1679
  computeCountExpression() {
1678
1680
  const mainAlias = this.expressionMap.mainAlias.name; // todo: will this work with "fromTableName"?