typeorm 0.3.13-dev.97280fc → 0.3.13-dev.a11809e
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/sqlite-abstract/AbstractSqliteDriver.js +7 -0
- package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/browser/entity-schema/EntitySchemaInheritanceOptions.d.ts +11 -0
- package/browser/entity-schema/EntitySchemaInheritanceOptions.js +3 -0
- package/browser/entity-schema/EntitySchemaInheritanceOptions.js.map +1 -0
- package/browser/entity-schema/EntitySchemaOptions.d.ts +5 -4
- package/browser/entity-schema/EntitySchemaOptions.js.map +1 -1
- package/browser/entity-schema/EntitySchemaTransformer.js +13 -0
- package/browser/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/browser/find-options/FindOperator.d.ts +2 -0
- package/browser/find-options/FindOperator.js +13 -0
- package/browser/find-options/FindOperator.js.map +1 -1
- package/browser/find-options/FindOptionsUtils.js +45 -15
- 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 +8 -2
- package/browser/migration/MigrationExecutor.js.map +1 -1
- package/browser/query-builder/JoinAttribute.d.ts +4 -0
- package/browser/query-builder/JoinAttribute.js +4 -0
- package/browser/query-builder/JoinAttribute.js.map +1 -1
- package/browser/query-builder/SelectQueryBuilder.d.ts +4 -3
- package/browser/query-builder/SelectQueryBuilder.js +16 -8
- package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteDriver.js +7 -0
- package/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/entity-schema/EntitySchemaInheritanceOptions.d.ts +11 -0
- package/entity-schema/EntitySchemaInheritanceOptions.js +4 -0
- package/entity-schema/EntitySchemaInheritanceOptions.js.map +1 -0
- package/entity-schema/EntitySchemaOptions.d.ts +5 -4
- package/entity-schema/EntitySchemaOptions.js.map +1 -1
- package/entity-schema/EntitySchemaTransformer.js +13 -0
- package/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/find-options/FindOperator.d.ts +2 -0
- package/find-options/FindOperator.js +13 -0
- package/find-options/FindOperator.js.map +1 -1
- package/find-options/FindOptionsUtils.js +46 -16
- 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 +8 -2
- package/migration/MigrationExecutor.js.map +1 -1
- package/package.json +1 -1
- package/query-builder/JoinAttribute.d.ts +4 -0
- package/query-builder/JoinAttribute.js +4 -0
- package/query-builder/JoinAttribute.js.map +1 -1
- package/query-builder/SelectQueryBuilder.d.ts +4 -3
- package/query-builder/SelectQueryBuilder.js +16 -8
- package/query-builder/SelectQueryBuilder.js.map +1 -1
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "name": "typeorm", "private": false, "version": "0.3.13-dev.
|
|
1
|
+
{ "name": "typeorm", "private": false, "version": "0.3.13-dev.a11809e", "description": "Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, MongoDB databases.", "license": "MIT", "readmeFilename": "README.md", "author": { "name": "Umed Khudoiberdiev", "email": "pleerock.me@gmail.com" }, "engines": { "node": ">= 12.9.0" }, "exports": { ".": { "types": "./index.d.ts", "node": { "import": "./index.mjs", "require": "./index.js", "types": "./index.d.ts" }, "browser": { "require": "./index.js", "import": "./browser/index.js", "default": "./index.js" } }, "./browser": { "types": "./index.d.ts", "default": "./browser/index.js" }, "./*.js": "./*.js", "./*": { "require": "./*.js", "import": "./*" } }, "main": "./index.js", "module": "./index.mjs", "types": "./index.d.ts", "browser": { "./browser/connection/ConnectionOptionsReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/connection/options-reader/ConnectionOptionsXmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/connection/options-reader/ConnectionOptionsYmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/driver/aurora-data-api/AuroraDataApiDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/better-sqlite3/BetterSqlite3Driver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/cockroachdb/CockroachDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/MongoDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/MongoQueryRunner.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mysql/MysqlDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/oracle/OracleDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/postgres/PostgresDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sap/SapDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sqlite/SqliteDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sqlserver/SqlServerDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/entity-manager/MongoEntityManager.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/logger/FileLogger.js": "./browser/platform/BrowserFileLoggerDummy.js", "./browser/platform/PlatformTools.js": "./browser/platform/BrowserPlatformTools.js", "./browser/repository/MongoRepository.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/util/DirectoryExportedClassesLoader.js": "./browser/platform/BrowserDirectoryExportedClassesLoader.js", "./index.js": "./browser/index.js", "./index.mjs": "./browser/index.js" }, "repository": { "type": "git", "url": "https://github.com/typeorm/typeorm.git" }, "bugs": { "url": "https://github.com/typeorm/typeorm/issues" }, "homepage": "https://typeorm.io", "tags": [ "orm", "typescript", "typescript-orm", "mysql", "mysql-orm", "postgresql", "postgresql-orm", "mariadb", "mariadb-orm", "spanner", "sqlite", "sqlite-orm", "sql-server", "sql-server-orm", "oracle", "oracle-orm", "cloud-spanner", "cloud-spanner-orm" ], "devDependencies": { "@types/app-root-path": "^1.2.4", "@types/chai": "^4.3.4", "@types/chai-as-promised": "^7.1.5", "@types/debug": "^4.1.7", "@types/js-yaml": "^4.0.5", "@types/mkdirp": "^1.0.2", "@types/mocha": "^10.0.1", "@types/node": "^18.13.0", "@types/sha.js": "^2.4.0", "@types/sinon": "^10.0.13", "@types/source-map-support": "^0.5.6", "@types/uuid": "^9.0.0", "@types/xml2js": "^0.4.11", "@types/yargs": "^17.0.22", "better-sqlite3": "^8.1.0", "chai": "^4.3.7", "chai-as-promised": "^7.1.1", "class-transformer": "^0.5.1", "conventional-changelog-angular": "^5.0.13", "conventional-changelog-cli": "^2.2.2", "del": "6.1.1", "gulp": "^4.0.2", "gulp-istanbul": "^1.1.3", "gulp-mocha": "^8.0.0", "gulp-rename": "^2.0.0", "gulp-replace": "^1.1.4", "gulp-shell": "^0.8.0", "gulp-sourcemaps": "^3.0.0", "gulp-typescript": "^6.0.0-alpha.1", "gulpclass": "^0.2.0", "husky": "^8.0.3", "mocha": "^10.2.0", "mongodb": "^3.7.3", "mssql": "^9.1.1", "mysql": "^2.18.1", "mysql2": "^3.1.1", "pg": "^8.9.0", "pg-query-stream": "^4.3.0", "prettier": "^2.8.3", "redis": "^4.6.4", "remap-istanbul": "^0.13.0", "rimraf": "^4.1.2", "sinon": "^15.0.1", "sinon-chai": "^3.7.0", "source-map-support": "^0.5.21", "sql.js": "^1.8.0", "sqlite3": "^5.1.4", "ts-node": "^10.9.1", "typeorm-aurora-data-api-driver": "^2.4.4", "typescript": "^4.9.5" }, "peerDependencies": { "@google-cloud/spanner": "^5.18.0", "@sap/hana-client": "^2.12.25", "better-sqlite3": "^7.1.2 || ^8.0.0", "hdb-pool": "^0.1.6", "ioredis": "^5.0.4", "mongodb": "^3.6.0", "mssql": "^9.1.1", "mysql2": "^2.2.5 || ^3.0.1", "oracledb": "^5.1.0", "pg": "^8.5.1", "pg-native": "^3.0.0", "pg-query-stream": "^4.0.0", "redis": "^3.1.1 || ^4.0.0", "sql.js": "^1.4.0", "sqlite3": "^5.0.3", "ts-node": "^10.7.0", "typeorm-aurora-data-api-driver": "^2.0.0" }, "peerDependenciesMeta": { "@google-cloud/spanner": { "optional": true }, "@sap/hana-client": { "optional": true }, "better-sqlite3": { "optional": true }, "hdb-pool": { "optional": true }, "ioredis": { "optional": true }, "mongodb": { "optional": true }, "mssql": { "optional": true }, "mysql2": { "optional": true }, "oracledb": { "optional": true }, "pg": { "optional": true }, "pg-native": { "optional": true }, "pg-query-stream": { "optional": true }, "redis": { "optional": true }, "sql.js": { "optional": true }, "sqlite3": { "optional": true }, "ts-node": { "optional": true }, "typeorm-aurora-data-api-driver": { "optional": true } }, "dependencies": { "@sqltools/formatter": "^1.2.5", "app-root-path": "^3.1.0", "buffer": "^6.0.3", "chalk": "^4.1.2", "cli-highlight": "^2.1.11", "debug": "^4.3.4", "dotenv": "^16.0.3", "glob": "^8.1.0", "js-yaml": "^4.1.0", "mkdirp": "^2.1.3", "reflect-metadata": "^0.1.13", "sha.js": "^2.4.11", "tslib": "^2.5.0", "uuid": "^9.0.0", "xml2js": "^0.4.23", "yargs": "^17.6.2" }, "scripts": { "test": "rimraf ./build && tsc && mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 60000 ./build/compiled/test", "test-fast": "mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 60000 ./build/compiled/test", "compile": "rimraf ./build && tsc", "watch": "./node_modules/.bin/tsc -w", "package": "gulp package", "pack": "gulp pack", "lint": "prettier --check \"./src/**/*.ts\" \"./test/**/*.ts\" \"./sample/**/*.ts\"", "format": "prettier --write \"./src/**/*.ts\" \"./test/**/*.ts\" \"./sample/**/*.ts\"", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 2" }, "bin": { "typeorm": "./cli.js", "typeorm-ts-node-commonjs": "./cli-ts-node-commonjs.js", "typeorm-ts-node-esm": "./cli-ts-node-esm.js" }, "funding": "https://opencollective.com/typeorm", "collective": { "type": "opencollective", "url": "https://opencollective.com/typeorm", "logo": "https://opencollective.com/opencollective/logo.txt" }, "nyc": { "all": true, "cache": false, "exclude": [ "**/*.d.ts" ], "extension": [ ".ts" ], "include": [ "build/compiled/src/**", "src/**" ], "reporter": "json" } }
|
|
@@ -33,6 +33,10 @@ export declare class JoinAttribute {
|
|
|
33
33
|
* Indicates if user maps one or many objects from the join.
|
|
34
34
|
*/
|
|
35
35
|
isMappingMany?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Useful when the joined expression is a custom query to support mapping.
|
|
38
|
+
*/
|
|
39
|
+
mapAsEntity?: Function | string;
|
|
36
40
|
constructor(connection: DataSource, queryExpressionMap: QueryExpressionMap, joinAttribute?: JoinAttribute);
|
|
37
41
|
get isMany(): boolean;
|
|
38
42
|
isSelectedCache: boolean;
|
|
@@ -122,6 +122,10 @@ class JoinAttribute {
|
|
|
122
122
|
// entityOrProperty is Entity class
|
|
123
123
|
if (this.connection.hasMetadata(this.entityOrProperty))
|
|
124
124
|
return this.connection.getMetadata(this.entityOrProperty);
|
|
125
|
+
// Overriden mapping entity provided for leftJoinAndMapOne with custom query builder
|
|
126
|
+
if (this.mapAsEntity && this.connection.hasMetadata(this.mapAsEntity)) {
|
|
127
|
+
return this.connection.getMetadata(this.mapAsEntity);
|
|
128
|
+
}
|
|
125
129
|
return undefined;
|
|
126
130
|
/*if (typeof this.entityOrProperty === "string") { // entityOrProperty is a custom table
|
|
127
131
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/query-builder/JoinAttribute.ts"],"names":[],"mappings":";;;AAGA,2DAAuD;AAGvD,qDAAiD;AACjD,oCAAuC;AACvC,uDAAmD;AAEnD;;GAEG;AACH,MAAa,aAAa;IAmCtB,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAC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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;AA9OD,sCA8OC","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":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/query-builder/JoinAttribute.ts"],"names":[],"mappings":";;;AAGA,2DAAuD;AAGvD,qDAAiD;AACjD,oCAAuC;AACvC,uDAAmD;AAEnD;;GAEG;AACH,MAAa,aAAa;IAwCtB,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,yBAAW,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,IAAI,EAAE,CAAC,CAAA;IACjD,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E,IAAI,MAAM;QACN,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC,aAAa,CAAA;QAE/D,IAAI,IAAI,CAAC,QAAQ;YACb,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAA;QAElE,OAAO,KAAK,CAAA;IAChB,CAAC;IAID;;OAEG;IACH,IAAI,UAAU;QACV,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE;YAC3B,IAAI,QAAQ,GAAG,GAAG,EAAE;gBAChB,KAAK,MAAM,MAAM,IAAI,IAAI,CAA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ata/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":".."}
|
|
@@ -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): this;
|
|
261
|
+
innerJoinAndMapOne(mapToProperty: string, subQueryFactory: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, alias: string, condition?: string, parameters?: ObjectLiteral, mapAsEntity?: Function | string): 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): this;
|
|
329
|
+
leftJoinAndMapOne(mapToProperty: string, subQueryFactory: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>, alias: string, condition?: string, parameters?: ObjectLiteral, mapAsEntity?: Function | string): 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): void;
|
|
613
|
+
protected join(direction: "INNER" | "LEFT", entityOrProperty: Function | string | ((qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>), aliasName: string, condition?: string, parameters?: ObjectLiteral, mapToProperty?: string, isMappingMany?: boolean, mapAsEntity?: Function | string): void;
|
|
614
614
|
/**
|
|
615
615
|
* Creates "SELECT FROM" part of SQL query.
|
|
616
616
|
*/
|
|
@@ -658,6 +658,7 @@ 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;
|
|
661
662
|
/**
|
|
662
663
|
* Executes sql generated by query builder and returns object with raw results and entities created from them.
|
|
663
664
|
*/
|
|
@@ -21,10 +21,11 @@ const DriverUtils_1 = require("../driver/DriverUtils");
|
|
|
21
21
|
const EntityNotFoundError_1 = require("../error/EntityNotFoundError");
|
|
22
22
|
const error_1 = require("../error");
|
|
23
23
|
const FindOptionsUtils_1 = require("../find-options/FindOptionsUtils");
|
|
24
|
-
const ApplyValueTransformers_1 = require("../util/ApplyValueTransformers");
|
|
25
24
|
const OrmUtils_1 = require("../util/OrmUtils");
|
|
26
25
|
const EntityPropertyNotFoundError_1 = require("../error/EntityPropertyNotFoundError");
|
|
27
26
|
const InstanceChecker_1 = require("../util/InstanceChecker");
|
|
27
|
+
const FindOperator_1 = require("../find-options/FindOperator");
|
|
28
|
+
const ApplyValueTransformers_1 = require("../util/ApplyValueTransformers");
|
|
28
29
|
/**
|
|
29
30
|
* Allows to build complex sql queries in a fashion way and execute those queries.
|
|
30
31
|
*/
|
|
@@ -232,9 +233,9 @@ class SelectQueryBuilder extends QueryBuilder_1.QueryBuilder {
|
|
|
232
233
|
* You also need to specify an alias of the joined data.
|
|
233
234
|
* Optionally, you can add condition and parameters used in condition.
|
|
234
235
|
*/
|
|
235
|
-
innerJoinAndMapOne(mapToProperty, entityOrProperty, alias, condition, parameters) {
|
|
236
|
+
innerJoinAndMapOne(mapToProperty, entityOrProperty, alias, condition, parameters, mapAsEntity) {
|
|
236
237
|
this.addSelect(alias);
|
|
237
|
-
this.join("INNER", entityOrProperty, alias, condition, parameters, mapToProperty, false);
|
|
238
|
+
this.join("INNER", entityOrProperty, alias, condition, parameters, mapToProperty, false, mapAsEntity);
|
|
238
239
|
return this;
|
|
239
240
|
}
|
|
240
241
|
/**
|
|
@@ -256,9 +257,9 @@ class SelectQueryBuilder extends QueryBuilder_1.QueryBuilder {
|
|
|
256
257
|
* You also need to specify an alias of the joined data.
|
|
257
258
|
* Optionally, you can add condition and parameters used in condition.
|
|
258
259
|
*/
|
|
259
|
-
leftJoinAndMapOne(mapToProperty, entityOrProperty, alias, condition, parameters) {
|
|
260
|
+
leftJoinAndMapOne(mapToProperty, entityOrProperty, alias, condition, parameters, mapAsEntity) {
|
|
260
261
|
this.addSelect(alias);
|
|
261
|
-
this.join("LEFT", entityOrProperty, alias, condition, parameters, mapToProperty, false);
|
|
262
|
+
this.join("LEFT", entityOrProperty, alias, condition, parameters, mapToProperty, false, mapAsEntity);
|
|
262
263
|
return this;
|
|
263
264
|
}
|
|
264
265
|
/**
|
|
@@ -944,10 +945,11 @@ class SelectQueryBuilder extends QueryBuilder_1.QueryBuilder {
|
|
|
944
945
|
// -------------------------------------------------------------------------
|
|
945
946
|
// Protected Methods
|
|
946
947
|
// -------------------------------------------------------------------------
|
|
947
|
-
join(direction, entityOrProperty, aliasName, condition, parameters, mapToProperty, isMappingMany) {
|
|
948
|
+
join(direction, entityOrProperty, aliasName, condition, parameters, mapToProperty, isMappingMany, mapAsEntity) {
|
|
948
949
|
this.setParameters(parameters || {});
|
|
949
950
|
const joinAttribute = new JoinAttribute_1.JoinAttribute(this.connection, this.expressionMap);
|
|
950
951
|
joinAttribute.direction = direction;
|
|
952
|
+
joinAttribute.mapAsEntity = mapAsEntity;
|
|
951
953
|
joinAttribute.mapToProperty = mapToProperty;
|
|
952
954
|
joinAttribute.isMappingMany = isMappingMany;
|
|
953
955
|
joinAttribute.entityOrProperty = entityOrProperty; // relationName
|
|
@@ -1901,6 +1903,9 @@ class SelectQueryBuilder extends QueryBuilder_1.QueryBuilder {
|
|
|
1901
1903
|
// }
|
|
1902
1904
|
}
|
|
1903
1905
|
}
|
|
1906
|
+
concatRelationMetadata(relationMetadata) {
|
|
1907
|
+
this.relationMetadatas.push(relationMetadata);
|
|
1908
|
+
}
|
|
1904
1909
|
/**
|
|
1905
1910
|
* Executes sql generated by query builder and returns object with raw results and entities created from them.
|
|
1906
1911
|
*/
|
|
@@ -2253,7 +2258,7 @@ class SelectQueryBuilder extends QueryBuilder_1.QueryBuilder {
|
|
|
2253
2258
|
if (relationValue === true ||
|
|
2254
2259
|
typeof relationValue === "object") {
|
|
2255
2260
|
if (this.expressionMap.relationLoadStrategy === "query") {
|
|
2256
|
-
this.
|
|
2261
|
+
this.concatRelationMetadata(relation);
|
|
2257
2262
|
}
|
|
2258
2263
|
else {
|
|
2259
2264
|
// join
|
|
@@ -2441,7 +2446,10 @@ class SelectQueryBuilder extends QueryBuilder_1.QueryBuilder {
|
|
|
2441
2446
|
parameterValue = where[key].value;
|
|
2442
2447
|
}
|
|
2443
2448
|
if (column.transformer) {
|
|
2444
|
-
parameterValue
|
|
2449
|
+
parameterValue instanceof FindOperator_1.FindOperator
|
|
2450
|
+
? parameterValue.transformValue(column.transformer)
|
|
2451
|
+
: (parameterValue =
|
|
2452
|
+
ApplyValueTransformers_1.ApplyValueTransformers.transformTo(column.transformer, parameterValue));
|
|
2445
2453
|
}
|
|
2446
2454
|
// if (parameterValue === null) {
|
|
2447
2455
|
// andConditions.push(`${aliasPath} IS NULL`);
|