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AI,CAAC;IAChB,CAAC;IAED;;OAEG;IACO,4CAAe,GAAzB,UAA0B,GAAQ;QAC9B,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI;YAC5D,OAAO,GAAG,CAAC;QAEf,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IAED;;OAEG;IACO,8CAAiB,GAA3B;QACI,OAAO,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC1E,CAAC;IAEL,yBAAC;AAAD,CAx3DA,AAw3DC,CAx3D+C,YAAY,GAw3D3D","file":"SelectQueryBuilder.js","sourcesContent":["import {RawSqlResultsToEntityTransformer} from \"./transformer/RawSqlResultsToEntityTransformer\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {SqlServerDriver} from \"../driver/sqlserver/SqlServerDriver\";\nimport {PessimisticLockTransactionRequiredError} from \"../error/PessimisticLockTransactionRequiredError\";\nimport {NoVersionOrUpdateDateColumnError} from \"../error/NoVersionOrUpdateDateColumnError\";\nimport {OptimisticLockVersionMismatchError} from \"../error/OptimisticLockVersionMismatchError\";\nimport {OptimisticLockCanNotBeUsedError} from \"../error/OptimisticLockCanNotBeUsedError\";\nimport {JoinAttribute} from \"./JoinAttribute\";\nimport {RelationIdAttribute} from \"./relation-id/RelationIdAttribute\";\nimport {RelationCountAttribute} from \"./relation-count/RelationCountAttribute\";\nimport {RelationIdLoader} from \"./relation-id/RelationIdLoader\";\nimport {RelationIdMetadataToAttributeTransformer} from \"./relation-id/RelationIdMetadataToAttributeTransformer\";\nimport {RelationCountLoader} from \"./relation-count/RelationCountLoader\";\nimport {RelationCountMetadataToAttributeTransformer} from \"./relation-count/RelationCountMetadataToAttributeTransformer\";\nimport {QueryBuilder} from \"./QueryBuilder\";\nimport {ReadStream} from \"../platform/PlatformTools\";\nimport {LockNotSupportedOnGivenDriverError} from \"../error/LockNotSupportedOnGivenDriverError\";\nimport {MysqlDriver} from \"../driver/mysql/MysqlDriver\";\nimport {PostgresDriver} from \"../driver/postgres/PostgresDriver\";\nimport {OracleDriver} from \"../driver/oracle/OracleDriver\";\nimport {SelectQuery} from \"./SelectQuery\";\nimport {EntityMetadata} from \"../metadata/EntityMetadata\";\nimport {ColumnMetadata} from \"../metadata/ColumnMetadata\";\nimport {OrderByCondition} from \"../find-options/OrderByCondition\";\nimport {QueryExpressionMap} from \"./QueryExpressionMap\";\nimport {ObjectType} from \"../common/ObjectType\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {WhereExpression} from \"./WhereExpression\";\nimport {Brackets} from \"./Brackets\";\nimport {AbstractSqliteDriver} from \"../driver/sqlite-abstract/AbstractSqliteDriver\";\nimport {QueryResultCacheOptions} from \"../cache/QueryResultCacheOptions\";\nimport {OffsetWithoutLimitNotSupportedError} from \"../error/OffsetWithoutLimitNotSupportedError\";\nimport {BroadcasterResult} from \"../subscriber/BroadcasterResult\";\nimport {SelectQueryBuilderOption} from \"./SelectQueryBuilderOption\";\nimport {ObjectUtils} from \"../util/ObjectUtils\";\nimport {DriverUtils} from \"../driver/DriverUtils\";\n\n/**\n * Allows to build complex sql queries in a fashion way and execute those queries.\n */\nexport class SelectQueryBuilder<Entity> extends QueryBuilder<Entity> implements WhereExpression {\n\n // -------------------------------------------------------------------------\n // Public Implemented Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets generated sql query without parameters being replaced.\n */\n getQuery(): string {\n let sql = this.createSelectExpression();\n sql += this.createJoinExpression();\n sql += this.createWhereExpression();\n sql += this.createGroupByExpression();\n sql += this.createHavingExpression();\n sql += this.createOrderByExpression();\n sql += this.createLimitOffsetExpression();\n sql += this.createLockExpression();\n sql = sql.trim();\n if (this.expressionMap.subQuery)\n sql = \"(\" + sql + \")\";\n return sql;\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a subquery - query that can be used inside other queries.\n */\n subQuery(): SelectQueryBuilder<any> {\n const qb = this.createQueryBuilder();\n qb.expressionMap.subQuery = true;\n qb.expressionMap.parentQueryBuilder = this;\n return qb;\n }\n\n /**\n * Creates SELECT query.\n * Replaces all previous selections if they exist.\n */\n select(): this;\n\n /**\n * Creates SELECT query.\n * Replaces all previous selections if they exist.\n */\n select(selection: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, selectionAliasName?: string): this;\n\n /**\n * Creates SELECT query and selects given data.\n * Replaces all previous selections if they exist.\n */\n select(selection: string, selectionAliasName?: string): this;\n\n /**\n * Creates SELECT query and selects given data.\n * Replaces all previous selections if they exist.\n */\n select(selection: string[]): this;\n\n /**\n * Creates SELECT query and selects given data.\n * Replaces all previous selections if they exist.\n */\n select(selection?: string|string[]|((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>), selectionAliasName?: string): SelectQueryBuilder<Entity> {\n this.expressionMap.queryType = \"select\";\n if (selection instanceof Array) {\n this.expressionMap.selects = selection.map(selection => ({ selection: selection }));\n\n } else if (selection instanceof Function) {\n const subQueryBuilder = selection(this.subQuery());\n this.setParameters(subQueryBuilder.getParameters());\n this.expressionMap.selects.push({ selection: subQueryBuilder.getQuery(), aliasName: selectionAliasName });\n\n } else if (selection) {\n this.expressionMap.selects = [{ selection: selection, aliasName: selectionAliasName }];\n }\n\n return this;\n }\n\n /**\n * Adds new selection to the SELECT query.\n */\n addSelect(selection: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, selectionAliasName?: string): this;\n\n /**\n * Adds new selection to the SELECT query.\n */\n addSelect(selection: string, selectionAliasName?: string): this;\n\n /**\n * Adds new selection to the SELECT query.\n */\n addSelect(selection: string[]): this;\n\n /**\n * Adds new selection to the SELECT query.\n */\n addSelect(selection: string|string[]|((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>), selectionAliasName?: string): this {\n if (!selection)\n return this;\n\n if (selection instanceof Array) {\n this.expressionMap.selects = this.expressionMap.selects.concat(selection.map(selection => ({ selection: selection })));\n\n } else if (selection instanceof Function) {\n const subQueryBuilder = selection(this.subQuery());\n this.setParameters(subQueryBuilder.getParameters());\n this.expressionMap.selects.push({ selection: subQueryBuilder.getQuery(), aliasName: selectionAliasName });\n\n } else if (selection) {\n this.expressionMap.selects.push({ selection: selection, aliasName: selectionAliasName });\n }\n\n return this;\n }\n\n /**\n * Specifies FROM which entity's table select/update/delete will be executed.\n * Also sets a main string alias of the selection data.\n * Removes all previously set from-s.\n */\n from<T>(entityTarget: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, aliasName: string): SelectQueryBuilder<T>;\n\n /**\n * Specifies FROM which entity's table select/update/delete will be executed.\n * Also sets a main string alias of the selection data.\n * Removes all previously set from-s.\n */\n from<T>(entityTarget: ObjectType<T>|string, aliasName: string): SelectQueryBuilder<T>;\n\n /**\n * Specifies FROM which entity's table select/update/delete will be executed.\n * Also sets a main string alias of the selection data.\n * Removes all previously set from-s.\n */\n from<T>(entityTarget: ObjectType<T>|string|((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>), aliasName: string): SelectQueryBuilder<T> {\n const mainAlias = this.createFromAlias(entityTarget, aliasName);\n this.expressionMap.setMainAlias(mainAlias);\n return (this as any) as SelectQueryBuilder<T>;\n }\n\n /**\n * Specifies FROM which entity's table select/update/delete will be executed.\n * Also sets a main string alias of the selection data.\n */\n addFrom<T>(entityTarget: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, aliasName: string): SelectQueryBuilder<T>;\n\n /**\n * Specifies FROM which entity's table select/update/delete will be executed.\n * Also sets a main string alias of the selection data.\n */\n addFrom<T>(entityTarget: ObjectType<T>|string, aliasName: string): SelectQueryBuilder<T>;\n\n /**\n * Specifies FROM which entity's table select/update/delete will be executed.\n * Also sets a main string alias of the selection data.\n */\n addFrom<T>(entityTarget: ObjectType<T>|string|((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>), aliasName: string): SelectQueryBuilder<T> {\n const alias = this.createFromAlias(entityTarget, aliasName);\n if (!this.expressionMap.mainAlias)\n this.expressionMap.setMainAlias(alias);\n\n return (this as any) as SelectQueryBuilder<T>;\n }\n\n /**\n * INNER JOINs (without selection) given subquery.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoin(subQueryFactory: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * INNER JOINs (without selection) entity's property.\n * Given entity property should be a relation.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoin(property: string, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * INNER JOINs (without selection) given entity's table.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoin(entity: Function|string, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * INNER JOINs (without selection) given table.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoin(tableName: string, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * INNER JOINs (without selection).\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoin(entityOrProperty: Function|string|((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>), alias: string, condition: string = \"\", parameters?: ObjectLiteral): this {\n this.join(\"INNER\", entityOrProperty, alias, condition, parameters);\n return this;\n }\n\n /**\n * LEFT JOINs (without selection) given subquery.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoin(subQueryFactory: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * LEFT JOINs (without selection) entity's property.\n * Given entity property should be a relation.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoin(property: string, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * LEFT JOINs (without selection) entity's table.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoin(entity: Function|string, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * LEFT JOINs (without selection) given table.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoin(tableName: string, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * LEFT JOINs (without selection).\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoin(entityOrProperty: Function|string|((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>), alias: string, condition: string = \"\", parameters?: ObjectLiteral): this {\n this.join(\"LEFT\", entityOrProperty, alias, condition, parameters);\n return this;\n }\n\n /**\n * INNER JOINs given subquery and adds all selection properties to SELECT..\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoinAndSelect(subQueryFactory: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * INNER JOINs entity's property and adds all selection properties to SELECT.\n * Given entity property should be a relation.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoinAndSelect(property: string, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * INNER JOINs entity and adds all selection properties to SELECT.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoinAndSelect(entity: Function|string, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * INNER JOINs table and adds all selection properties to SELECT.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoinAndSelect(tableName: string, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * INNER JOINs and adds all selection properties to SELECT.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoinAndSelect(entityOrProperty: Function|string|((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>), alias: string, condition: string = \"\", parameters?: ObjectLiteral): this {\n this.addSelect(alias);\n this.innerJoin(entityOrProperty, alias, condition, parameters);\n return this;\n }\n\n /**\n * LEFT JOINs given subquery and adds all selection properties to SELECT..\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoinAndSelect(subQueryFactory: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * LEFT JOINs entity's property and adds all selection properties to SELECT.\n * Given entity property should be a relation.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoinAndSelect(property: string, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * LEFT JOINs entity and adds all selection properties to SELECT.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoinAndSelect(entity: Function|string, alias: string, condition: string, parameters?: ObjectLiteral): this;\n\n /**\n * LEFT JOINs table and adds all selection properties to SELECT.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoinAndSelect(tableName: string, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * LEFT JOINs and adds all selection properties to SELECT.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoinAndSelect(entityOrProperty: Function|string|((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>), alias: string, condition: string = \"\", parameters?: ObjectLiteral): this {\n this.addSelect(alias);\n this.leftJoin(entityOrProperty, alias, condition, parameters);\n return this;\n }\n\n /**\n * INNER JOINs given subquery, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there are multiple rows of selecting data, and mapped result will be an array.\n * Given entity property should be a relation.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoinAndMapMany(mapToProperty: string, subQueryFactory: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * INNER JOINs entity's property, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there are multiple rows of selecting data, and mapped result will be an array.\n * Given entity property should be a relation.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoinAndMapMany(mapToProperty: string, property: string, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * INNER JOINs entity's table, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there are multiple rows of selecting data, and mapped result will be an array.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoinAndMapMany(mapToProperty: string, entity: Function|string, alias: string, condition: string, parameters?: ObjectLiteral): this;\n\n /**\n * INNER JOINs table, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there are multiple rows of selecting data, and mapped result will be an array.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoinAndMapMany(mapToProperty: string, tableName: string, alias: string, condition: string, parameters?: ObjectLiteral): this;\n\n /**\n * INNER JOINs, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there are multiple rows of selecting data, and mapped result will be an array.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoinAndMapMany(mapToProperty: string, entityOrProperty: Function|string|((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>), alias: string, condition: string = \"\", parameters?: ObjectLiteral): this {\n this.addSelect(alias);\n this.join(\"INNER\", entityOrProperty, alias, condition, parameters, mapToProperty, true);\n return this;\n }\n\n /**\n * INNER JOINs given subquery, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there is a single row of selecting data, and mapped result will be a single selected value.\n * Given entity property should be a relation.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoinAndMapOne(mapToProperty: string, subQueryFactory: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * INNER JOINs entity's property, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there is a single row of selecting data, and mapped result will be a single selected value.\n * Given entity property should be a relation.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoinAndMapOne(mapToProperty: string, property: string, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * INNER JOINs entity's table, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there is a single row of selecting data, and mapped result will be a single selected value.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoinAndMapOne(mapToProperty: string, entity: Function|string, alias: string, condition: string, parameters?: ObjectLiteral): this;\n\n /**\n * INNER JOINs table, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there is a single row of selecting data, and mapped result will be a single selected value.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoinAndMapOne(mapToProperty: string, tableName: string, alias: string, condition: string, parameters?: ObjectLiteral): this;\n\n /**\n * INNER JOINs, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there is a single row of selecting data, and mapped result will be a single selected value.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n innerJoinAndMapOne(mapToProperty: string, entityOrProperty: Function|string|((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>), alias: string, condition: string = \"\", parameters?: ObjectLiteral): this {\n this.addSelect(alias);\n this.join(\"INNER\", entityOrProperty, alias, condition, parameters, mapToProperty, false);\n return this;\n }\n\n /**\n * LEFT JOINs given subquery, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there are multiple rows of selecting data, and mapped result will be an array.\n * Given entity property should be a relation.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoinAndMapMany(mapToProperty: string, subQueryFactory: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * LEFT JOINs entity's property, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there are multiple rows of selecting data, and mapped result will be an array.\n * Given entity property should be a relation.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoinAndMapMany(mapToProperty: string, property: string, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * LEFT JOINs entity's table, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there are multiple rows of selecting data, and mapped result will be an array.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoinAndMapMany(mapToProperty: string, entity: Function|string, alias: string, condition: string, parameters?: ObjectLiteral): this;\n\n /**\n * LEFT JOINs table, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there are multiple rows of selecting data, and mapped result will be an array.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoinAndMapMany(mapToProperty: string, tableName: string, alias: string, condition: string, parameters?: ObjectLiteral): this;\n\n /**\n * LEFT JOINs, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there are multiple rows of selecting data, and mapped result will be an array.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoinAndMapMany(mapToProperty: string, entityOrProperty: Function|string|((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>), alias: string, condition: string = \"\", parameters?: ObjectLiteral): this {\n this.addSelect(alias);\n this.join(\"LEFT\", entityOrProperty, alias, condition, parameters, mapToProperty, true);\n return this;\n }\n\n /**\n * LEFT JOINs given subquery, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there is a single row of selecting data, and mapped result will be a single selected value.\n * Given entity property should be a relation.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoinAndMapOne(mapToProperty: string, subQueryFactory: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * LEFT JOINs entity's property, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there is a single row of selecting data, and mapped result will be a single selected value.\n * Given entity property should be a relation.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoinAndMapOne(mapToProperty: string, property: string, alias: string, condition?: string, parameters?: ObjectLiteral): this;\n\n /**\n * LEFT JOINs entity's table, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there is a single row of selecting data, and mapped result will be a single selected value.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoinAndMapOne(mapToProperty: string, entity: Function|string, alias: string, condition: string, parameters?: ObjectLiteral): this;\n\n /**\n * LEFT JOINs table, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there is a single row of selecting data, and mapped result will be a single selected value.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoinAndMapOne(mapToProperty: string, tableName: string, alias: string, condition: string, parameters?: ObjectLiteral): this;\n\n /**\n * LEFT JOINs, SELECTs the data returned by a join and MAPs all that data to some entity's property.\n * This is extremely useful when you want to select some data and map it to some virtual property.\n * It will assume that there is a single row of selecting data, and mapped result will be a single selected value.\n * You also need to specify an alias of the joined data.\n * Optionally, you can add condition and parameters used in condition.\n */\n leftJoinAndMapOne(mapToProperty: string, entityOrProperty: Function|string|((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>), alias: string, condition: string = \"\", parameters?: ObjectLiteral): this {\n this.addSelect(alias);\n this.join(\"LEFT\", entityOrProperty, alias, condition, parameters, mapToProperty, false);\n return this;\n }\n\n /**\n */\n // selectAndMap(mapToProperty: string, property: string, aliasName: string, qbFactory: ((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>)): this;\n\n /**\n */\n // selectAndMap(mapToProperty: string, entity: Function|string, aliasName: string, qbFactory: ((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>)): this;\n\n /**\n */\n // selectAndMap(mapToProperty: string, tableName: string, aliasName: string, qbFactory: ((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>)): this;\n\n /**\n */\n // selectAndMap(mapToProperty: string, entityOrProperty: Function|string, aliasName: string, qbFactory: ((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>)): this {\n // const select = new SelectAttribute(this.expressionMap);\n // select.mapToProperty = mapToProperty;\n // select.entityOrProperty = entityOrProperty;\n // select.aliasName = aliasName;\n // select.qbFactory = qbFactory;\n // return this;\n // }\n\n /**\n * LEFT JOINs relation id and maps it into some entity's property.\n * Optionally, you can add condition and parameters used in condition.\n */\n loadRelationIdAndMap(mapToProperty: string, relationName: string, options?: { disableMixedMap?: boolean }): this;\n\n /**\n * LEFT JOINs relation id and maps it into some entity's property.\n * Optionally, you can add condition and parameters used in condition.\n */\n loadRelationIdAndMap(mapToProperty: string, relationName: string, alias: string, queryBuilderFactory: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>): this;\n\n /**\n * LEFT JOINs relation id and maps it into some entity's property.\n * Optionally, you can add condition and parameters used in condition.\n */\n loadRelationIdAndMap(mapToProperty: string,\n relationName: string,\n aliasNameOrOptions?: string|{ disableMixedMap?: boolean },\n queryBuilderFactory?: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>): this {\n\n const relationIdAttribute = new RelationIdAttribute(this.expressionMap);\n relationIdAttribute.mapToProperty = mapToProperty;\n relationIdAttribute.relationName = relationName;\n if (typeof aliasNameOrOptions === \"string\")\n relationIdAttribute.alias = aliasNameOrOptions;\n if (aliasNameOrOptions instanceof Object && (aliasNameOrOptions as any).disableMixedMap)\n relationIdAttribute.disableMixedMap = true;\n\n relationIdAttribute.queryBuilderFactory = queryBuilderFactory;\n this.expressionMap.relationIdAttributes.push(relationIdAttribute);\n\n if (relationIdAttribute.relation.junctionEntityMetadata) {\n this.expressionMap.createAlias({\n type: \"other\",\n name: relationIdAttribute.junctionAlias,\n metadata: relationIdAttribute.relation.junctionEntityMetadata\n });\n }\n return this;\n }\n\n /**\n * Counts number of entities of entity's relation and maps the value into some entity's property.\n * Optionally, you can add condition and parameters used in condition.\n */\n loadRelationCountAndMap(mapToProperty: string, relationName: string, aliasName?: string, queryBuilderFactory?: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>): this {\n const relationCountAttribute = new RelationCountAttribute(this.expressionMap);\n relationCountAttribute.mapToProperty = mapToProperty;\n relationCountAttribute.relationName = relationName;\n relationCountAttribute.alias = aliasName;\n relationCountAttribute.queryBuilderFactory = queryBuilderFactory;\n this.expressionMap.relationCountAttributes.push(relationCountAttribute);\n\n this.expressionMap.createAlias({\n type: \"other\",\n name: relationCountAttribute.junctionAlias\n });\n if (relationCountAttribute.relation.junctionEntityMetadata) {\n this.expressionMap.createAlias({\n type: \"other\",\n name: relationCountAttribute.junctionAlias,\n metadata: relationCountAttribute.relation.junctionEntityMetadata\n });\n }\n return this;\n }\n\n /**\n * Loads all relation ids for all relations of the selected entity.\n * All relation ids will be mapped to relation property themself.\n * If array of strings is given then loads only relation ids of the given properties.\n */\n loadAllRelationIds(options?: { relations?: string[], disableMixedMap?: boolean }): this { // todo: add skip relations\n this.expressionMap.mainAlias!.metadata.relations.forEach(relation => {\n if (options !== undefined && options.relations !== undefined && options.relations.indexOf(relation.propertyPath) === -1)\n return;\n\n this.loadRelationIdAndMap(\n this.expressionMap.mainAlias!.name + \".\" + relation.propertyPath,\n this.expressionMap.mainAlias!.name + \".\" + relation.propertyPath,\n options\n );\n });\n return this;\n }\n\n /**\n * Sets WHERE condition in the query builder.\n * If you had previously WHERE expression defined,\n * calling this function will override previously set WHERE conditions.\n * Additionally you can add parameters used in where expression.\n */\n where(where: Brackets|string|((qb: this) => string)|ObjectLiteral|ObjectLiteral[], parameters?: ObjectLiteral): this {\n this.expressionMap.wheres = []; // don't move this block below since computeWhereParameter can add where expressions\n const condition = this.computeWhereParameter(where);\n if (condition)\n this.expressionMap.wheres = [{ type: \"simple\", condition: condition }];\n if (parameters)\n this.setParameters(parameters);\n return this;\n }\n\n /**\n * Adds new AND WHERE condition in the query builder.\n * Additionally you can add parameters used in where expression.\n */\n andWhere(where: string|Brackets|((qb: this) => string), parameters?: ObjectLiteral): this {\n this.expressionMap.wheres.push({ type: \"and\", condition: this.computeWhereParameter(where) });\n if (parameters) this.setParameters(parameters);\n return this;\n }\n\n /**\n * Adds new OR WHERE condition in the query builder.\n * Additionally you can add parameters used in where expression.\n */\n orWhere(where: Brackets|string|((qb: this) => string), parameters?: ObjectLiteral): this {\n this.expressionMap.wheres.push({ type: \"or\", condition: this.computeWhereParameter(where) });\n if (parameters) this.setParameters(parameters);\n return this;\n }\n\n /**\n * Adds new AND WHERE with conditions for the given ids.\n *\n * Ids are mixed.\n * It means if you have single primary key you can pass a simple id values, for example [1, 2, 3].\n * If you have multiple primary keys you need to pass object with property names and values specified,\n * for example [{ firstId: 1, secondId: 2 }, { firstId: 2, secondId: 3 }, ...]\n */\n whereInIds(ids: any|any[]): this {\n return this.where(this.createWhereIdsExpression(ids));\n }\n\n /**\n * Adds new AND WHERE with conditions for the given ids.\n *\n * Ids are mixed.\n * It means if you have single primary key you can pass a simple id values, for example [1, 2, 3].\n * If you have multiple primary keys you need to pass object with property names and values specified,\n * for example [{ firstId: 1, secondId: 2 }, { firstId: 2, secondId: 3 }, ...]\n */\n andWhereInIds(ids: any|any[]): this {\n return this.andWhere(this.createWhereIdsExpression(ids));\n }\n\n /**\n * Adds new OR WHERE with conditions for the given ids.\n *\n * Ids are mixed.\n * It means if you have single primary key you can pass a simple id values, for example [1, 2, 3].\n * If you have multiple primary keys you need to pass object with property names and values specified,\n * for example [{ firstId: 1, secondId: 2 }, { firstId: 2, secondId: 3 }, ...]\n */\n orWhereInIds(ids: any|any[]): this {\n return this.orWhere(this.createWhereIdsExpression(ids));\n }\n\n /**\n * Sets HAVING condition in the query builder.\n * If you had previously HAVING expression defined,\n * calling this function will override previously set HAVING conditions.\n * Additionally you can add parameters used in where expression.\n */\n having(having: string, parameters?: ObjectLiteral): this {\n this.expressionMap.havings.push({ type: \"simple\", condition: having });\n if (parameters) this.setParameters(parameters);\n return this;\n }\n\n /**\n * Adds new AND HAVING condition in the query builder.\n * Additionally you can add parameters used in where expression.\n */\n andHaving(having: string, parameters?: ObjectLiteral): this {\n this.expressionMap.havings.push({ type: \"and\", condition: having });\n if (parameters) this.setParameters(parameters);\n return this;\n }\n\n /**\n * Adds new OR HAVING condition in the query builder.\n * Additionally you can add parameters used in where expression.\n */\n orHaving(having: string, parameters?: ObjectLiteral): this {\n this.expressionMap.havings.push({ type: \"or\", condition: having });\n if (parameters) this.setParameters(parameters);\n return this;\n }\n\n /**\n * Sets GROUP BY condition in the query builder.\n * If you had previously GROUP BY expression defined,\n * calling this function will override previously set GROUP BY conditions.\n */\n groupBy(): this;\n\n /**\n * Sets GROUP BY condition in the query builder.\n * If you had previously GROUP BY expression defined,\n * calling this function will override previously set GROUP BY conditions.\n */\n groupBy(groupBy: string): this;\n\n /**\n * Sets GROUP BY condition in the query builder.\n * If you had previously GROUP BY expression defined,\n * calling this function will override previously set GROUP BY conditions.\n */\n groupBy(groupBy?: string): this {\n if (groupBy) {\n this.expressionMap.groupBys = [groupBy];\n } else {\n this.expressionMap.groupBys = [];\n }\n return this;\n }\n\n /**\n * Adds GROUP BY condition in the query builder.\n */\n addGroupBy(groupBy: string): this {\n this.expressionMap.groupBys.push(groupBy);\n return this;\n }\n\n /**\n * Sets ORDER BY condition in the query builder.\n * If you had previously ORDER BY expression defined,\n * calling this function will override previously set ORDER BY conditions.\n *\n * Calling order by without order set will remove all previously set order bys.\n */\n orderBy(): this;\n\n /**\n * Sets ORDER BY condition in the query builder.\n * If you had previously ORDER BY expression defined,\n * calling this function will override previously set ORDER BY conditions.\n */\n orderBy(sort: string, order?: \"ASC\"|\"DESC\", nulls?: \"NULLS FIRST\"|\"NULLS LAST\"): this;\n\n /**\n * Sets ORDER BY condition in the query builder.\n * If you had previously ORDER BY expression defined,\n * calling this function will override previously set ORDER BY conditions.\n */\n orderBy(order: OrderByCondition): this;\n\n /**\n * Sets ORDER BY condition in the query builder.\n * If you had previously ORDER BY expression defined,\n * calling this function will override previously set ORDER BY conditions.\n */\n orderBy(sort?: string|OrderByCondition, order: \"ASC\"|\"DESC\" = \"ASC\", nulls?: \"NULLS FIRST\"|\"NULLS LAST\"): this {\n if (order !== undefined && order !== \"ASC\" && order !== \"DESC\")\n throw new Error(`SelectQueryBuilder.addOrderBy \"order\" can accept only \"ASC\" and \"DESC\" values.`);\n if (nulls !== undefined && nulls !== \"NULLS FIRST\" && nulls !== \"NULLS LAST\")\n throw new Error(`SelectQueryBuilder.addOrderBy \"nulls\" can accept only \"NULLS FIRST\" and \"NULLS LAST\" values.`);\n\n if (sort) {\n if (sort instanceof Object) {\n this.expressionMap.orderBys = sort as OrderByCondition;\n } else {\n if (nulls) {\n this.expressionMap.orderBys = { [sort as string]: { order, nulls } };\n } else {\n this.expressionMap.orderBys = { [sort as string]: order };\n }\n }\n } else {\n this.expressionMap.orderBys = {};\n }\n return this;\n }\n\n /**\n * Adds ORDER BY condition in the query builder.\n */\n addOrderBy(sort: string, order: \"ASC\"|\"DESC\" = \"ASC\", nulls?: \"NULLS FIRST\"|\"NULLS LAST\"): this {\n if (order !== undefined && order !== \"ASC\" && order !== \"DESC\")\n throw new Error(`SelectQueryBuilder.addOrderBy \"order\" can accept only \"ASC\" and \"DESC\" values.`);\n if (nulls !== undefined && nulls !== \"NULLS FIRST\" && nulls !== \"NULLS LAST\")\n throw new Error(`SelectQueryBuilder.addOrderBy \"nulls\" can accept only \"NULLS FIRST\" and \"NULLS LAST\" values.`);\n\n if (nulls) {\n this.expressionMap.orderBys[sort] = { order, nulls };\n } else {\n this.expressionMap.orderBys[sort] = order;\n }\n return this;\n }\n\n /**\n * Set's LIMIT - maximum number of rows to be selected.\n * NOTE that it may not work as you expect if you are using joins.\n * If you want to implement pagination, and you are having join in your query,\n * then use instead take method instead.\n */\n limit(limit?: number): this {\n this.expressionMap.limit = this.normalizeNumber(limit);\n if (this.expressionMap.limit !== undefined && isNaN(this.expressionMap.limit))\n throw new Error(`Provided \"limit\" value is not a number. Please provide a numeric value.`);\n\n return this;\n }\n\n /**\n * Set's OFFSET - selection offset.\n * NOTE that it may not work as you expect if you are using joins.\n * If you want to implement pagination, and you are having join in your query,\n * then use instead skip method instead.\n */\n offset(offset?: number): this {\n this.expressionMap.offset = this.normalizeNumber(offset);\n if (this.expressionMap.offset !== undefined && isNaN(this.expressionMap.offset))\n throw new Error(`Provided \"offset\" value is not a number. Please provide a numeric value.`);\n\n return this;\n }\n\n /**\n * Sets maximal number of entities to take.\n */\n take(take?: number): this {\n this.expressionMap.take = this.normalizeNumber(take);\n if (this.expressionMap.take !== undefined && isNaN(this.expressionMap.take))\n throw new Error(`Provided \"take\" value is not a number. Please provide a numeric value.`);\n\n return this;\n }\n\n /**\n * Sets number of entities to skip.\n */\n skip(skip?: number): this {\n this.expressionMap.skip = this.normalizeNumber(skip);\n if (this.expressionMap.skip !== undefined && isNaN(this.expressionMap.skip))\n throw new Error(`Provided \"skip\" value is not a number. Please provide a numeric value.`);\n\n return this;\n }\n\n /**\n * Sets locking mode.\n */\n setLock(lockMode: \"optimistic\", lockVersion: number): this;\n\n /**\n * Sets locking mode.\n */\n setLock(lockMode: \"optimistic\", lockVersion: Date): this;\n\n /**\n * Sets locking mode.\n */\n setLock(lockMode: \"pessimistic_read\"|\"pessimistic_write\"): this;\n\n /**\n * Sets locking mode.\n */\n setLock(lockMode: \"optimistic\"|\"pessimistic_read\"|\"pessimistic_write\", lockVersion?: number|Date): this {\n this.expressionMap.lockMode = lockMode;\n this.expressionMap.lockVersion = lockVersion;\n return this;\n\n }\n\n /**\n * Gets first raw result returned by execution of generated query builder sql.\n */\n async getRawOne(): Promise<any> {\n return (await this.getRawMany())[0];\n }\n\n /**\n * Gets all raw results returned by execution of generated query builder sql.\n */\n async getRawMany(): Promise<any[]> {\n if (this.expressionMap.lockMode === \"optimistic\")\n throw new OptimisticLockCanNotBeUsedError();\n\n this.expressionMap.queryEntity = false;\n const queryRunner = this.obtainQueryRunner();\n let transactionStartedByUs: boolean = false;\n try {\n\n // start transaction if it was enabled\n if (this.expressionMap.useTransaction === true && queryRunner.isTransactionActive === false) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n const results = await this.loadRawResults(queryRunner);\n\n // close transaction if we started it\n if (transactionStartedByUs) {\n await queryRunner.commitTransaction();\n }\n\n return results;\n\n } catch (error) {\n\n // rollback transaction if we started it\n if (transactionStartedByUs) {\n try {\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n throw error;\n\n } finally {\n if (queryRunner !== this.queryRunner) { // means we created our own query runner\n await queryRunner.release();\n }\n }\n }\n\n /**\n * Executes sql generated by query builder and returns object with raw results and entities created from them.\n */\n async getRawAndEntities(): Promise<{ entities: Entity[], raw: any[] }> {\n const queryRunner = this.obtainQueryRunner();\n let transactionStartedByUs: boolean = false;\n try {\n\n // start transaction if it was enabled\n if (this.expressionMap.useTransaction === true && queryRunner.isTransactionActive === false) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n this.expressionMap.queryEntity = true;\n const results = await this.executeEntitiesAndRawResults(queryRunner);\n\n // close transaction if we started it\n if (transactionStartedByUs) {\n await queryRunner.commitTransaction();\n }\n\n return results;\n\n } catch (error) {\n\n // rollback transaction if we started it\n if (transactionStartedByUs) {\n try {\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n throw error;\n\n } finally {\n if (queryRunner !== this.queryRunner) // means we created our own query runner\n await queryRunner.release();\n }\n }\n\n /**\n * Gets single entity returned by execution of generated query builder sql.\n */\n async getOne(): Promise<Entity|undefined> {\n const results = await this.getRawAndEntities();\n const result = results.entities[0] as any;\n\n if (result && this.expressionMap.lockMode === \"optimistic\" && this.expressionMap.lockVersion) {\n const metadata = this.expressionMap.mainAlias!.metadata;\n\n if (this.expressionMap.lockVersion instanceof Date) {\n const actualVersion = metadata.updateDateColumn!.getEntityValue(result); // what if columns arent set?\n if (actualVersion.getTime() !== this.expressionMap.lockVersion.getTime())\n throw new OptimisticLockVersionMismatchError(metadata.name, this.expressionMap.lockVersion, actualVersion);\n\n } else {\n const actualVersion = metadata.versionColumn!.getEntityValue(result); // what if columns arent set?\n if (actualVersion !== this.expressionMap.lockVersion)\n throw new OptimisticLockVersionMismatchError(metadata.name, this.expressionMap.lockVersion, actualVersion);\n }\n }\n\n return result;\n }\n\n /**\n * Gets entities returned by execution of generated query builder sql.\n */\n async getMany(): Promise<Entity[]> {\n if (this.expressionMap.lockMode === \"optimistic\")\n throw new OptimisticLockCanNotBeUsedError();\n\n const results = await this.getRawAndEntities();\n return results.entities;\n }\n\n /**\n * Gets count - number of entities selected by sql generated by this query builder.\n * Count excludes all limitations set by setFirstResult and setMaxResults methods call.\n */\n async getCount(): Promise<number> {\n if (this.expressionMap.lockMode === \"optimistic\")\n throw new OptimisticLockCanNotBeUsedError();\n\n const queryRunner = this.obtainQueryRunner();\n let transactionStartedByUs: boolean = false;\n try {\n\n // start transaction if it was enabled\n if (this.expressionMap.useTransaction === true && queryRunner.isTransactionActive === false) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n this.expressionMap.queryEntity = false;\n const results = await this.executeCountQuery(queryRunner);\n\n // close transaction if we started it\n if (transactionStartedByUs) {\n await queryRunner.commitTransaction();\n }\n\n return results;\n\n } catch (error) {\n\n // rollback transaction if we started it\n if (transactionStartedByUs) {\n try {\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n throw error;\n\n } finally {\n if (queryRunner !== this.queryRunner) // means we created our own query runner\n await queryRunner.release();\n }\n }\n\n /**\n * Executes built SQL query and returns entities and overall entities count (without limitation).\n * This method is useful to build pagination.\n */\n async getManyAndCount(): Promise<[Entity[], number]> {\n if (this.expressionMap.lockMode === \"optimistic\")\n throw new OptimisticLockCanNotBeUsedError();\n\n const queryRunner = this.obtainQueryRunner();\n let transactionStartedByUs: boolean = false;\n try {\n\n // start transaction if it was enabled\n if (this.expressionMap.useTransaction === true && queryRunner.isTransactionActive === false) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n this.expressionMap.queryEntity = true;\n const entitiesAndRaw = await this.executeEntitiesAndRawResults(queryRunner);\n this.expressionMap.queryEntity = false;\n const count = await this.executeCountQuery(queryRunner);\n const results: [Entity[], number] = [entitiesAndRaw.entities, count];\n\n // close transaction if we started it\n if (transactionStartedByUs) {\n await queryRunner.commitTransaction();\n }\n\n return results;\n\n } catch (error) {\n\n // rollback transaction if we started it\n if (transactionStartedByUs) {\n try {\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n throw error;\n\n } finally {\n if (queryRunner !== this.queryRunner) // means we created our own query runner\n await queryRunner.release();\n }\n }\n\n /**\n * Executes built SQL query and returns raw data stream.\n */\n async stream(): Promise<ReadStream> {\n this.expressionMap.queryEntity = false;\n const [sql, parameters] = this.getQueryAndParameters();\n const queryRunner = this.obtainQueryRunner();\n let transactionStartedByUs: boolean = false;\n try {\n\n // start transaction if it was enabled\n if (this.expressionMap.useTransaction === true && queryRunner.isTransactionActive === false) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n const releaseFn = () => {\n if (queryRunner !== this.queryRunner) // means we created our own query runner\n return queryRunner.release();\n return;\n };\n const results = queryRunner.stream(sql, parameters, releaseFn, releaseFn);\n\n // close transaction if we started it\n if (transactionStartedByUs) {\n await queryRunner.commitTransaction();\n }\n\n return results;\n\n } catch (error) {\n\n // rollback transaction if we started it\n if (transactionStartedByUs) {\n try {\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n throw error;\n\n } finally {\n if (queryRunner !== this.queryRunner) // means we created our own query runner\n await queryRunner.release();\n }\n }\n\n /**\n * Enables or disables query result caching.\n */\n cache(enabled: boolean): this;\n\n /**\n * Enables query result caching and sets in milliseconds in which cache will expire.\n * If not set then global caching time will be used.\n */\n cache(milliseconds: number): this;\n\n /**\n * Enables query result caching and sets cache id and milliseconds in which cache will expire.\n */\n cache(id: any, milliseconds?: number): this;\n\n /**\n * Enables or disables query result caching.\n */\n cache(enabledOrMillisecondsOrId: boolean|number|string, maybeMilliseconds?: number): this {\n\n if (typeof enabledOrMillisecondsOrId === \"boolean\") {\n this.expressionMap.cache = enabledOrMillisecondsOrId;\n\n } else if (typeof enabledOrMillisecondsOrId === \"number\") {\n this.expressionMap.cache = true;\n this.expressionMap.cacheDuration = enabledOrMillisecondsOrId;\n\n } else if (typeof enabledOrMillisecondsOrId === \"string\" || typeof enabledOrMillisecondsOrId === \"number\") {\n this.expressionMap.cache = true;\n this.expressionMap.cacheId = enabledOrMillisecondsOrId;\n }\n\n if (maybeMilliseconds) {\n this.expressionMap.cacheDuration = maybeMilliseconds;\n }\n\n return this;\n }\n\n /**\n * Sets extra options that can be used to configure how query builder works.\n */\n setOption(option: SelectQueryBuilderOption): this {\n this.expressionMap.options.push(option);\n return this;\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n protected join(direction: \"INNER\"|\"LEFT\",\n entityOrProperty: Function|string|((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>),\n aliasName: string,\n condition?: string,\n parameters?: ObjectLiteral,\n mapToProperty?: string,\n isMappingMany?: boolean): void {\n\n this.setParameters(parameters || {});\n\n const joinAttribute = new JoinAttribute(this.connection, this.expressionMap);\n joinAttribute.direction = direction;\n joinAttribute.mapToProperty = mapToProperty;\n joinAttribute.isMappingMany = isMappingMany;\n joinAttribute.entityOrProperty = entityOrProperty; // relationName\n joinAttribute.condition = condition; // joinInverseSideCondition\n // joinAttribute.junctionAlias = joinAttribute.relation.isOwning ? parentAlias + \"_\" + destinationTableAlias : destinationTableAlias + \"_\" + parentAlias;\n this.expressionMap.joinAttributes.push(joinAttribute);\n\n if (joinAttribute.metadata) {\n\n // todo: find and set metadata right there?\n joinAttribute.alias = this.expressionMap.createAlias({\n type: \"join\",\n name: aliasName,\n metadata: joinAttribute.metadata\n });\n if (joinAttribute.relation && joinAttribute.relation.junctionEntityMetadata) {\n this.expressionMap.createAlias({\n type: \"join\",\n name: joinAttribute.junctionAlias,\n metadata: joinAttribute.relation.junctionEntityMetadata\n });\n }\n\n } else {\n let subQuery: string = \"\";\n if (entityOrProperty instanceof Function) {\n const subQueryBuilder: SelectQueryBuilder<any> = (entityOrProperty as any)(((this as any) as SelectQueryBuilder<any>).subQuery());\n this.setParameters(subQueryBuilder.getParameters());\n subQuery = subQueryBuilder.getQuery();\n\n } else {\n subQuery = entityOrProperty;\n }\n const isSubQuery = entityOrProperty instanceof Function || entityOrProperty.substr(0, 1) === \"(\" && entityOrProperty.substr(-1) === \")\";\n joinAttribute.alias = this.expressionMap.createAlias({\n type: \"join\",\n name: aliasName,\n tablePath: isSubQuery === false ? entityOrProperty as string : undefined,\n subQuery: isSubQuery === true ? subQuery : undefined,\n });\n }\n }\n\n /**\n * Creates \"SELECT FROM\" part of SQL query.\n */\n protected createSelectExpression() {\n\n if (!this.expressionMap.mainAlias)\n throw new Error(\"Cannot build query because main alias is not set (call qb#from method)\");\n\n // todo throw exception if selects or from is missing\n\n const allSelects: SelectQuery[] = [];\n const excludedSelects: SelectQuery[] = [];\n\n if (this.expressionMap.mainAlias.hasMetadata) {\n const metadata = this.expressionMap.mainAlias.metadata;\n allSelects.push(...this.buildEscapedEntityColumnSelects(this.expressionMap.mainAlias.name, metadata));\n excludedSelects.push(...this.findEntityColumnSelects(this.expressionMap.mainAlias.name, metadata));\n }\n\n // add selects from joins\n this.expressionMap.joinAttributes\n .forEach(join => {\n if (join.metadata) {\n allSelects.push(...this.buildEscapedEntityColumnSelects(join.alias.name!, join.metadata));\n excludedSelects.push(...this.findEntityColumnSelects(join.alias.name!, join.metadata));\n } else {\n const hasMainAlias = this.expressionMap.selects.some(select => select.selection === join.alias.name);\n if (hasMainAlias) {\n allSelects.push({ selection: this.escape(join.alias.name!) + \".*\" });\n const excludedSelect = this.expressionMap.selects.find(select => select.selection === join.alias.name);\n excludedSelects.push(excludedSelect!);\n }\n }\n });\n\n // add all other selects\n this.expressionMap.selects\n .filter(select => excludedSelects.indexOf(select) === -1)\n .forEach(select => allSelects.push({ selection: this.replacePropertyNames(select.selection), aliasName: select.aliasName }));\n\n // if still selection is empty, then simply set it to all (*)\n if (allSelects.length === 0)\n allSelects.push({ selection: \"*\" });\n\n let lock: string = \"\";\n if (this.connection.driver instanceof SqlServerDriver) {\n switch (this.expressionMap.lockMode) {\n case \"pessimistic_read\":\n lock = \" WITH (HOLDLOCK, ROWLOCK)\";\n break;\n case \"pessimistic_write\":\n lock = \" WITH (UPDLOCK, ROWLOCK)\";\n break;\n }\n }\n\n // create a selection query\n const froms = this.expressionMap.aliases\n .filter(alias => alias.type === \"from\" && (alias.tablePath || alias.subQuery))\n .map(alias => {\n if (alias.subQuery)\n return alias.subQuery + \" \" + this.escape(alias.name);\n\n return this.getTableName(alias.tablePath!) + \" \" + this.escape(alias.name);\n });\n const selection = allSelects.map(select => select.selection + (select.aliasName ? \" AS \" + this.escape(select.aliasName) : \"\")).join(\", \");\n return \"SELECT \" + selection + \" FROM \" + froms.join(\", \") + lock;\n }\n\n /**\n * Creates \"JOIN\" part of SQL query.\n */\n protected createJoinExpression(): string {\n\n // examples:\n // select from owning side\n // qb.select(\"post\")\n // .leftJoinAndSelect(\"post.category\", \"category\");\n // select from non-owning side\n // qb.select(\"category\")\n // .leftJoinAndSelect(\"category.post\", \"post\");\n\n const joins = this.expressionMap.joinAttributes.map(joinAttr => {\n\n const relation = joinAttr.relation;\n const destinationTableName = joinAttr.tablePath;\n const destinationTableAlias = joinAttr.alias.name;\n const appendedCondition = joinAttr.condition ? \" AND (\" + joinAttr.condition + \")\" : \"\";\n const parentAlias = joinAttr.parentAlias;\n\n // if join was build without relation (e.g. without \"post.category\") then it means that we have direct\n // table to join, without junction table involved. This means we simply join direct table.\n if (!parentAlias || !relation) {\n const destinationJoin = joinAttr.alias.subQuery ? joinAttr.alias.subQuery : this.getTableName(destinationTableName);\n return \" \" + joinAttr.direction + \" JOIN \" + destinationJoin + \" \" + this.escape(destinationTableAlias) +\n (joinAttr.condition ? \" ON \" + this.replacePropertyNames(joinAttr.condition) : \"\");\n }\n\n // if real entity relation is involved\n if (relation.isManyToOne || relation.isOneToOneOwner) {\n\n // JOIN `category` `category` ON `category`.`id` = `post`.`categoryId`\n const condition = relation.joinColumns.map(joinColumn => {\n return destinationTableAlias + \".\" + joinColumn.referencedColumn!.propertyPath + \"=\" +\n parentAlias + \".\" + relation.propertyPath + \".\" + joinColumn.referencedColumn!.propertyPath;\n }).join(\" AND \");\n\n return \" \" + joinAttr.direction + \" JOIN \" + this.getTableName(destinationTableName) + \" \" + this.escape(destinationTableAlias) + \" ON \" + this.replacePropertyNames(condition + appendedCondition);\n\n } else if (relation.isOneToMany || relation.isOneToOneNotOwner) {\n\n // JOIN `post` `post` ON `post`.`categoryId` = `category`.`id`\n const condition = relation.inverseRelation!.joinColumns.map(joinColumn => {\n return destinationTableAlias + \".\" + relation.inverseRelation!.propertyPath + \".\" + joinColumn.referencedColumn!.propertyPath + \"=\" +\n parentAlias + \".\" + joinColumn.referencedColumn!.propertyPath;\n }).join(\" AND \");\n\n return \" \" + joinAttr.direction + \" JOIN \" + this.getTableName(destinationTableName) + \" \" + this.escape(destinationTableAlias) + \" ON \" + this.replacePropertyNames(condition + appendedCondition);\n\n } else { // means many-to-many\n const junctionTableName = relation.junctionEntityMetadata!.tablePath;\n\n const junctionAlias = joinAttr.junctionAlias;\n let junctionCondition = \"\", destinationCondition = \"\";\n\n if (relation.isOwning) {\n\n junctionCondition = relation.joinColumns.map(joinColumn => {\n // `post_category`.`postId` = `post`.`id`\n return junctionAlias + \".\" + joinColumn.propertyPath + \"=\" + parentAlias + \".\" + joinColumn.referencedColumn!.propertyPath;\n }).join(\" AND \");\n\n destinationCondition = relation.inverseJoinColumns.map(joinColumn => {\n // `category`.`id` = `post_category`.`categoryId`\n return destinationTableAlias + \".\" + joinColumn.referencedColumn!.propertyPath + \"=\" + junctionAlias + \".\" + joinColumn.propertyPath;\n }).join(\" AND \");\n\n } else {\n junctionCondition = relation.inverseRelation!.inverseJoinColumns.map(joinColumn => {\n // `post_category`.`categoryId` = `category`.`id`\n return junctionAlias + \".\" + joinColumn.propertyPath + \"=\" + parentAlias + \".\" + joinColumn.referencedColumn!.propertyPath;\n }).join(\" AND \");\n\n destinationCondition = relation.inverseRelation!.joinColumns.map(joinColumn => {\n // `post`.`id` = `post_category`.`postId`\n return destinationTableAlias + \".\" + joinColumn.referencedColumn!.propertyPath + \"=\" + junctionAlias + \".\" + joinColumn.propertyPath;\n }).join(\" AND \");\n }\n\n return \" \" + joinAttr.direction + \" JOIN \" + this.getTableName(junctionTableName) + \" \" + this.escape(junctionAlias) + \" ON \" + this.replacePropertyNames(junctionCondition) +\n \" \" + joinAttr.direction + \" JOIN \" + this.getTableName(destinationTableName) + \" \" + this.escape(destinationTableAlias) + \" ON \" + this.replacePropertyNames(destinationCondition + appendedCondition);\n\n }\n });\n\n return joins.join(\" \");\n }\n\n /**\n * Creates \"GROUP BY\" part of SQL query.\n */\n protected createGroupByExpression() {\n if (!this.expressionMap.groupBys || !this.expressionMap.groupBys.length) return \"\";\n return \" GROUP BY \" + this.replacePropertyNames(this.expressionMap.groupBys.join(\", \"));\n }\n\n /**\n * Creates \"ORDER BY\" part of SQL query.\n */\n protected createOrderByExpression() {\n const orderBys = this.expressionMap.allOrderBys;\n if (Object.keys(orderBys).length > 0)\n return \" ORDER BY \" + Object.keys(orderBys)\n .map(columnName => {\n if (typeof orderBys[columnName] === \"string\") {\n return this.replacePropertyNames(columnName) + \" \" + orderBys[columnName];\n } else {\n return this.replacePropertyNames(columnName) + \" \" + (orderBys[columnName] as any).order + \" \" + (orderBys[columnName] as any).nulls;\n }\n })\n .join(\", \");\n\n return \"\";\n }\n\n /**\n * Creates \"LIMIT\" and \"OFFSET\" parts of SQL query.\n */\n protected createLimitOffsetExpression(): string {\n // in the case if nothing is joined in the query builder we don't need to make two requests to get paginated results\n // we can use regular limit / offset, that's why we add offset and limit construction here based on skip and take values\n let offset: number|undefined = this.expressionMap.offset,\n limit: number|undefined = this.expressionMap.limit;\n if (!offset && !limit && this.expressionMap.joinAttributes.length === 0) {\n offset = this.expressionMap.skip;\n limit = this.expressionMap.take;\n }\n\n if (this.connection.driver instanceof SqlServerDriver) {\n // Due to a limitation in SQL Server's parser implementation it does not support using\n // OFFSET or FETCH NEXT without an ORDER BY clause being provided. In cases where the\n // user does not request one we insert a dummy ORDER BY that does nothing and should\n // have no effect on the query planner or on the order of the results returned.\n // https://dba.stackexchange.com/a/193799\n let prefix = \"\";\n if ((limit || offset) && Object.keys(this.expressionMap.allOrderBys).length <= 0) {\n prefix = \" ORDER BY (SELECT NULL)\";\n }\n\n if (limit && offset)\n return prefix + \" OFFSET \" + offset + \" ROWS FETCH NEXT \" + limit + \" ROWS ONLY\";\n if (limit)\n return prefix + \" OFFSET 0 ROWS FETCH NEXT \" + limit + \" ROWS ONLY\";\n if (offset)\n return prefix + \" OFFSET \" + offset + \" ROWS\";\n\n } else if (this.connection.driver instanceof MysqlDriver) {\n\n if (limit && offset)\n return \" LIMIT \" + limit + \" OFFSET \" + offset;\n if (limit)\n return \" LIMIT \" + limit;\n if (offset)\n throw new OffsetWithoutLimitNotSupportedError(\"MySQL\");\n\n } else if (this.connection.driver instanceof AbstractSqliteDriver) {\n\n if (limit && offset)\n return \" LIMIT \" + limit + \" OFFSET \" + offset;\n if (limit)\n return \" LIMIT \" + limit;\n if (offset)\n return \" LIMIT -1 OFFSET \" + offset;\n\n } else if (this.connection.driver instanceof OracleDriver) {\n\n if (limit && offset)\n return \" OFFSET \" + offset + \" ROWS FETCH NEXT \" + limit + \" ROWS ONLY\";\n if (limit)\n return \" FETCH NEXT \" + limit + \" ROWS ONLY\";\n if (offset)\n return \" OFFSET \" + offset + \" ROWS\";\n\n } else {\n if (limit && offset)\n return \" LIMIT \" + limit + \" OFFSET \" + offset;\n if (limit)\n return \" LIMIT \" + limit;\n if (offset)\n return \" OFFSET \" + offset;\n }\n\n return \"\";\n }\n\n /**\n * Creates \"LOCK\" part of SQL query.\n */\n protected createLockExpression(): string {\n const driver = this.connection.driver;\n switch (this.expressionMap.lockMode) {\n case \"pessimistic_read\":\n if (driver instanceof MysqlDriver) {\n return \" LOCK IN SHARE MODE\";\n\n } else if (driver instanceof PostgresDriver) {\n return \" FOR SHARE\";\n\n } else if (driver instanceof OracleDriver) {\n return \" FOR UPDATE\";\n\n } else if (driver instanceof SqlServerDriver) {\n return \"\";\n\n } else {\n throw new LockNotSupportedOnGivenDriverError();\n }\n case \"pessimistic_write\":\n if (driver instanceof MysqlDriver || driver instanceof PostgresDriver || driver instanceof OracleDriver) {\n return \" FOR UPDATE\";\n\n } else if (driver instanceof SqlServerDriver) {\n return \"\";\n\n } else {\n throw new LockNotSupportedOnGivenDriverError();\n }\n default:\n return \"\";\n }\n }\n\n /**\n * Creates \"HAVING\" part of SQL query.\n */\n protected createHavingExpression() {\n if (!this.expressionMap.havings || !this.expressionMap.havings.length) return \"\";\n const conditions = this.expressionMap.havings.map((having, index) => {\n switch (having.type) {\n case \"and\":\n return (index > 0 ? \"AND \" : \"\") + this.replacePropertyNames(having.condition);\n case \"or\":\n return (index > 0 ? \"OR \" : \"\") + this.replacePropertyNames(having.condition);\n default:\n return this.replacePropertyNames(having.condition);\n }\n }).join(\" \");\n\n if (!conditions.length) return \"\";\n return \" HAVING \" + conditions;\n }\n\n protected buildEscapedEntityColumnSelects(aliasName: string, metadata: EntityMetadata): SelectQuery[] {\n const hasMainAlias = this.expressionMap.selects.some(select => select.selection === aliasName);\n\n const columns: ColumnMetadata[] = [];\n if (hasMainAlias) {\n columns.push(...metadata.columns.filter(column => column.isSelect === true));\n }\n columns.push(...metadata.columns.filter(column => {\n return this.expressionMap.selects.some(select => select.selection === aliasName + \".\" + column.propertyPath);\n }));\n\n // if user used partial selection and did not select some primary columns which are required to be selected\n // we select those primary columns and mark them as \"virtual\". Later virtual column values will be removed from final entity\n // to make entity contain exactly what user selected\n if (columns.length === 0) // however not in the case when nothing (even partial) was selected from this target (for example joins without selection)\n return [];\n\n const nonSelectedPrimaryColumns = this.expressionMap.queryEntity ? metadata.primaryColumns.filter(primaryColumn => columns.indexOf(primaryColumn) === -1) : [];\n const allColumns = [...columns, ...nonSelectedPrimaryColumns];\n\n return allColumns.map(column => {\n const selection = this.expressionMap.selects.find(select => select.selection === aliasName + \".\" + column.propertyPath);\n let selectionPath = this.escape(aliasName) + \".\" + this.escape(column.databaseName);\n if (this.connection.driver.spatialTypes.indexOf(column.type) !== -1) {\n if (this.connection.driver instanceof MysqlDriver)\n selectionPath = `AsText(${selectionPath})`;\n\n if (this.connection.driver instanceof PostgresDriver)\n // cast to JSON to trigger parsing in the driver\n selectionPath = `ST_AsGeoJSON(${selectionPath})::json`;\n\n if (this.connection.driver instanceof SqlServerDriver)\n selectionPath = `${selectionPath}.ToString()`;\n }\n return {\n selection: selectionPath,\n aliasName: selection && selection.aliasName ? selection.aliasName : DriverUtils.buildColumnAlias(this.connection.driver, aliasName, column.databaseName),\n // todo: need to keep in mind that custom selection.aliasName breaks hydrator. fix it later!\n virtual: selection ? selection.virtual === true : (hasMainAlias ? false : true),\n };\n });\n }\n\n protected findEntityColumnSelects(aliasName: string, metadata: EntityMetadata): SelectQuery[] {\n const mainSelect = this.expressionMap.selects.find(select => select.selection === aliasName);\n if (mainSelect)\n return [mainSelect];\n\n return this.expressionMap.selects.filter(select => {\n return metadata.columns.some(column => select.selection === aliasName + \".\" + column.propertyPath);\n });\n }\n\n protected async executeCountQuery(queryRunner: QueryRunner): Promise<number> {\n\n const mainAlias = this.expressionMap.mainAlias!.name; // todo: will this work with \"fromTableName\"?\n const metadata = this.expressionMap.mainAlias!.metadata;\n\n const distinctAlias = this.escape(mainAlias);\n let countSql: string = \"\";\n if (metadata.hasMultiplePrimaryKeys) {\n if (this.connection.driver instanceof AbstractSqliteDriver) {\n countSql = `COUNT(DISTINCT(` + metadata.primaryColumns.map((primaryColumn, index) => {\n const propertyName = this.escape(primaryColumn.databaseName);\n return `${distinctAlias}.${propertyName}`;\n }).join(\" || \") + \")) as \\\"cnt\\\"\";\n\n } else {\n countSql = `COUNT(DISTINCT(CONCAT(` + metadata.primaryColumns.map((primaryColumn, index) => {\n const propertyName = this.escape(primaryColumn.databaseName);\n return `${distinctAlias}.${propertyName}`;\n }).join(\", \") + \"))) as \\\"cnt\\\"\";\n }\n\n } else {\n countSql = `COUNT(DISTINCT(` + metadata.primaryColumns.map((primaryColumn, index) => {\n const propertyName = this.escape(primaryColumn.databaseName);\n return `${distinctAlias}.${propertyName}`;\n }).join(\", \") + \")) as \\\"cnt\\\"\";\n }\n\n const results = await this.clone()\n .orderBy()\n .groupBy()\n .offset(undefined)\n .limit(undefined)\n .skip(undefined)\n .take(undefined)\n .select(countSql)\n .setOption(\"disable-global-order\")\n .loadRawResults(queryRunner);\n\n if (!results || !results[0] || !results[0][\"cnt\"])\n return 0;\n\n return parseInt(results[0][\"cnt\"]);\n }\n\n /**\n * Executes sql generated by query builder and returns object with raw results and entities created from them.\n */\n protected async executeEntitiesAndRawResults(queryRunner: QueryRunner): Promise<{ entities: Entity[], raw: any[] }> {\n\n if (!this.expressionMap.mainAlias)\n throw new Error(`Alias is not set. Use \"from\" method to set an alias.`);\n\n if ((this.expressionMap.lockMode === \"pessimistic_read\" || this.expressionMap.lockMode === \"pessimistic_write\") && !queryRunner.isTransactionActive)\n throw new PessimisticLockTransactionRequiredError();\n\n if (this.expressionMap.lockMode === \"optimistic\") {\n const metadata = this.expressionMap.mainAlias.metadata;\n if (!metadata.versionColumn && !metadata.updateDateColumn)\n throw new NoVersionOrUpdateDateColumnError(metadata.name);\n }\n\n const relationIdLoader = new RelationIdLoader(this.connection, queryRunner, this.expressionMap.relationIdAttributes);\n const relationCountLoader = new RelationCountLoader(this.connection, queryRunner, this.expressionMap.relationCountAttributes);\n const relationIdMetadataTransformer = new RelationIdMetadataToAttributeTransformer(this.expressionMap);\n relationIdMetadataTransformer.transform();\n const relationCountMetadataTransformer = new RelationCountMetadataToAttributeTransformer(this.expressionMap);\n relationCountMetadataTransformer.transform();\n\n let rawResults: any[] = [], entities: any[] = [];\n\n // for pagination enabled (e.g. skip and take) its much more complicated - its a special process\n // where we make two queries to find the data we need\n // first query find ids in skip and take range\n // and second query loads the actual data in given ids range\n if ((this.expressionMap.skip || this.expressionMap.take) && this.expressionMap.joinAttributes.length > 0) {\n\n // we are skipping order by here because its not working in subqueries anyway\n // to make order by working we need to apply it on a distinct query\n const [selects, orderBys] = this.createOrderByCombinedWithSelectExpression(\"distinctAlias\");\n const metadata = this.expressionMap.mainAlias.metadata;\n const mainAliasName = this.expressionMap.mainAlias.name;\n\n const querySelects = metadata.primaryColumns.map(primaryColumn => {\n const distinctAlias = this.escape(\"distinctAlias\");\n const columnAlias = this.escape(DriverUtils.buildColumnAlias(this.connection.driver, mainAliasName, primaryColumn.databaseName));\n if (!orderBys[columnAlias]) // make sure we aren't overriding user-defined order in inverse direction\n orderBys[columnAlias] = \"ASC\";\n return `${distinctAlias}.${columnAlias} as \"ids_${DriverUtils.buildColumnAlias(this.connection.driver, mainAliasName, primaryColumn.databaseName)}\"`;\n });\n\n rawResults = await new SelectQueryBuilder(this.connection, queryRunner)\n .select(`DISTINCT ${querySelects.join(\", \")}`)\n .addSelect(selects)\n .from(`(${this.clone().orderBy().getQuery()})`, \"distinctAlias\")\n .offset(this.expressionMap.skip)\n .limit(this.expressionMap.take)\n .orderBy(orderBys)\n .cache(this.expressionMap.cache ? this.expressionMap.cache : this.expressionMap.cacheId, this.expressionMap.cacheDuration)\n .setParameters(this.getParameters())\n .setNativeParameters(this.expressionMap.nativeParameters)\n .getRawMany();\n\n if (rawResults.length > 0) {\n let condition = \"\";\n const parameters: ObjectLiteral = {};\n if (metadata.hasMultiplePrimaryKeys) {\n condition = rawResults.map((result, index) => {\n return metadata.primaryColumns.map(primaryColumn => {\n parameters[`ids_${index}_${primaryColumn.databaseName}`] = result[`ids_${mainAliasName}_${primaryColumn.databaseName}`];\n return `${mainAliasName}.${primaryColumn.propertyPath}=:ids_${index}_${primaryColumn.databaseName}`;\n }).join(\" AND \");\n }).join(\" OR \");\n } else {\n const ids = rawResults.map(result => result[\"ids_\" + DriverUtils.buildColumnAlias(this.connection.driver, mainAliasName, metadata.primaryColumns[0].databaseName)]);\n const areAllNumbers = ids.every((id: any) => typeof id === \"number\");\n if (areAllNumbers) {\n // fixes #190. if all numbers then its safe to perform query without parameter\n condition = `${mainAliasName}.${metadata.primaryColumns[0].propertyPath} IN (${ids.join(\", \")})`;\n } else {\n parameters[\"ids\"] = ids;\n condition = mainAliasName + \".\" + metadata.primaryColumns[0].propertyPath + \" IN (:...ids)\";\n }\n }\n rawResults = await this.clone()\n .mergeExpressionMap({ extraAppendedAndWhereCondition: condition })\n .setParameters(parameters)\n .loadRawResults(queryRunner);\n }\n\n } else {\n rawResults = await this.loadRawResults(queryRunner);\n }\n\n if (rawResults.length > 0) {\n\n // transform raw results into entities\n const rawRelationIdResults = await relationIdLoader.load(rawResults);\n const rawRelationCountResults = await relationCountLoader.load(rawResults);\n const transformer = new RawSqlResultsToEntityTransformer(this.expressionMap, this.connection.driver, rawRelationIdResults, rawRelationCountResults, this.queryRunner);\n entities = transformer.transform(rawResults, this.expressionMap.mainAlias!);\n\n // broadcast all \"after load\" events\n if (this.expressionMap.callListeners === true && this.expressionMap.mainAlias.hasMetadata) {\n const broadcastResult = new BroadcasterResult();\n queryRunner.broadcaster.broadcastLoadEventsForAll(broadcastResult, this.expressionMap.mainAlias.metadata, entities);\n if (broadcastResult.promises.length > 0) await Promise.all(broadcastResult.promises);\n }\n }\n\n return {\n raw: rawResults,\n entities: entities,\n };\n }\n\n protected createOrderByCombinedWithSelectExpression(parentAlias: string): [ string, OrderByCondition] {\n\n // if table has a default order then apply it\n const orderBys = this.expressionMap.allOrderBys;\n const selectString = Object.keys(orderBys)\n .map(orderCriteria => {\n if (orderCriteria.indexOf(\".\") !== -1) {\n const [aliasName, propertyPath] = orderCriteria.split(\".\");\n const alias = this.expressionMap.findAliasByName(aliasName);\n const column = alias.metadata.findColumnWithPropertyName(propertyPath);\n return this.escape(parentAlias) + \".\" + this.escape(DriverUtils.buildColumnAlias(this.connection.driver, aliasName, column!.databaseName));\n } else {\n if (this.expressionMap.selects.find(select => select.selection === orderCriteria || select.aliasName === orderCriteria))\n return this.escape(parentAlias) + \".\" + orderCriteria;\n\n return \"\";\n }\n })\n .join(\", \");\n\n const orderByObject: OrderByCondition = {};\n Object.keys(orderBys).forEach(orderCriteria => {\n if (orderCriteria.indexOf(\".\") !== -1) {\n const [aliasName, propertyPath] = orderCriteria.split(\".\");\n const alias = this.expressionMap.findAliasByName(aliasName);\n const column = alias.metadata.findColumnWithPropertyName(propertyPath);\n orderByObject[this.escape(parentAlias) + \".\" + this.escape(DriverUtils.buildColumnAlias(this.connection.driver, aliasName, column!.databaseName))] = orderBys[orderCriteria];\n } else {\n if (this.expressionMap.selects.find(select => select.selection === orderCriteria || select.aliasName === orderCriteria)) {\n orderByObject[this.escape(parentAlias) + \".\" + orderCriteria] = orderBys[orderCriteria];\n } else {\n orderByObject[orderCriteria] = orderBys[orderCriteria];\n }\n }\n });\n\n return [selectString, orderByObject];\n }\n\n /**\n * Loads raw results from the database.\n */\n protected async loadRawResults(queryRunner: QueryRunner) {\n const [sql, parameters] = this.getQueryAndParameters();\n const queryId = sql + \" -- PARAMETERS: \" + JSON.stringify(parameters);\n const cacheOptions = typeof this.connection.options.cache === \"object\" ? this.connection.options.cache : {};\n let savedQueryResultCacheOptions: QueryResultCacheOptions|undefined = undefined;\n if (this.connection.queryResultCache && (this.expressionMap.cache || cacheOptions.alwaysEnabled)) {\n savedQueryResultCacheOptions = await this.connection.queryResultCache.getFromCache({\n identifier: this.expressionMap.cacheId,\n query: queryId,\n duration: this.expressionMap.cacheDuration || cacheOptions.duration || 1000\n }, queryRunner);\n if (savedQueryResultCacheOptions && !this.connection.queryResultCache.isExpired(savedQueryResultCacheOptions))\n return JSON.parse(savedQueryResultCacheOptions.result);\n }\n\n const results = await queryRunner.query(sql, parameters);\n\n if (this.connection.queryResultCache && (this.expressionMap.cache || cacheOptions.alwaysEnabled)) {\n await this.connection.queryResultCache.storeInCache({\n identifier: this.expressionMap.cacheId,\n query: queryId,\n time: new Date().getTime(),\n duration: this.expressionMap.cacheDuration || cacheOptions.duration || 1000,\n result: JSON.stringify(results)\n }, savedQueryResultCacheOptions, queryRunner);\n }\n\n return results;\n }\n\n /**\n * Merges into expression map given expression map properties.\n */\n protected mergeExpressionMap(expressionMap: Partial<QueryExpressionMap>): this {\n ObjectUtils.assign(this.expressionMap, expressionMap);\n return this;\n }\n\n /**\n * Normalizes a give number - converts to int if possible.\n */\n protected normalizeNumber(num: any) {\n if (typeof num === \"number\" || num === undefined || num === null)\n return num;\n\n return Number(num);\n }\n\n /**\n * Creates a query builder used to execute sql queries inside this query builder.\n */\n protected obtainQueryRunner() {\n return this.queryRunner || this.connection.createQueryRunner(\"slave\");\n }\n\n}\n"],"sourceRoot":".."}
|