From 409bb27bc6f9c6b9d05e7096eddf251f92abc628 Mon Sep 17 00:00:00 2001 From: James Ward Date: Sun, 11 Jul 2021 04:04:56 -0400 Subject: [PATCH 1/2] fix: condition is optional in SelectQueryBuilder joins the condition seems to have been accidentally marked as required when it's actually optional in the underlying implementation. this marks the condition in any join within `SelectQueryBuilder` as optional --- src/query-builder/SelectQueryBuilder.ts | 34 ++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/query-builder/SelectQueryBuilder.ts b/src/query-builder/SelectQueryBuilder.ts index 242a68fa10..a9c6e8f262 100644 --- a/src/query-builder/SelectQueryBuilder.ts +++ b/src/query-builder/SelectQueryBuilder.ts @@ -272,7 +272,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - innerJoin(entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition: string = "", parameters?: ObjectLiteral): this { + innerJoin(entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition?: string, parameters?: ObjectLiteral): this { this.join("INNER", entityOrProperty, alias, condition, parameters); return this; } @@ -311,7 +311,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - leftJoin(entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition: string = "", parameters?: ObjectLiteral): this { + leftJoin(entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition?: string = "", parameters?: ObjectLiteral): this { this.join("LEFT", entityOrProperty, alias, condition, parameters); return this; } @@ -350,7 +350,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - innerJoinAndSelect(entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition: string = "", parameters?: ObjectLiteral): this { + innerJoinAndSelect(entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition?: string, parameters?: ObjectLiteral): this { this.addSelect(alias); this.innerJoin(entityOrProperty, alias, condition, parameters); return this; @@ -376,7 +376,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - leftJoinAndSelect(entity: Function|string, alias: string, condition: string, parameters?: ObjectLiteral): this; + leftJoinAndSelect(entity: Function|string, alias: string, condition?: string, parameters?: ObjectLiteral): this; /** * LEFT JOINs table and adds all selection properties to SELECT. @@ -390,7 +390,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - leftJoinAndSelect(entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition: string = "", parameters?: ObjectLiteral): this { + leftJoinAndSelect(entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition?: string, parameters?: ObjectLiteral): this { this.addSelect(alias); this.leftJoin(entityOrProperty, alias, condition, parameters); return this; @@ -423,7 +423,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - innerJoinAndMapMany(mapToProperty: string, entity: Function|string, alias: string, condition: string, parameters?: ObjectLiteral): this; + innerJoinAndMapMany(mapToProperty: string, entity: Function|string, alias: string, condition?: string, parameters?: ObjectLiteral): this; /** * INNER JOINs table, SELECTs the data returned by a join and MAPs all that data to some entity's property. @@ -432,7 +432,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - innerJoinAndMapMany(mapToProperty: string, tableName: string, alias: string, condition: string, parameters?: ObjectLiteral): this; + innerJoinAndMapMany(mapToProperty: string, tableName: string, alias: string, condition?: string, parameters?: ObjectLiteral): this; /** * INNER JOINs, SELECTs the data returned by a join and MAPs all that data to some entity's property. @@ -441,7 +441,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - innerJoinAndMapMany(mapToProperty: string, entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition: string = "", parameters?: ObjectLiteral): this { + innerJoinAndMapMany(mapToProperty: string, entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition?: string, parameters?: ObjectLiteral): this { this.addSelect(alias); this.join("INNER", entityOrProperty, alias, condition, parameters, mapToProperty, true); return this; @@ -474,7 +474,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - innerJoinAndMapOne(mapToProperty: string, entity: Function|string, alias: string, condition: string, parameters?: ObjectLiteral): this; + innerJoinAndMapOne(mapToProperty: string, entity: Function|string, alias: string, condition?: string, parameters?: ObjectLiteral): this; /** * INNER JOINs table, SELECTs the data returned by a join and MAPs all that data to some entity's property. @@ -483,7 +483,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - innerJoinAndMapOne(mapToProperty: string, tableName: string, alias: string, condition: string, parameters?: ObjectLiteral): this; + innerJoinAndMapOne(mapToProperty: string, tableName: string, alias: string, condition?: string, parameters?: ObjectLiteral): this; /** * INNER JOINs, SELECTs the data returned by a join and MAPs all that data to some entity's property. @@ -492,7 +492,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - innerJoinAndMapOne(mapToProperty: string, entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition: string = "", parameters?: ObjectLiteral): this { + innerJoinAndMapOne(mapToProperty: string, entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition?: string, parameters?: ObjectLiteral): this { this.addSelect(alias); this.join("INNER", entityOrProperty, alias, condition, parameters, mapToProperty, false); return this; @@ -525,7 +525,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - leftJoinAndMapMany(mapToProperty: string, entity: Function|string, alias: string, condition: string, parameters?: ObjectLiteral): this; + leftJoinAndMapMany(mapToProperty: string, entity: Function|string, alias: string, condition?: string, parameters?: ObjectLiteral): this; /** * LEFT JOINs table, SELECTs the data returned by a join and MAPs all that data to some entity's property. @@ -534,7 +534,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - leftJoinAndMapMany(mapToProperty: string, tableName: string, alias: string, condition: string, parameters?: ObjectLiteral): this; + leftJoinAndMapMany(mapToProperty: string, tableName: string, alias: string, condition?: string, parameters?: ObjectLiteral): this; /** * LEFT JOINs, SELECTs the data returned by a join and MAPs all that data to some entity's property. @@ -543,7 +543,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - leftJoinAndMapMany(mapToProperty: string, entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition: string = "", parameters?: ObjectLiteral): this { + leftJoinAndMapMany(mapToProperty: string, entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition?: string, parameters?: ObjectLiteral): this { this.addSelect(alias); this.join("LEFT", entityOrProperty, alias, condition, parameters, mapToProperty, true); return this; @@ -576,7 +576,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - leftJoinAndMapOne(mapToProperty: string, entity: Function|string, alias: string, condition: string, parameters?: ObjectLiteral): this; + leftJoinAndMapOne(mapToProperty: string, entity: Function|string, alias: string, condition?: string, parameters?: ObjectLiteral): this; /** * LEFT JOINs table, SELECTs the data returned by a join and MAPs all that data to some entity's property. @@ -585,7 +585,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - leftJoinAndMapOne(mapToProperty: string, tableName: string, alias: string, condition: string, parameters?: ObjectLiteral): this; + leftJoinAndMapOne(mapToProperty: string, tableName: string, alias: string, condition?: string, parameters?: ObjectLiteral): this; /** * LEFT JOINs, SELECTs the data returned by a join and MAPs all that data to some entity's property. @@ -594,7 +594,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - leftJoinAndMapOne(mapToProperty: string, entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition: string = "", parameters?: ObjectLiteral): this { + leftJoinAndMapOne(mapToProperty: string, entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition?: string, parameters?: ObjectLiteral): this { this.addSelect(alias); this.join("LEFT", entityOrProperty, alias, condition, parameters, mapToProperty, false); return this; From d73c93393d2f0ca7fd69b36d8d3b00447c2876ef Mon Sep 17 00:00:00 2001 From: James Ward Date: Sun, 11 Jul 2021 04:50:37 -0400 Subject: [PATCH 2/2] fix missed definition --- src/query-builder/SelectQueryBuilder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/query-builder/SelectQueryBuilder.ts b/src/query-builder/SelectQueryBuilder.ts index a9c6e8f262..582586c8ab 100644 --- a/src/query-builder/SelectQueryBuilder.ts +++ b/src/query-builder/SelectQueryBuilder.ts @@ -311,7 +311,7 @@ export class SelectQueryBuilder extends QueryBuilder implements * You also need to specify an alias of the joined data. * Optionally, you can add condition and parameters used in condition. */ - leftJoin(entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition?: string = "", parameters?: ObjectLiteral): this { + leftJoin(entityOrProperty: Function|string|((qb: SelectQueryBuilder) => SelectQueryBuilder), alias: string, condition?: string, parameters?: ObjectLiteral): this { this.join("LEFT", entityOrProperty, alias, condition, parameters); return this; }