typeorm 0.3.13-dev.f1330ad → 0.3.13-dev.f7f6817
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/driver/postgres/PostgresQueryRunner.js +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js +0 -7
- package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/browser/entity-schema/EntitySchemaOptions.d.ts +4 -5
- package/browser/entity-schema/EntitySchemaOptions.js.map +1 -1
- package/browser/entity-schema/EntitySchemaTransformer.js +0 -13
- package/browser/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/browser/find-options/FindOperator.d.ts +0 -2
- package/browser/find-options/FindOperator.js +0 -13
- package/browser/find-options/FindOperator.js.map +1 -1
- package/browser/find-options/FindOptionsUtils.js +15 -45
- package/browser/find-options/FindOptionsUtils.js.map +1 -1
- package/browser/metadata/EmbeddedMetadata.js +3 -3
- package/browser/metadata/EmbeddedMetadata.js.map +1 -1
- package/browser/migration/MigrationExecutor.js +2 -8
- package/browser/migration/MigrationExecutor.js.map +1 -1
- package/browser/query-builder/JoinAttribute.d.ts +0 -4
- package/browser/query-builder/JoinAttribute.js +0 -4
- package/browser/query-builder/JoinAttribute.js.map +1 -1
- package/browser/query-builder/SelectQueryBuilder.d.ts +3 -4
- package/browser/query-builder/SelectQueryBuilder.js +8 -16
- package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
- package/browser/util/StringUtils.js +3 -3
- package/browser/util/StringUtils.js.map +1 -1
- package/driver/postgres/PostgresQueryRunner.js +1 -1
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteDriver.js +0 -7
- package/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/entity-schema/EntitySchemaOptions.d.ts +4 -5
- package/entity-schema/EntitySchemaOptions.js.map +1 -1
- package/entity-schema/EntitySchemaTransformer.js +0 -13
- package/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/find-options/FindOperator.d.ts +0 -2
- package/find-options/FindOperator.js +0 -13
- package/find-options/FindOperator.js.map +1 -1
- package/find-options/FindOptionsUtils.js +16 -46
- package/find-options/FindOptionsUtils.js.map +1 -1
- package/metadata/EmbeddedMetadata.js +3 -3
- package/metadata/EmbeddedMetadata.js.map +1 -1
- package/migration/MigrationExecutor.js +2 -8
- package/migration/MigrationExecutor.js.map +1 -1
- package/package.json +1 -1
- package/query-builder/JoinAttribute.d.ts +0 -4
- package/query-builder/JoinAttribute.js +0 -4
- package/query-builder/JoinAttribute.js.map +1 -1
- package/query-builder/SelectQueryBuilder.d.ts +3 -4
- package/query-builder/SelectQueryBuilder.js +8 -16
- package/query-builder/SelectQueryBuilder.js.map +1 -1
- package/util/StringUtils.js +3 -3
- package/util/StringUtils.js.map +1 -1
- package/browser/entity-schema/EntitySchemaInheritanceOptions.d.ts +0 -11
- package/browser/entity-schema/EntitySchemaInheritanceOptions.js +0 -3
- package/browser/entity-schema/EntitySchemaInheritanceOptions.js.map +0 -1
- package/entity-schema/EntitySchemaInheritanceOptions.d.ts +0 -11
- package/entity-schema/EntitySchemaInheritanceOptions.js +0 -4
- package/entity-schema/EntitySchemaInheritanceOptions.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/query-builder/JoinAttribute.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAGvD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEnD;;GAEG;AACH,MAAM,OAAO,aAAa;IAwCtB,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YACY,UAAsB,EACtB,kBAAsC,EAC9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AU,CAAC,MAAM,EACtB,IAAI,CAAC,WAAY,EACjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAClB,CAAA;SACJ;aAAM;YACH,OAAO,WAAW,CAAC,UAAU,CACzB,IAAI,CAAC,UAAU,CAAC,MAAM,EACtB,IAAI,CAAC,KAAK,CAAC,IAAI,EACf,IAAI,CAAC,WAAY,CACpB,CAAA;SACJ;IACL,CAAC;IAED,IAAI,wBAAwB;QACxB,IAAI,CAAC,IAAI,CAAC,aAAa;YAAE,OAAO,SAAS,CAAA;QAEzC,OAAO,IAAI,CAAC,aAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAC5C,CAAC;IAED,IAAI,yBAAyB;QACzB,IAAI,CAAC,IAAI,CAAC,aAAa;YAAE,OAAO,SAAS,CAAA;QAEzC,OAAO,IAAI,CAAC,aAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAC5C,CAAC;CACJ","file":"JoinAttribute.js","sourcesContent":["import { EntityMetadata } from \"../metadata/EntityMetadata\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { RelationMetadata } from \"../metadata/RelationMetadata\"\nimport { QueryBuilderUtils } from \"./QueryBuilderUtils\"\nimport { QueryExpressionMap } from \"./QueryExpressionMap\"\nimport { Alias } from \"./Alias\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\nimport { TypeORMError } from \"../error\"\nimport { DriverUtils } from \"../driver/DriverUtils\"\n\n/**\n * Stores all join attributes which will be used to build a JOIN query.\n */\nexport class JoinAttribute {\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Join direction.\n */\n direction: \"LEFT\" | \"INNER\"\n\n /**\n * Alias of the joined (destination) table.\n */\n alias: Alias\n\n /**\n * Joined table, entity target, or relation in \"post.category\" format.\n */\n entityOrProperty: Function | string\n\n /**\n * Extra condition applied to \"ON\" section of join.\n */\n condition?: string\n\n /**\n * Property + alias of the object where to joined data should be mapped.\n */\n mapToProperty?: string\n\n /**\n * Indicates if user maps one or many objects from the join.\n */\n isMappingMany?: boolean\n\n /**\n * Useful when the joined expression is a custom query to support mapping.\n */\n mapAsEntity?: Function | string\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n private connection: DataSource,\n private queryExpressionMap: QueryExpressionMap,\n joinAttribute?: JoinAttribute,\n ) {\n ObjectUtils.assign(this, joinAttribute || {})\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n get isMany(): boolean {\n if (this.isMappingMany !== undefined) return this.isMappingMany\n\n if (this.relation)\n return this.relation.isManyToMany || this.relation.isOneToMany\n\n return false\n }\n\n isSelectedCache: boolean\n isSelectedEvaluated: boolean = false\n /**\n * Indicates if this join is selected.\n */\n get isSelected(): boolean {\n if (!this.isSelectedEvaluated) {\n let getValue = () => {\n for (const select of this.queryExpressionMap.selects) {\n if (select.selection === this.alias.name) return true\n\n if (\n this.metadata &&\n !!this.metadata.columns.find(\n (column) =>\n select.selection ===\n this.alias.name + \".\" + column.propertyPath,\n )\n )\n return true\n }\n\n return false\n }\n this.isSelectedCache = getValue()\n this.isSelectedEvaluated = true\n }\n return this.isSelectedCache\n }\n\n /**\n * Name of the table which we should join.\n */\n get tablePath(): string {\n return this.metadata\n ? this.metadata.tablePath\n : (this.entityOrProperty as string)\n }\n\n /**\n * Alias of the parent of this join.\n * For example, if we join (\"post.category\", \"categoryAlias\") then \"post\" is a parent alias.\n * This value is extracted from entityOrProperty value.\n * This is available when join was made using \"post.category\" syntax.\n */\n get parentAlias(): string | undefined {\n if (!QueryBuilderUtils.isAliasProperty(this.entityOrProperty))\n return undefined\n\n return this.entityOrProperty.substr(\n 0,\n this.entityOrProperty.indexOf(\".\"),\n )\n }\n\n /**\n * Relation property name of the parent.\n * This is used to understand what is joined.\n * For example, if we join (\"post.category\", \"categoryAlias\") then \"category\" is a relation property.\n * This value is extracted from entityOrProperty value.\n * This is available when join was made using \"post.category\" syntax.\n */\n get relationPropertyPath(): string | undefined {\n if (!QueryBuilderUtils.isAliasProperty(this.entityOrProperty))\n return undefined\n\n return this.entityOrProperty.substr(\n this.entityOrProperty.indexOf(\".\") + 1,\n )\n }\n\n relationCache: RelationMetadata | undefined\n relationEvaluated: boolean = false\n /**\n * Relation of the parent.\n * This is used to understand what is joined.\n * This is available when join was made using \"post.category\" syntax.\n * Relation can be undefined if entityOrProperty is regular entity or custom table.\n */\n get relation(): RelationMetadata | undefined {\n if (!this.relationEvaluated) {\n let getValue = () => {\n if (!QueryBuilderUtils.isAliasProperty(this.entityOrProperty))\n return undefined\n\n const relationOwnerSelection =\n this.queryExpressionMap.findAliasByName(this.parentAlias!)\n let relation =\n relationOwnerSelection.metadata.findRelationWithPropertyPath(\n this.relationPropertyPath!,\n )\n\n if (relation) {\n return relation\n }\n\n if (relationOwnerSelection.metadata.parentEntityMetadata) {\n relation =\n relationOwnerSelection.metadata.parentEntityMetadata.findRelationWithPropertyPath(\n this.relationPropertyPath!,\n )\n if (relation) {\n return relation\n }\n }\n\n throw new TypeORMError(\n `Relation with property path ${this.relationPropertyPath} in entity was not found.`,\n )\n }\n this.relationCache = getValue.bind(this)()\n this.relationEvaluated = true\n }\n return this.relationCache\n }\n\n /**\n * Metadata of the joined entity.\n * If table without entity was joined, then it will return undefined.\n */\n get metadata(): EntityMetadata | undefined {\n // entityOrProperty is relation, e.g. \"post.category\"\n if (this.relation) return this.relation.inverseEntityMetadata\n\n // entityOrProperty is Entity class\n if (this.connection.hasMetadata(this.entityOrProperty))\n return this.connection.getMetadata(this.entityOrProperty)\n\n // Overriden mapping entity provided for leftJoinAndMapOne with custom query builder\n if (this.mapAsEntity && this.connection.hasMetadata(this.mapAsEntity)) {\n return this.connection.getMetadata(this.mapAsEntity)\n }\n\n return undefined\n\n /*if (typeof this.entityOrProperty === \"string\") { // entityOrProperty is a custom table\n\n // first try to find entity with such name, this is needed when entity does not have a target class,\n // and its target is a string name (scenario when plain old javascript is used or entity schema is loaded from files)\n const metadata = this.connection.entityMetadatas.find(metadata => metadata.name === this.entityOrProperty);\n if (metadata)\n return metadata;\n\n // check if we have entity with such table name, and use its metadata if found\n return this.connection.entityMetadatas.find(metadata => metadata.tableName === this.entityOrProperty);\n }*/\n }\n\n /**\n * Generates alias of junction table, whose ids we get.\n */\n get junctionAlias(): string {\n if (!this.relation)\n throw new TypeORMError(\n `Cannot get junction table for join without relation.`,\n )\n\n if (this.relation.isOwning) {\n return DriverUtils.buildAlias(\n this.connection.driver,\n this.parentAlias!,\n this.alias.name,\n )\n } else {\n return DriverUtils.buildAlias(\n this.connection.driver,\n this.alias.name,\n this.parentAlias!,\n )\n }\n }\n\n get mapToPropertyParentAlias(): string | undefined {\n if (!this.mapToProperty) return undefined\n\n return this.mapToProperty!.split(\".\")[0]\n }\n\n get mapToPropertyPropertyName(): string | undefined {\n if (!this.mapToProperty) return undefined\n\n return this.mapToProperty!.split(\".\")[1]\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/query-builder/JoinAttribute.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAGvD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEnD;;GAEG;AACH,MAAM,OAAO,aAAa;IAmCtB,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YACY,UAAsB,EACtB,kBAAsC,EAC9C,aAA6B;QAFrB,eAAU,GAAV,UAAU,CAAY;QACtB,uBAAkB,GAAlB,kBAAkB,CAAoB;QAoBlD,wBAAmB,GAAY,KAAK,CAAA;QAuEpC,sBAAiB,GAAY,KAAK,CAAA;QAxF9B,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,IAAI,E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CAAC,CAAA;IAC5C,CAAC;IAED,IAAI,yBAAyB;QACzB,IAAI,CAAC,IAAI,CAAC,aAAa;YAAE,OAAO,SAAS,CAAA;QAEzC,OAAO,IAAI,CAAC,aAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAC5C,CAAC;CACJ","file":"JoinAttribute.js","sourcesContent":["import { EntityMetadata } from \"../metadata/EntityMetadata\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { RelationMetadata } from \"../metadata/RelationMetadata\"\nimport { QueryBuilderUtils } from \"./QueryBuilderUtils\"\nimport { QueryExpressionMap } from \"./QueryExpressionMap\"\nimport { Alias } from \"./Alias\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\nimport { TypeORMError } from \"../error\"\nimport { DriverUtils } from \"../driver/DriverUtils\"\n\n/**\n * Stores all join attributes which will be used to build a JOIN query.\n */\nexport class JoinAttribute {\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Join direction.\n */\n direction: \"LEFT\" | \"INNER\"\n\n /**\n * Alias of the joined (destination) table.\n */\n alias: Alias\n\n /**\n * Joined table, entity target, or relation in \"post.category\" format.\n */\n entityOrProperty: Function | string\n\n /**\n * Extra condition applied to \"ON\" section of join.\n */\n condition?: string\n\n /**\n * Property + alias of the object where to joined data should be mapped.\n */\n mapToProperty?: string\n\n /**\n * Indicates if user maps one or many objects from the join.\n */\n isMappingMany?: boolean\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n private connection: DataSource,\n private queryExpressionMap: QueryExpressionMap,\n joinAttribute?: JoinAttribute,\n ) {\n ObjectUtils.assign(this, joinAttribute || {})\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n get isMany(): boolean {\n if (this.isMappingMany !== undefined) return this.isMappingMany\n\n if (this.relation)\n return this.relation.isManyToMany || this.relation.isOneToMany\n\n return false\n }\n\n isSelectedCache: boolean\n isSelectedEvaluated: boolean = false\n /**\n * Indicates if this join is selected.\n */\n get isSelected(): boolean {\n if (!this.isSelectedEvaluated) {\n let getValue = () => {\n for (const select of this.queryExpressionMap.selects) {\n if (select.selection === this.alias.name) return true\n\n if (\n this.metadata &&\n !!this.metadata.columns.find(\n (column) =>\n select.selection ===\n this.alias.name + \".\" + column.propertyPath,\n )\n )\n return true\n }\n\n return false\n }\n this.isSelectedCache = getValue()\n this.isSelectedEvaluated = true\n }\n return this.isSelectedCache\n }\n\n /**\n * Name of the table which we should join.\n */\n get tablePath(): string {\n return this.metadata\n ? this.metadata.tablePath\n : (this.entityOrProperty as string)\n }\n\n /**\n * Alias of the parent of this join.\n * For example, if we join (\"post.category\", \"categoryAlias\") then \"post\" is a parent alias.\n * This value is extracted from entityOrProperty value.\n * This is available when join was made using \"post.category\" syntax.\n */\n get parentAlias(): string | undefined {\n if (!QueryBuilderUtils.isAliasProperty(this.entityOrProperty))\n return undefined\n\n return this.entityOrProperty.substr(\n 0,\n this.entityOrProperty.indexOf(\".\"),\n )\n }\n\n /**\n * Relation property name of the parent.\n * This is used to understand what is joined.\n * For example, if we join (\"post.category\", \"categoryAlias\") then \"category\" is a relation property.\n * This value is extracted from entityOrProperty value.\n * This is available when join was made using \"post.category\" syntax.\n */\n get relationPropertyPath(): string | undefined {\n if (!QueryBuilderUtils.isAliasProperty(this.entityOrProperty))\n return undefined\n\n return this.entityOrProperty.substr(\n this.entityOrProperty.indexOf(\".\") + 1,\n )\n }\n\n relationCache: RelationMetadata | undefined\n relationEvaluated: boolean = false\n /**\n * Relation of the parent.\n * This is used to understand what is joined.\n * This is available when join was made using \"post.category\" syntax.\n * Relation can be undefined if entityOrProperty is regular entity or custom table.\n */\n get relation(): RelationMetadata | undefined {\n if (!this.relationEvaluated) {\n let getValue = () => {\n if (!QueryBuilderUtils.isAliasProperty(this.entityOrProperty))\n return undefined\n\n const relationOwnerSelection =\n this.queryExpressionMap.findAliasByName(this.parentAlias!)\n let relation =\n relationOwnerSelection.metadata.findRelationWithPropertyPath(\n this.relationPropertyPath!,\n )\n\n if (relation) {\n return relation\n }\n\n if (relationOwnerSelection.metadata.parentEntityMetadata) {\n relation =\n relationOwnerSelection.metadata.parentEntityMetadata.findRelationWithPropertyPath(\n this.relationPropertyPath!,\n )\n if (relation) {\n return relation\n }\n }\n\n throw new TypeORMError(\n `Relation with property path ${this.relationPropertyPath} in entity was not found.`,\n )\n }\n this.relationCache = getValue.bind(this)()\n this.relationEvaluated = true\n }\n return this.relationCache\n }\n\n /**\n * Metadata of the joined entity.\n * If table without entity was joined, then it will return undefined.\n */\n get metadata(): EntityMetadata | undefined {\n // entityOrProperty is relation, e.g. \"post.category\"\n if (this.relation) return this.relation.inverseEntityMetadata\n\n // entityOrProperty is Entity class\n if (this.connection.hasMetadata(this.entityOrProperty))\n return this.connection.getMetadata(this.entityOrProperty)\n\n return undefined\n\n /*if (typeof this.entityOrProperty === \"string\") { // entityOrProperty is a custom table\n\n // first try to find entity with such name, this is needed when entity does not have a target class,\n // and its target is a string name (scenario when plain old javascript is used or entity schema is loaded from files)\n const metadata = this.connection.entityMetadatas.find(metadata => metadata.name === this.entityOrProperty);\n if (metadata)\n return metadata;\n\n // check if we have entity with such table name, and use its metadata if found\n return this.connection.entityMetadatas.find(metadata => metadata.tableName === this.entityOrProperty);\n }*/\n }\n\n /**\n * Generates alias of junction table, whose ids we get.\n */\n get junctionAlias(): string {\n if (!this.relation)\n throw new TypeORMError(\n `Cannot get junction table for join without relation.`,\n )\n\n if (this.relation.isOwning) {\n return DriverUtils.buildAlias(\n this.connection.driver,\n this.parentAlias!,\n this.alias.name,\n )\n } else {\n return DriverUtils.buildAlias(\n this.connection.driver,\n this.alias.name,\n this.parentAlias!,\n )\n }\n }\n\n get mapToPropertyParentAlias(): string | undefined {\n if (!this.mapToProperty) return undefined\n\n return this.mapToProperty!.split(\".\")[0]\n }\n\n get mapToPropertyPropertyName(): string | undefined {\n if (!this.mapToProperty) return undefined\n\n return this.mapToProperty!.split(\".\")[1]\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -258,7 +258,7 @@ export declare class SelectQueryBuilder<Entity extends ObjectLiteral> extends Qu
|
|
|
258
258
|
* You also need to specify an alias of the joined data.
|
|
259
259
|
* Optionally, you can add condition and parameters used in condition.
|
|
260
260
|
*/
|
|
261
|
-
innerJoinAndMapOne(mapToProperty: string, subQueryFactory: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, alias: string, condition?: string, parameters?: ObjectLiteral
|
|
261
|
+
innerJoinAndMapOne(mapToProperty: string, subQueryFactory: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, alias: string, condition?: string, parameters?: ObjectLiteral): this;
|
|
262
262
|
/**
|
|
263
263
|
* INNER JOINs entity's property, SELECTs the data returned by a join and MAPs all that data to some entity's property.
|
|
264
264
|
* This is extremely useful when you want to select some data and map it to some virtual property.
|
|
@@ -326,7 +326,7 @@ export declare class SelectQueryBuilder<Entity extends ObjectLiteral> extends Qu
|
|
|
326
326
|
* You also need to specify an alias of the joined data.
|
|
327
327
|
* Optionally, you can add condition and parameters used in condition.
|
|
328
328
|
*/
|
|
329
|
-
leftJoinAndMapOne(mapToProperty: string, subQueryFactory: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, alias: string, condition?: string, parameters?: ObjectLiteral
|
|
329
|
+
leftJoinAndMapOne(mapToProperty: string, subQueryFactory: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, alias: string, condition?: string, parameters?: ObjectLiteral): this;
|
|
330
330
|
/**
|
|
331
331
|
* LEFT JOINs entity's property, SELECTs the data returned by a join and MAPs all that data to some entity's property.
|
|
332
332
|
* This is extremely useful when you want to select some data and map it to some virtual property.
|
|
@@ -610,7 +610,7 @@ export declare class SelectQueryBuilder<Entity extends ObjectLiteral> extends Qu
|
|
|
610
610
|
* Sets extra options that can be used to configure how query builder works.
|
|
611
611
|
*/
|
|
612
612
|
setOption(option: SelectQueryBuilderOption): this;
|
|
613
|
-
protected join(direction: "INNER" | "LEFT", entityOrProperty: Function | string | ((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>), aliasName: string, condition?: string, parameters?: ObjectLiteral, mapToProperty?: string, isMappingMany?: boolean
|
|
613
|
+
protected join(direction: "INNER" | "LEFT", entityOrProperty: Function | string | ((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>), aliasName: string, condition?: string, parameters?: ObjectLiteral, mapToProperty?: string, isMappingMany?: boolean): void;
|
|
614
614
|
/**
|
|
615
615
|
* Creates "SELECT FROM" part of SQL query.
|
|
616
616
|
*/
|
|
@@ -658,7 +658,6 @@ export declare class SelectQueryBuilder<Entity extends ObjectLiteral> extends Qu
|
|
|
658
658
|
protected executeCountQuery(queryRunner: QueryRunner): Promise<number>;
|
|
659
659
|
protected executeExistsQuery(queryRunner: QueryRunner): Promise<boolean>;
|
|
660
660
|
protected applyFindOptions(): void;
|
|
661
|
-
concatRelationMetadata(relationMetadata: RelationMetadata): void;
|
|
662
661
|
/**
|
|
663
662
|
* Executes sql generated by query builder and returns object with raw results and entities created from them.
|
|
664
663
|
*/
|
|
@@ -18,11 +18,10 @@ import { DriverUtils } from "../driver/DriverUtils";
|
|
|
18
18
|
import { EntityNotFoundError } from "../error/EntityNotFoundError";
|
|
19
19
|
import { TypeORMError } from "../error";
|
|
20
20
|
import { FindOptionsUtils } from "../find-options/FindOptionsUtils";
|
|
21
|
+
import { ApplyValueTransformers } from "../util/ApplyValueTransformers";
|
|
21
22
|
import { OrmUtils } from "../util/OrmUtils";
|
|
22
23
|
import { EntityPropertyNotFoundError } from "../error/EntityPropertyNotFoundError";
|
|
23
24
|
import { InstanceChecker } from "../util/InstanceChecker";
|
|
24
|
-
import { FindOperator } from "../find-options/FindOperator";
|
|
25
|
-
import { ApplyValueTransformers } from "../util/ApplyValueTransformers";
|
|
26
25
|
/**
|
|
27
26
|
* Allows to build complex sql queries in a fashion way and execute those queries.
|
|
28
27
|
*/
|
|
@@ -230,9 +229,9 @@ export class SelectQueryBuilder extends QueryBuilder {
|
|
|
230
229
|
* You also need to specify an alias of the joined data.
|
|
231
230
|
* Optionally, you can add condition and parameters used in condition.
|
|
232
231
|
*/
|
|
233
|
-
innerJoinAndMapOne(mapToProperty, entityOrProperty, alias, condition, parameters
|
|
232
|
+
innerJoinAndMapOne(mapToProperty, entityOrProperty, alias, condition, parameters) {
|
|
234
233
|
this.addSelect(alias);
|
|
235
|
-
this.join("INNER", entityOrProperty, alias, condition, parameters, mapToProperty, false
|
|
234
|
+
this.join("INNER", entityOrProperty, alias, condition, parameters, mapToProperty, false);
|
|
236
235
|
return this;
|
|
237
236
|
}
|
|
238
237
|
/**
|
|
@@ -254,9 +253,9 @@ export class SelectQueryBuilder extends QueryBuilder {
|
|
|
254
253
|
* You also need to specify an alias of the joined data.
|
|
255
254
|
* Optionally, you can add condition and parameters used in condition.
|
|
256
255
|
*/
|
|
257
|
-
leftJoinAndMapOne(mapToProperty, entityOrProperty, alias, condition, parameters
|
|
256
|
+
leftJoinAndMapOne(mapToProperty, entityOrProperty, alias, condition, parameters) {
|
|
258
257
|
this.addSelect(alias);
|
|
259
|
-
this.join("LEFT", entityOrProperty, alias, condition, parameters, mapToProperty, false
|
|
258
|
+
this.join("LEFT", entityOrProperty, alias, condition, parameters, mapToProperty, false);
|
|
260
259
|
return this;
|
|
261
260
|
}
|
|
262
261
|
/**
|
|
@@ -942,11 +941,10 @@ export class SelectQueryBuilder extends QueryBuilder {
|
|
|
942
941
|
// -------------------------------------------------------------------------
|
|
943
942
|
// Protected Methods
|
|
944
943
|
// -------------------------------------------------------------------------
|
|
945
|
-
join(direction, entityOrProperty, aliasName, condition, parameters, mapToProperty, isMappingMany
|
|
944
|
+
join(direction, entityOrProperty, aliasName, condition, parameters, mapToProperty, isMappingMany) {
|
|
946
945
|
this.setParameters(parameters || {});
|
|
947
946
|
const joinAttribute = new JoinAttribute(this.connection, this.expressionMap);
|
|
948
947
|
joinAttribute.direction = direction;
|
|
949
|
-
joinAttribute.mapAsEntity = mapAsEntity;
|
|
950
948
|
joinAttribute.mapToProperty = mapToProperty;
|
|
951
949
|
joinAttribute.isMappingMany = isMappingMany;
|
|
952
950
|
joinAttribute.entityOrProperty = entityOrProperty; // relationName
|
|
@@ -1900,9 +1898,6 @@ export class SelectQueryBuilder extends QueryBuilder {
|
|
|
1900
1898
|
// }
|
|
1901
1899
|
}
|
|
1902
1900
|
}
|
|
1903
|
-
concatRelationMetadata(relationMetadata) {
|
|
1904
|
-
this.relationMetadatas.push(relationMetadata);
|
|
1905
|
-
}
|
|
1906
1901
|
/**
|
|
1907
1902
|
* Executes sql generated by query builder and returns object with raw results and entities created from them.
|
|
1908
1903
|
*/
|
|
@@ -2255,7 +2250,7 @@ export class SelectQueryBuilder extends QueryBuilder {
|
|
|
2255
2250
|
if (relationValue === true ||
|
|
2256
2251
|
typeof relationValue === "object") {
|
|
2257
2252
|
if (this.expressionMap.relationLoadStrategy === "query") {
|
|
2258
|
-
this.
|
|
2253
|
+
this.relationMetadatas.push(relation);
|
|
2259
2254
|
}
|
|
2260
2255
|
else {
|
|
2261
2256
|
// join
|
|
@@ -2443,10 +2438,7 @@ export class SelectQueryBuilder extends QueryBuilder {
|
|
|
2443
2438
|
parameterValue = where[key].value;
|
|
2444
2439
|
}
|
|
2445
2440
|
if (column.transformer) {
|
|
2446
|
-
parameterValue
|
|
2447
|
-
? parameterValue.transformValue(column.transformer)
|
|
2448
|
-
: (parameterValue =
|
|
2449
|
-
ApplyValueTransformers.transformTo(column.transformer, parameterValue));
|
|
2441
|
+
parameterValue = ApplyValueTransformers.transformTo(column.transformer, parameterValue);
|
|
2450
2442
|
}
|
|
2451
2443
|
// if (parameterValue === null) {
|
|
2452
2444
|
// andConditions.push(`${aliasPath} IS NULL`);
|