typeorm 0.2.39-dev.2133ffe → 0.2.39-dev.25271d7
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/README.md +37 -36
- package/browser/decorator/entity-view/ViewEntity.js +1 -0
- package/browser/decorator/entity-view/ViewEntity.js.map +1 -1
- package/browser/decorator/options/ViewEntityOptions.d.ts +5 -0
- package/browser/decorator/options/ViewEntityOptions.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachDriver.js +23 -14
- package/browser/driver/cockroachdb/CockroachDriver.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachQueryRunner.js +62 -68
- package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/browser/driver/cordova/CordovaDriver.d.ts +1 -1
- package/browser/driver/cordova/CordovaDriver.js +25 -18
- package/browser/driver/cordova/CordovaDriver.js.map +1 -1
- package/browser/driver/cordova/CordovaQueryRunner.js +50 -43
- package/browser/driver/cordova/CordovaQueryRunner.js.map +1 -1
- package/browser/driver/postgres/PostgresDriver.d.ts +2 -2
- package/browser/driver/postgres/PostgresDriver.js +31 -40
- package/browser/driver/postgres/PostgresDriver.js.map +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.js +7 -15
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/driver/sap/SapQueryRunner.js +10 -28
- package/browser/driver/sap/SapQueryRunner.js.map +1 -1
- package/browser/driver/sqljs/SqljsDriver.js +5 -22
- package/browser/driver/sqljs/SqljsDriver.js.map +1 -1
- package/browser/driver/sqljs/SqljsQueryRunner.js +9 -10
- package/browser/driver/sqljs/SqljsQueryRunner.js.map +1 -1
- package/browser/metadata/EntityMetadata.d.ts +5 -0
- package/browser/metadata/EntityMetadata.js +1 -0
- package/browser/metadata/EntityMetadata.js.map +1 -1
- package/browser/metadata-args/TableMetadataArgs.d.ts +4 -0
- package/browser/metadata-args/TableMetadataArgs.js.map +1 -1
- package/browser/migration/MigrationExecutor.d.ts +1 -1
- package/browser/migration/MigrationExecutor.js +6 -14
- package/browser/migration/MigrationExecutor.js.map +1 -1
- package/browser/persistence/SubjectExecutor.js +3 -3
- package/browser/persistence/SubjectExecutor.js.map +1 -1
- package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.js +2 -8
- package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
- package/browser/schema-builder/RdbmsSchemaBuilder.js +223 -148
- package/browser/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/browser/schema-builder/util/ViewUtils.d.ts +7 -0
- package/browser/schema-builder/util/ViewUtils.js +25 -0
- package/browser/schema-builder/util/ViewUtils.js.map +1 -0
- package/decorator/entity-view/ViewEntity.js +1 -0
- package/decorator/entity-view/ViewEntity.js.map +1 -1
- package/decorator/options/ViewEntityOptions.d.ts +5 -0
- package/decorator/options/ViewEntityOptions.js.map +1 -1
- package/driver/cockroachdb/CockroachDriver.js +23 -14
- package/driver/cockroachdb/CockroachDriver.js.map +1 -1
- package/driver/cockroachdb/CockroachQueryRunner.js +62 -68
- package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/driver/cordova/CordovaDriver.d.ts +1 -1
- package/driver/cordova/CordovaDriver.js +25 -18
- package/driver/cordova/CordovaDriver.js.map +1 -1
- package/driver/cordova/CordovaQueryRunner.js +50 -43
- package/driver/cordova/CordovaQueryRunner.js.map +1 -1
- package/driver/postgres/PostgresDriver.d.ts +2 -2
- package/driver/postgres/PostgresDriver.js +31 -40
- package/driver/postgres/PostgresDriver.js.map +1 -1
- package/driver/postgres/PostgresQueryRunner.js +7 -15
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/driver/sap/SapQueryRunner.js +10 -28
- package/driver/sap/SapQueryRunner.js.map +1 -1
- package/driver/sqljs/SqljsDriver.js +5 -22
- package/driver/sqljs/SqljsDriver.js.map +1 -1
- package/driver/sqljs/SqljsQueryRunner.js +9 -10
- package/driver/sqljs/SqljsQueryRunner.js.map +1 -1
- package/metadata/EntityMetadata.d.ts +5 -0
- package/metadata/EntityMetadata.js +1 -0
- package/metadata/EntityMetadata.js.map +1 -1
- package/metadata-args/TableMetadataArgs.d.ts +4 -0
- package/metadata-args/TableMetadataArgs.js.map +1 -1
- package/migration/MigrationExecutor.d.ts +1 -1
- package/migration/MigrationExecutor.js +6 -14
- package/migration/MigrationExecutor.js.map +1 -1
- package/package.json +1 -1
- package/persistence/SubjectExecutor.js +3 -3
- package/persistence/SubjectExecutor.js.map +1 -1
- package/query-builder/transformer/RawSqlResultsToEntityTransformer.js +2 -8
- package/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
- package/schema-builder/RdbmsSchemaBuilder.js +222 -147
- package/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/schema-builder/util/ViewUtils.d.ts +7 -0
- package/schema-builder/util/ViewUtils.js +28 -0
- package/schema-builder/util/ViewUtils.js.map +1 -0
|
@@ -51,18 +51,10 @@ var SqljsDriver = /** @class */ (function (_super) {
|
|
|
51
51
|
*/
|
|
52
52
|
SqljsDriver.prototype.disconnect = function () {
|
|
53
53
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
54
|
-
var _this = this;
|
|
55
54
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
_this.databaseConnection.close();
|
|
60
|
-
ok();
|
|
61
|
-
}
|
|
62
|
-
catch (e) {
|
|
63
|
-
fail(e);
|
|
64
|
-
}
|
|
65
|
-
})];
|
|
55
|
+
this.queryRunner = undefined;
|
|
56
|
+
this.databaseConnection.close();
|
|
57
|
+
return [2 /*return*/];
|
|
66
58
|
});
|
|
67
59
|
});
|
|
68
60
|
};
|
|
@@ -265,7 +257,6 @@ var SqljsDriver = /** @class */ (function (_super) {
|
|
|
265
257
|
SqljsDriver.prototype.createDatabaseConnectionWithImport = function (database) {
|
|
266
258
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
267
259
|
var isLegacyVersion, sqlite, _a;
|
|
268
|
-
var _this = this;
|
|
269
260
|
return (0, tslib_1.__generator)(this, function (_b) {
|
|
270
261
|
switch (_b.label) {
|
|
271
262
|
case 0:
|
|
@@ -285,16 +276,8 @@ var SqljsDriver = /** @class */ (function (_super) {
|
|
|
285
276
|
else {
|
|
286
277
|
this.databaseConnection = new sqlite.Database();
|
|
287
278
|
}
|
|
288
|
-
|
|
289
|
-
return [2 /*return*/,
|
|
290
|
-
try {
|
|
291
|
-
_this.databaseConnection.exec("PRAGMA foreign_keys = ON;");
|
|
292
|
-
ok(_this.databaseConnection);
|
|
293
|
-
}
|
|
294
|
-
catch (e) {
|
|
295
|
-
fail(e);
|
|
296
|
-
}
|
|
297
|
-
})];
|
|
279
|
+
this.databaseConnection.exec("PRAGMA foreign_keys = ON;");
|
|
280
|
+
return [2 /*return*/, this.databaseConnection];
|
|
298
281
|
}
|
|
299
282
|
});
|
|
300
283
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/driver/sqljs/SqljsDriver.ts"],"names":[],"mappings":";;;;AAAA,gFAA6E;AAE7E,uDAAoD;AAGpD,6FAA0F;AAC1F,+EAA4E;AAC5E,8DAA2D;AAE3D,gDAA6C;AAG7C,qCAA2C;AAS3C;IAAiC,4CAAoB;IAIjD,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,qBAAY,UAAsB;QAAlC,YACI,kBAAM,UAAU,CAAC,SAUpB;QARG,8EAA8E;QAC9E,uEAAuE;QACvE,IAAI,KAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,KAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,KAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE;YACnF,MAAM,IAAI,iDAAuB,CAAC,8BAA8B,CAAC,CAAC;SACrE;QAED,sBAAsB;QACtB,KAAI,CAAC,gBAAgB,EAAE,CAAC;;IAC5B,CAAC;IAGD,4EAA4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I,IAAI,6BAAa,CAAC,IAAI,KAAK,SAAS,EAAE;YAClC,IAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,GAAG,CAAC;YACjD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;SACxB;aACI;YACD,IAAI;gBACA,IAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,6BAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACnE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;aAExB;YAAC,OAAO,CAAC,EAAE;gBACR,MAAM,IAAI,+DAA8B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;aAChE;SACJ;IACL,CAAC;IACL,kBAAC;AAAD,CA7QA,AA6QC,CA7QgC,2CAAoB,GA6QpD;AA7QY,kCAAW","file":"SqljsDriver.js","sourcesContent":["import {AbstractSqliteDriver} from \"../sqlite-abstract/AbstractSqliteDriver\";\nimport {SqljsConnectionOptions} from \"./SqljsConnectionOptions\";\nimport {SqljsQueryRunner} from \"./SqljsQueryRunner\";\nimport {QueryRunner} from \"../../query-runner/QueryRunner\";\nimport {Connection} from \"../../connection/Connection\";\nimport {DriverPackageNotInstalledError} from \"../../error/DriverPackageNotInstalledError\";\nimport {DriverOptionNotSetError} from \"../../error/DriverOptionNotSetError\";\nimport {PlatformTools} from \"../../platform/PlatformTools\";\nimport {EntityMetadata} from \"../../metadata/EntityMetadata\";\nimport {OrmUtils} from \"../../util/OrmUtils\";\nimport {ObjectLiteral} from \"../../common/ObjectLiteral\";\nimport {ReplicationMode} from \"../types/ReplicationMode\";\nimport { TypeORMError } from \"../../error\";\n\n// This is needed to satisfy the typescript compiler.\ninterface Window {\n SQL: any;\n localforage: any;\n}\ndeclare let window: Window;\n\nexport class SqljsDriver extends AbstractSqliteDriver {\n // The driver specific options.\n options: SqljsConnectionOptions;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(connection: Connection) {\n super(connection);\n\n // If autoSave is enabled by user, location or autoSaveCallback have to be set\n // because either autoSave saves to location or calls autoSaveCallback.\n if (this.options.autoSave && !this.options.location && !this.options.autoSaveCallback) {\n throw new DriverOptionNotSetError(`location or autoSaveCallback`);\n }\n\n // load sql.js package\n this.loadDependencies();\n }\n\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Performs connection to the database.\n */\n async connect(): Promise<void> {\n this.databaseConnection = await this.createDatabaseConnection();\n }\n\n /**\n * Closes connection with database.\n */\n async disconnect(): Promise<void> {\n return new Promise<void>((ok, fail) => {\n try {\n this.queryRunner = undefined;\n this.databaseConnection.close();\n ok();\n }\n catch (e) {\n fail(e);\n }\n });\n }\n\n /**\n * Creates a query runner used to execute database queries.\n */\n createQueryRunner(mode: ReplicationMode): QueryRunner {\n if (!this.queryRunner)\n this.queryRunner = new SqljsQueryRunner(this);\n\n return this.queryRunner;\n }\n\n /**\n * Loads a database from a given file (Node.js), local storage key (browser) or array.\n * This will delete the current database!\n */\n async load(fileNameOrLocalStorageOrData: string | Uint8Array, checkIfFileOrLocalStorageExists: boolean = true): Promise<any> {\n if (typeof fileNameOrLocalStorageOrData === \"string\") {\n // content has to be loaded\n if (PlatformTools.type === \"node\") {\n // Node.js\n // fileNameOrLocalStorageOrData should be a path to the file\n if (PlatformTools.fileExist(fileNameOrLocalStorageOrData)) {\n const database = PlatformTools.readFileSync(fileNameOrLocalStorageOrData);\n return this.createDatabaseConnectionWithImport(database);\n }\n else if (checkIfFileOrLocalStorageExists) {\n throw new TypeORMError(`File ${fileNameOrLocalStorageOrData} does not exist`);\n }\n else {\n // File doesn't exist and checkIfFileOrLocalStorageExists is set to false.\n // Therefore open a database without importing an existing file.\n // File will be written on first write operation.\n return this.createDatabaseConnectionWithImport();\n }\n }\n else {\n // browser\n // fileNameOrLocalStorageOrData should be a local storage / indexedDB key\n let localStorageContent = null;\n if (this.options.useLocalForage) {\n if (window.localforage) {\n localStorageContent = await window.localforage.getItem(fileNameOrLocalStorageOrData);\n } else {\n throw new TypeORMError(`localforage is not defined - please import localforage.js into your site`);\n }\n } else {\n localStorageContent = PlatformTools.getGlobalVariable().localStorage.getItem(fileNameOrLocalStorageOrData);\n }\n\n if (localStorageContent != null) {\n // localStorage value exists.\n return this.createDatabaseConnectionWithImport(JSON.parse(localStorageContent));\n }\n else if (checkIfFileOrLocalStorageExists) {\n throw new TypeORMError(`File ${fileNameOrLocalStorageOrData} does not exist`);\n }\n else {\n // localStorage value doesn't exist and checkIfFileOrLocalStorageExists is set to false.\n // Therefore open a database without importing anything.\n // localStorage value will be written on first write operation.\n return this.createDatabaseConnectionWithImport();\n }\n }\n }\n else {\n return this.createDatabaseConnectionWithImport(fileNameOrLocalStorageOrData);\n }\n }\n\n /**\n * Saved the current database to the given file (Node.js), local storage key (browser) or\n * indexedDB key (browser with enabled useLocalForage option).\n * If no location path is given, the location path in the options (if specified) will be used.\n */\n async save(location?: string) {\n if (!location && !this.options.location) {\n throw new TypeORMError(`No location is set, specify a location parameter or add the location option to your configuration`);\n }\n\n let path = \"\";\n if (location) {\n path = location;\n }\n else if (this.options.location) {\n path = this.options.location;\n }\n\n if (PlatformTools.type === \"node\") {\n try {\n const content = Buffer.from(this.databaseConnection.export());\n await PlatformTools.writeFile(path, content);\n }\n catch (e) {\n throw new TypeORMError(`Could not save database, error: ${e}`);\n }\n }\n else {\n const database: Uint8Array = this.databaseConnection.export();\n // convert Uint8Array to number array to improve local-storage storage\n const databaseArray = [].slice.call(database);\n if (this.options.useLocalForage) {\n if (window.localforage) {\n await window.localforage.setItem(path, JSON.stringify(databaseArray));\n } else {\n throw new TypeORMError(`localforage is not defined - please import localforage.js into your site`);\n }\n } else {\n PlatformTools.getGlobalVariable().localStorage.setItem(path, JSON.stringify(databaseArray));\n }\n }\n }\n\n /**\n * This gets called by the QueryRunner when a change to the database is made.\n * If a custom autoSaveCallback is specified, it get's called with the database as Uint8Array,\n * otherwise the save method is called which saves it to file (Node.js), local storage (browser)\n * or indexedDB (browser with enabled useLocalForage option).\n */\n async autoSave() {\n if (this.options.autoSave) {\n if (this.options.autoSaveCallback) {\n await this.options.autoSaveCallback(this.export());\n }\n else {\n await this.save();\n }\n }\n }\n\n /**\n * Returns the current database as Uint8Array.\n */\n export(): Uint8Array {\n return this.databaseConnection.export();\n }\n\n /**\n * Creates generated map of values generated or returned by database after INSERT query.\n */\n createGeneratedMap(metadata: EntityMetadata, insertResult: any) {\n const generatedMap = metadata.generatedColumns.reduce((map, generatedColumn) => {\n // seems to be the only way to get the inserted id, see https://github.com/kripken/sql.js/issues/77\n if (generatedColumn.isPrimary && generatedColumn.generationStrategy === \"increment\") {\n const query = \"SELECT last_insert_rowid()\";\n try {\n let result = this.databaseConnection.exec(query);\n this.connection.logger.logQuery(query);\n return OrmUtils.mergeDeep(map, generatedColumn.createValueMap(result[0].values[0][0]));\n }\n catch (e) {\n this.connection.logger.logQueryError(e, query, []);\n }\n }\n\n return map;\n }, {} as ObjectLiteral);\n\n return Object.keys(generatedMap).length > 0 ? generatedMap : undefined;\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates connection with the database.\n * If the location option is set, the database is loaded first.\n */\n protected createDatabaseConnection(): Promise<any> {\n if (this.options.location) {\n return this.load(this.options.location, false);\n }\n\n return this.createDatabaseConnectionWithImport(this.options.database);\n }\n\n /**\n * Creates connection with an optional database.\n * If database is specified it is loaded, otherwise a new empty database is created.\n */\n protected async createDatabaseConnectionWithImport(database?: Uint8Array): Promise<any> {\n // sql.js < 1.0 exposes an object with a `Database` method.\n const isLegacyVersion = typeof this.sqlite.Database === \"function\";\n const sqlite = isLegacyVersion ? this.sqlite : await this.sqlite(this.options.sqlJsConfig);\n if (database && database.length > 0) {\n this.databaseConnection = new sqlite.Database(database);\n }\n else {\n this.databaseConnection = new sqlite.Database();\n }\n\n // Enable foreign keys for database\n return new Promise<any>((ok, fail) => {\n try {\n this.databaseConnection.exec(`PRAGMA foreign_keys = ON;`);\n ok(this.databaseConnection);\n }\n catch (e) {\n fail(e);\n }\n });\n }\n\n /**\n * If driver dependency is not given explicitly, then try to load it via \"require\".\n */\n protected loadDependencies(): void {\n if (PlatformTools.type === \"browser\") {\n const sqlite = this.options.driver || window.SQL;\n this.sqlite = sqlite;\n }\n else {\n try {\n const sqlite = this.options.driver || PlatformTools.load(\"sql.js\");\n this.sqlite = sqlite;\n\n } catch (e) {\n throw new DriverPackageNotInstalledError(\"sql.js\", \"sql.js\");\n }\n }\n }\n}\n"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../../src/driver/sqljs/SqljsDriver.ts"],"names":[],"mappings":";;;;AAAA,gFAA6E;AAE7E,uDAAoD;AAGpD,6FAA0F;AAC1F,+EAA4E;AAC5E,8DAA2D;AAE3D,gDAA6C;AAG7C,qCAA2C;AAS3C;IAAiC,4CAAoB;IAIjD,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,qBAAY,UAAsB;QAAlC,YACI,kBAAM,UAAU,CAAC,SAUpB;QARG,8EAA8E;QAC9E,uEAAuE;QACvE,IAAI,KAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,KAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,KAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE;YACnF,MAAM,IAAI,iDAAuB,CAAC,8BAA8B,CAAC,CAAC;SACrE;QAED,sBAAsB;QACtB,KAAI,CAAC,gBAAgB,EAAE,CAAC;;IAC5B,CAAC;IAGD,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACG,6BAAO,GAAb;;;;;;wBACI,KAAA,IAAI,CAAA;wBAAsB,qBAAM,IAAI,CAAC,wBAAwB,EAAE,EAAA;;wBAA/D,GAAK,kBAAkB,GAAG,SAAqC,CAAC;;;;;KACnE;IAED;;OAEG;IACG,gCAAU,GAAhB;;;gBACI,IAAI,CAA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qljsConnectionOptions\";\nimport {SqljsQueryRunner} from \"./SqljsQueryRunner\";\nimport {QueryRunner} from \"../../query-runner/QueryRunner\";\nimport {Connection} from \"../../connection/Connection\";\nimport {DriverPackageNotInstalledError} from \"../../error/DriverPackageNotInstalledError\";\nimport {DriverOptionNotSetError} from \"../../error/DriverOptionNotSetError\";\nimport {PlatformTools} from \"../../platform/PlatformTools\";\nimport {EntityMetadata} from \"../../metadata/EntityMetadata\";\nimport {OrmUtils} from \"../../util/OrmUtils\";\nimport {ObjectLiteral} from \"../../common/ObjectLiteral\";\nimport {ReplicationMode} from \"../types/ReplicationMode\";\nimport { TypeORMError } from \"../../error\";\n\n// This is needed to satisfy the typescript compiler.\ninterface Window {\n SQL: any;\n localforage: any;\n}\ndeclare let window: Window;\n\nexport class SqljsDriver extends AbstractSqliteDriver {\n // The driver specific options.\n options: SqljsConnectionOptions;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(connection: Connection) {\n super(connection);\n\n // If autoSave is enabled by user, location or autoSaveCallback have to be set\n // because either autoSave saves to location or calls autoSaveCallback.\n if (this.options.autoSave && !this.options.location && !this.options.autoSaveCallback) {\n throw new DriverOptionNotSetError(`location or autoSaveCallback`);\n }\n\n // load sql.js package\n this.loadDependencies();\n }\n\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Performs connection to the database.\n */\n async connect(): Promise<void> {\n this.databaseConnection = await this.createDatabaseConnection();\n }\n\n /**\n * Closes connection with database.\n */\n async disconnect(): Promise<void> {\n this.queryRunner = undefined;\n this.databaseConnection.close();\n }\n\n /**\n * Creates a query runner used to execute database queries.\n */\n createQueryRunner(mode: ReplicationMode): QueryRunner {\n if (!this.queryRunner)\n this.queryRunner = new SqljsQueryRunner(this);\n\n return this.queryRunner;\n }\n\n /**\n * Loads a database from a given file (Node.js), local storage key (browser) or array.\n * This will delete the current database!\n */\n async load(fileNameOrLocalStorageOrData: string | Uint8Array, checkIfFileOrLocalStorageExists: boolean = true): Promise<any> {\n if (typeof fileNameOrLocalStorageOrData === \"string\") {\n // content has to be loaded\n if (PlatformTools.type === \"node\") {\n // Node.js\n // fileNameOrLocalStorageOrData should be a path to the file\n if (PlatformTools.fileExist(fileNameOrLocalStorageOrData)) {\n const database = PlatformTools.readFileSync(fileNameOrLocalStorageOrData);\n return this.createDatabaseConnectionWithImport(database);\n }\n else if (checkIfFileOrLocalStorageExists) {\n throw new TypeORMError(`File ${fileNameOrLocalStorageOrData} does not exist`);\n }\n else {\n // File doesn't exist and checkIfFileOrLocalStorageExists is set to false.\n // Therefore open a database without importing an existing file.\n // File will be written on first write operation.\n return this.createDatabaseConnectionWithImport();\n }\n }\n else {\n // browser\n // fileNameOrLocalStorageOrData should be a local storage / indexedDB key\n let localStorageContent = null;\n if (this.options.useLocalForage) {\n if (window.localforage) {\n localStorageContent = await window.localforage.getItem(fileNameOrLocalStorageOrData);\n } else {\n throw new TypeORMError(`localforage is not defined - please import localforage.js into your site`);\n }\n } else {\n localStorageContent = PlatformTools.getGlobalVariable().localStorage.getItem(fileNameOrLocalStorageOrData);\n }\n\n if (localStorageContent != null) {\n // localStorage value exists.\n return this.createDatabaseConnectionWithImport(JSON.parse(localStorageContent));\n }\n else if (checkIfFileOrLocalStorageExists) {\n throw new TypeORMError(`File ${fileNameOrLocalStorageOrData} does not exist`);\n }\n else {\n // localStorage value doesn't exist and checkIfFileOrLocalStorageExists is set to false.\n // Therefore open a database without importing anything.\n // localStorage value will be written on first write operation.\n return this.createDatabaseConnectionWithImport();\n }\n }\n }\n else {\n return this.createDatabaseConnectionWithImport(fileNameOrLocalStorageOrData);\n }\n }\n\n /**\n * Saved the current database to the given file (Node.js), local storage key (browser) or\n * indexedDB key (browser with enabled useLocalForage option).\n * If no location path is given, the location path in the options (if specified) will be used.\n */\n async save(location?: string) {\n if (!location && !this.options.location) {\n throw new TypeORMError(`No location is set, specify a location parameter or add the location option to your configuration`);\n }\n\n let path = \"\";\n if (location) {\n path = location;\n }\n else if (this.options.location) {\n path = this.options.location;\n }\n\n if (PlatformTools.type === \"node\") {\n try {\n const content = Buffer.from(this.databaseConnection.export());\n await PlatformTools.writeFile(path, content);\n }\n catch (e) {\n throw new TypeORMError(`Could not save database, error: ${e}`);\n }\n }\n else {\n const database: Uint8Array = this.databaseConnection.export();\n // convert Uint8Array to number array to improve local-storage storage\n const databaseArray = [].slice.call(database);\n if (this.options.useLocalForage) {\n if (window.localforage) {\n await window.localforage.setItem(path, JSON.stringify(databaseArray));\n } else {\n throw new TypeORMError(`localforage is not defined - please import localforage.js into your site`);\n }\n } else {\n PlatformTools.getGlobalVariable().localStorage.setItem(path, JSON.stringify(databaseArray));\n }\n }\n }\n\n /**\n * This gets called by the QueryRunner when a change to the database is made.\n * If a custom autoSaveCallback is specified, it get's called with the database as Uint8Array,\n * otherwise the save method is called which saves it to file (Node.js), local storage (browser)\n * or indexedDB (browser with enabled useLocalForage option).\n */\n async autoSave() {\n if (this.options.autoSave) {\n if (this.options.autoSaveCallback) {\n await this.options.autoSaveCallback(this.export());\n }\n else {\n await this.save();\n }\n }\n }\n\n /**\n * Returns the current database as Uint8Array.\n */\n export(): Uint8Array {\n return this.databaseConnection.export();\n }\n\n /**\n * Creates generated map of values generated or returned by database after INSERT query.\n */\n createGeneratedMap(metadata: EntityMetadata, insertResult: any) {\n const generatedMap = metadata.generatedColumns.reduce((map, generatedColumn) => {\n // seems to be the only way to get the inserted id, see https://github.com/kripken/sql.js/issues/77\n if (generatedColumn.isPrimary && generatedColumn.generationStrategy === \"increment\") {\n const query = \"SELECT last_insert_rowid()\";\n try {\n let result = this.databaseConnection.exec(query);\n this.connection.logger.logQuery(query);\n return OrmUtils.mergeDeep(map, generatedColumn.createValueMap(result[0].values[0][0]));\n }\n catch (e) {\n this.connection.logger.logQueryError(e, query, []);\n }\n }\n\n return map;\n }, {} as ObjectLiteral);\n\n return Object.keys(generatedMap).length > 0 ? generatedMap : undefined;\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates connection with the database.\n * If the location option is set, the database is loaded first.\n */\n protected createDatabaseConnection(): Promise<any> {\n if (this.options.location) {\n return this.load(this.options.location, false);\n }\n\n return this.createDatabaseConnectionWithImport(this.options.database);\n }\n\n /**\n * Creates connection with an optional database.\n * If database is specified it is loaded, otherwise a new empty database is created.\n */\n protected async createDatabaseConnectionWithImport(database?: Uint8Array): Promise<any> {\n // sql.js < 1.0 exposes an object with a `Database` method.\n const isLegacyVersion = typeof this.sqlite.Database === \"function\";\n const sqlite = isLegacyVersion ? this.sqlite : await this.sqlite(this.options.sqlJsConfig);\n if (database && database.length > 0) {\n this.databaseConnection = new sqlite.Database(database);\n }\n else {\n this.databaseConnection = new sqlite.Database();\n }\n\n this.databaseConnection.exec(`PRAGMA foreign_keys = ON;`);\n\n return this.databaseConnection;\n }\n\n /**\n * If driver dependency is not given explicitly, then try to load it via \"require\".\n */\n protected loadDependencies(): void {\n if (PlatformTools.type === \"browser\") {\n const sqlite = this.options.driver || window.SQL;\n this.sqlite = sqlite;\n }\n else {\n try {\n const sqlite = this.options.driver || PlatformTools.load(\"sql.js\");\n this.sqlite = sqlite;\n\n } catch (e) {\n throw new DriverPackageNotInstalledError(\"sql.js\", \"sql.js\");\n }\n }\n }\n}\n"],"sourceRoot":"../.."}
|
|
@@ -80,15 +80,14 @@ var SqljsQueryRunner = /** @class */ (function (_super) {
|
|
|
80
80
|
* Executes a given SQL query.
|
|
81
81
|
*/
|
|
82
82
|
SqljsQueryRunner.prototype.query = function (query, parameters, useStructuredResult) {
|
|
83
|
-
var _this = this;
|
|
84
83
|
if (parameters === void 0) { parameters = []; }
|
|
85
84
|
if (useStructuredResult === void 0) { useStructuredResult = false; }
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
var command = query.trim().split(" ", 1)[0];
|
|
89
|
-
return new Promise(function (ok, fail) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
|
|
90
|
-
var databaseConnection, queryStartTime, statement, maxQueryExecutionTime, queryEndTime, queryExecutionTime, records, result;
|
|
85
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
86
|
+
var command, databaseConnection, queryStartTime, statement, maxQueryExecutionTime, queryEndTime, queryExecutionTime, records, result;
|
|
91
87
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
88
|
+
if (this.isReleased)
|
|
89
|
+
throw new QueryRunnerAlreadyReleasedError_1.QueryRunnerAlreadyReleasedError();
|
|
90
|
+
command = query.trim().split(" ", 1)[0];
|
|
92
91
|
databaseConnection = this.driver.databaseConnection;
|
|
93
92
|
this.driver.connection.logger.logQuery(query, parameters, this);
|
|
94
93
|
queryStartTime = +new Date();
|
|
@@ -116,10 +115,10 @@ var SqljsQueryRunner = /** @class */ (function (_super) {
|
|
|
116
115
|
this.isDirty = true;
|
|
117
116
|
}
|
|
118
117
|
if (useStructuredResult) {
|
|
119
|
-
|
|
118
|
+
return [2 /*return*/, result];
|
|
120
119
|
}
|
|
121
120
|
else {
|
|
122
|
-
|
|
121
|
+
return [2 /*return*/, result.raw];
|
|
123
122
|
}
|
|
124
123
|
}
|
|
125
124
|
catch (e) {
|
|
@@ -127,11 +126,11 @@ var SqljsQueryRunner = /** @class */ (function (_super) {
|
|
|
127
126
|
statement.free();
|
|
128
127
|
}
|
|
129
128
|
this.driver.connection.logger.logQueryError(e, query, parameters, this);
|
|
130
|
-
|
|
129
|
+
throw new QueryFailedError_1.QueryFailedError(query, parameters, e);
|
|
131
130
|
}
|
|
132
131
|
return [2 /*return*/];
|
|
133
132
|
});
|
|
134
|
-
});
|
|
133
|
+
});
|
|
135
134
|
};
|
|
136
135
|
return SqljsQueryRunner;
|
|
137
136
|
}(AbstractSqliteQueryRunner_1.AbstractSqliteQueryRunner));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/driver/sqljs/SqljsQueryRunner.ts"],"names":[],"mappings":";;;;AAAA,+FAA4F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AC,OAAO,GAAG,IAAI,CAAC;qBACvB;oBAED,IAAI,mBAAmB,EAAE;wBACrB,sBAAO,MAAM,EAAC;qBACjB;yBAAM;wBACH,sBAAO,MAAM,CAAC,GAAG,EAAC;qBACrB;iBACJ;gBAAC,OAAO,CAAC,EAAE;oBACR,IAAI,SAAS,EAAE;wBACX,SAAS,CAAC,IAAI,EAAE,CAAC;qBACpB;oBAED,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;oBACxE,MAAM,IAAI,mCAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;iBACpD;;;;KACJ;IACL,uBAAC;AAAD,CA5GA,AA4GC,CA5GqC,qDAAyB,GA4G9D;AA5GY,4CAAgB","file":"SqljsQueryRunner.js","sourcesContent":["import {QueryRunnerAlreadyReleasedError} from \"../../error/QueryRunnerAlreadyReleasedError\";\nimport {AbstractSqliteQueryRunner} from \"../sqlite-abstract/AbstractSqliteQueryRunner\";\nimport {SqljsDriver} from \"./SqljsDriver\";\nimport {Broadcaster} from \"../../subscriber/Broadcaster\";\nimport {QueryFailedError} from \"../../error/QueryFailedError\";\nimport { QueryResult } from \"../../query-runner/QueryResult\";\n\n/**\n * Runs queries on a single sqlite database connection.\n */\nexport class SqljsQueryRunner extends AbstractSqliteQueryRunner {\n\n /**\n * Flag to determine if a modification has happened since the last time this query runner has requested a save.\n */\n private isDirty = false;\n\n /**\n * Database driver used by connection.\n */\n driver: SqljsDriver;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(driver: SqljsDriver) {\n super();\n this.driver = driver;\n this.connection = driver.connection;\n this.broadcaster = new Broadcaster(this);\n }\n\n // -------------------------------------------------------------------------\n // Public methods\n // -------------------------------------------------------------------------\n\n private async flush() {\n if (this.isDirty) {\n await this.driver.autoSave();\n this.isDirty = false;\n }\n }\n\n async release(): Promise<void> {\n await this.flush();\n return super.release();\n }\n\n /**\n * Commits transaction.\n * Error will be thrown if transaction was not started.\n */\n async commitTransaction(): Promise<void> {\n await super.commitTransaction();\n await this.flush();\n }\n\n /**\n * Executes a given SQL query.\n */\n async query(query: string, parameters: any[] = [], useStructuredResult = false): Promise<any> {\n if (this.isReleased)\n throw new QueryRunnerAlreadyReleasedError();\n\n const command = query.trim().split(\" \", 1)[0];\n\n const databaseConnection = this.driver.databaseConnection;\n this.driver.connection.logger.logQuery(query, parameters, this);\n const queryStartTime = +new Date();\n let statement: any;\n try {\n statement = databaseConnection.prepare(query);\n if (parameters) {\n parameters = parameters.map(p => typeof p !== 'undefined' ? p : null);\n\n statement.bind(parameters);\n }\n\n // log slow queries if maxQueryExecution time is set\n const maxQueryExecutionTime = this.driver.options.maxQueryExecutionTime;\n const queryEndTime = +new Date();\n const queryExecutionTime = queryEndTime - queryStartTime;\n if (maxQueryExecutionTime && queryExecutionTime > maxQueryExecutionTime)\n this.driver.connection.logger.logQuerySlow(queryExecutionTime, query, parameters, this);\n\n const records: any[] = [];\n\n while (statement.step()) {\n records.push(statement.getAsObject());\n }\n\n const result = new QueryResult();\n\n result.affected = databaseConnection.getRowsModified();\n result.records = records;\n result.raw = records;\n\n statement.free();\n\n if (command !== \"SELECT\") {\n this.isDirty = true;\n }\n\n if (useStructuredResult) {\n return result;\n } else {\n return result.raw;\n }\n } catch (e) {\n if (statement) {\n statement.free();\n }\n\n this.driver.connection.logger.logQueryError(e, query, parameters, this);\n throw new QueryFailedError(query, parameters, e);\n }\n }\n}\n"],"sourceRoot":"../.."}
|
|
@@ -77,6 +77,11 @@ export declare class EntityMetadata {
|
|
|
77
77
|
* Used in views
|
|
78
78
|
*/
|
|
79
79
|
expression?: string | ((connection: Connection) => SelectQueryBuilder<any>);
|
|
80
|
+
/**
|
|
81
|
+
* View's dependencies.
|
|
82
|
+
* Used in views
|
|
83
|
+
*/
|
|
84
|
+
dependsOn?: Set<Function | string>;
|
|
80
85
|
/**
|
|
81
86
|
* Enables Sqlite "WITHOUT ROWID" modifier for the "CREATE TABLE" statement
|
|
82
87
|
*/
|
|
@@ -237,6 +237,7 @@ var EntityMetadata = /** @class */ (function () {
|
|
|
237
237
|
this.tableType = this.tableMetadataArgs.type;
|
|
238
238
|
this.expression = this.tableMetadataArgs.expression;
|
|
239
239
|
this.withoutRowid = this.tableMetadataArgs.withoutRowid;
|
|
240
|
+
this.dependsOn = this.tableMetadataArgs.dependsOn;
|
|
240
241
|
}
|
|
241
242
|
// -------------------------------------------------------------------------
|
|
242
243
|
// Public Methods
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/metadata/EntityMetadata.ts"],"names":[],"mappings":";;;;AAGA,sFAAmF;AAInF,6CAA0C;AAC1C,mDAA4C;AAgB5C;;GAEG;AACH;IA8cI,wEAAwE;IACxE,cAAc;IACd,wEAAwE;IAExE,wBAAY,OAOX;QA1bD;;WAEG;QACH,yBAAoB,GAAqB,EAAE,CAAC;QAE5C;;;;WAIG;QACH,oBAAe,GAAe,EAAE,CAAC;QAEjC;;WAEG;QACH,cAAS,GAAc,SAAS,CAAC;QA2BjC;;WAEG;QACH,iBAAY,GAAa,KAAK,CAAC;QA8B/B;;WAEG;QACH,gBAAW,GAAY,IAAI,CAAC;QA4B5B;;WAEG;QACH,4BAAuB,GAAY,KAAK,CAAC;QAEzC;;;;;WAKG;QACH,eAAU,GAAY,KAAK,CAAC;QAE5B;;;WAGG;QACH,6BAAwB,GAAY,IAAI,CAAC;QAYzC;;;WAGG;QACH,sBAAiB,GAAY,KAAK,CAAC;QAEnC;;WAEG;QACH,2BAAsB,GAAY,KAAK,CAAC;QAExC;;WAEG;QACH,4BAAuB,GAAY,KAAK,CAAC;QAQzC;;WAEG;QACH,eAAU,GAAqB,EAAE,CAAC;QAElC;;WAEG;QACH,YAAO,GAAqB,EAAE,CAAC;QAE/B;;WAEG;QACH,oBAAe,GAAqB,EAAE,CAAC;QAEvC;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SAAS,EAAhB,CAAgB,CAAC,CAAC;QACtE,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;QAC7D,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAA,MAAM,IAAI,OAAA,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,kBAAkB,KAAK,MAAM,EAA1D,CAA0D,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QACpI,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAChD,IAAI,IAAI,CAAC,oBAAoB;YACzB,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,UAAA,cAAc,IAAI,OAAA,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,EAArC,CAAqC,CAAC,CAAC;IACnG,CAAC;IAED;;;;;;;OAOG;IACH,4CAAmB,GAAnB;QACI,IAAM,GAAG,GAAmC,EAAE,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAA,MAAM,IAAI,OAAA,mBAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAnE,CAAmE,CAAC,CAAC;QACpG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAA,QAAQ,IAAI,OAAA,mBAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAvE,CAAuE,CAAC,CAAC;QAC5G,OAAO,GAAG,CAAC;IACf,CAAC;IACL,qBAAC;AAAD,CA70BA,AA60BC,IAAA;AA70BY,wCAAc","file":"EntityMetadata.js","sourcesContent":["import {QueryRunner, SelectQueryBuilder} from \"..\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {Connection} from \"../connection/Connection\";\nimport {CannotCreateEntityIdMapError} from \"../error/CannotCreateEntityIdMapError\";\nimport {OrderByCondition} from \"../find-options/OrderByCondition\";\nimport {TableMetadataArgs} from \"../metadata-args/TableMetadataArgs\";\nimport {TreeMetadataArgs} from \"../metadata-args/TreeMetadataArgs\";\nimport {OrmUtils} from \"../util/OrmUtils\";\nimport {shorten} from \"../util/StringUtils\";\nimport {CheckMetadata} from \"./CheckMetadata\";\nimport {ColumnMetadata} from \"./ColumnMetadata\";\nimport {EmbeddedMetadata} from \"./EmbeddedMetadata\";\nimport {EntityListenerMetadata} from \"./EntityListenerMetadata\";\nimport {ExclusionMetadata} from \"./ExclusionMetadata\";\nimport {ForeignKeyMetadata} from \"./ForeignKeyMetadata\";\nimport {IndexMetadata} from \"./IndexMetadata\";\nimport {RelationCountMetadata} from \"./RelationCountMetadata\";\nimport {RelationIdMetadata} from \"./RelationIdMetadata\";\nimport {RelationMetadata} from \"./RelationMetadata\";\nimport {TableType} from \"./types/TableTypes\";\nimport {TreeType} from \"./types/TreeTypes\";\nimport {UniqueMetadata} from \"./UniqueMetadata\";\nimport {ClosureTreeOptions} from \"./types/ClosureTreeOptions\";\n\n/**\n * Contains all entity metadata.\n */\nexport class EntityMetadata {\n\n // -------------------------------------------------------------------------\n // Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection where this entity metadata is created.\n */\n connection: Connection;\n\n /**\n * Metadata arguments used to build this entity metadata.\n */\n tableMetadataArgs: TableMetadataArgs;\n\n /**\n * If entity's table is a closure-typed table, then this entity will have a closure junction table metadata.\n */\n closureJunctionTable: EntityMetadata;\n\n /**\n * If this is entity metadata for a junction closure table then its owner closure table metadata will be set here.\n */\n parentClosureEntityMetadata: EntityMetadata;\n\n /**\n * Parent's entity metadata. Used in inheritance patterns.\n */\n parentEntityMetadata: EntityMetadata;\n\n /**\n * Children entity metadatas. Used in inheritance patterns.\n */\n childEntityMetadatas: EntityMetadata[] = [];\n\n /**\n * All \"inheritance tree\" from a target entity.\n * For example for target Post < ContentModel < Unit it will be an array of [Post, ContentModel, Unit].\n * It also contains child entities for single table inheritance.\n */\n inheritanceTree: Function[] = [];\n\n /**\n * Table type. Tables can be closure, junction, etc.\n */\n tableType: TableType = \"regular\";\n\n /**\n * Target class to which this entity metadata is bind.\n * Note, that when using table inheritance patterns target can be different rather then table's target.\n * For virtual tables which lack of real entity (like junction tables) target is equal to their table name.\n */\n target: Function|string;\n\n /**\n * Gets the name of the target.\n */\n targetName: string;\n\n /**\n * Entity's name.\n * Equal to entity target class's name if target is set to table.\n * If target class is not then then it equals to table name.\n */\n name: string;\n\n /**\n * View's expression.\n * Used in views\n */\n expression?: string|((connection: Connection) => SelectQueryBuilder<any>);\n\n /**\n * Enables Sqlite \"WITHOUT ROWID\" modifier for the \"CREATE TABLE\" statement\n */\n withoutRowid?: boolean = false;\n\n /**\n * Original user-given table name (taken from schema or @Entity(tableName) decorator).\n * If user haven't specified a table name this property will be undefined.\n */\n givenTableName?: string;\n\n /**\n * Entity table name in the database.\n * This is final table name of the entity.\n * This name already passed naming strategy, and generated based on\n * multiple criteria, including user table name and global table prefix.\n */\n tableName: string;\n\n /**\n * Entity table path. Contains database name, schema name and table name.\n * E.g. myDB.mySchema.myTable\n */\n tablePath: string;\n\n /**\n * Gets the table name without global table prefix.\n * When querying table you need a table name with prefix, but in some scenarios,\n * for example when you want to name a junction table that contains names of two other tables,\n * you may want a table name without prefix.\n */\n tableNameWithoutPrefix: string;\n\n /**\n * Indicates if schema will be synchronized for this entity or not.\n */\n synchronize: boolean = true;\n\n /**\n * Table's database engine type (like \"InnoDB\", \"MyISAM\", etc).\n */\n engine?: string;\n\n /**\n * Database name.\n */\n database?: string;\n\n /**\n * Schema name. Used in Postgres and Sql Server.\n */\n schema?: string;\n\n /**\n * Specifies a default order by used for queries from this table when no explicit order by is specified.\n */\n orderBy?: OrderByCondition;\n\n /**\n * If this entity metadata's table using one of the inheritance patterns,\n * then this will contain what pattern it uses.\n */\n inheritancePattern?: \"STI\"/*|\"CTI\"*/;\n\n /**\n * Checks if there any non-nullable column exist in this entity.\n */\n hasNonNullableRelations: boolean = false;\n\n /**\n * Indicates if this entity metadata of a junction table, or not.\n * Junction table is a table created by many-to-many relationship.\n *\n * Its also possible to understand if entity is junction via tableType.\n */\n isJunction: boolean = false;\n\n /**\n * Indicates if the entity should be instantiated using the constructor\n * or via allocating a new object via `Object.create()`.\n */\n isAlwaysUsingConstructor: boolean = true;\n\n /**\n * Indicates if this entity is a tree, what type of tree it is.\n */\n treeType?: TreeType;\n\n /**\n * Indicates if this entity is a tree, what options of tree it has.\n */\n treeOptions?: ClosureTreeOptions;\n\n /**\n * Checks if this table is a junction table of the closure table.\n * This type is for tables that contain junction metadata of the closure tables.\n */\n isClosureJunction: boolean = false;\n\n /**\n * Checks if entity's table has multiple primary columns.\n */\n hasMultiplePrimaryKeys: boolean = false;\n\n /**\n * Indicates if this entity metadata has uuid generated columns.\n */\n hasUUIDGeneratedColumns: boolean = false;\n\n /**\n * If this entity metadata is a child table of some table, it should have a discriminator value.\n * Used to store a value in a discriminator column.\n */\n discriminatorValue?: string;\n\n /**\n * Entity's column metadatas defined by user.\n */\n ownColumns: ColumnMetadata[] = [];\n\n /**\n * Columns of the entity, including columns that are coming from the embeddeds of this entity.\n */\n columns: ColumnMetadata[] = [];\n\n /**\n * Ancestor columns used only in closure junction tables.\n */\n ancestorColumns: ColumnMetadata[] = [];\n\n /**\n * Descendant columns used only in closure junction tables.\n */\n descendantColumns: ColumnMetadata[] = [];\n\n /**\n * All columns except for virtual columns.\n */\n nonVirtualColumns: ColumnMetadata[] = [];\n\n /**\n * In the case if this entity metadata is junction table's entity metadata,\n * this will contain all referenced columns of owner entity.\n */\n ownerColumns: ColumnMetadata[] = [];\n\n /**\n * In the case if this entity metadata is junction table's entity metadata,\n * this will contain all referenced columns of inverse entity.\n */\n inverseColumns: ColumnMetadata[] = [];\n\n /**\n * Gets the column with generated flag.\n */\n generatedColumns: ColumnMetadata[] = [];\n\n /**\n * Gets the object id column used with mongodb database.\n */\n objectIdColumn?: ColumnMetadata;\n\n /**\n * Gets entity column which contains a create date value.\n */\n createDateColumn?: ColumnMetadata;\n\n /**\n * Gets entity column which contains an update date value.\n */\n updateDateColumn?: ColumnMetadata;\n\n /**\n * Gets entity column which contains a delete date value.\n */\n deleteDateColumn?: ColumnMetadata;\n\n /**\n * Gets entity column which contains an entity version.\n */\n versionColumn?: ColumnMetadata;\n\n /**\n * Gets the discriminator column used to store entity identificator in single-table inheritance tables.\n */\n discriminatorColumn?: ColumnMetadata;\n\n /**\n * Special column that stores tree level in tree entities.\n */\n treeLevelColumn?: ColumnMetadata;\n\n /**\n * Nested set's left value column.\n * Used only in tree entities with nested set pattern applied.\n */\n nestedSetLeftColumn?: ColumnMetadata;\n\n /**\n * Nested set's right value column.\n * Used only in tree entities with nested set pattern applied.\n */\n nestedSetRightColumn?: ColumnMetadata;\n\n /**\n * Materialized path column.\n * Used only in tree entities with materialized path pattern applied.\n */\n materializedPathColumn?: ColumnMetadata;\n\n /**\n * Gets the primary columns.\n */\n primaryColumns: ColumnMetadata[] = [];\n\n /**\n * Entity's relation metadatas.\n */\n ownRelations: RelationMetadata[] = [];\n\n /**\n * Relations of the entity, including relations that are coming from the embeddeds of this entity.\n */\n relations: RelationMetadata[] = [];\n\n /**\n * List of eager relations this metadata has.\n */\n eagerRelations: RelationMetadata[] = [];\n\n /**\n * List of eager relations this metadata has.\n */\n lazyRelations: RelationMetadata[] = [];\n\n /**\n * Gets only one-to-one relations of the entity.\n */\n oneToOneRelations: RelationMetadata[] = [];\n\n /**\n * Gets only owner one-to-one relations of the entity.\n */\n ownerOneToOneRelations: RelationMetadata[] = [];\n\n /**\n * Gets only one-to-many relations of the entity.\n */\n oneToManyRelations: RelationMetadata[] = [];\n\n /**\n * Gets only many-to-one relations of the entity.\n */\n manyToOneRelations: RelationMetadata[] = [];\n\n /**\n * Gets only many-to-many relations of the entity.\n */\n manyToManyRelations: RelationMetadata[] = [];\n\n /**\n * Gets only owner many-to-many relations of the entity.\n */\n ownerManyToManyRelations: RelationMetadata[] = [];\n\n /**\n * Gets only owner one-to-one and many-to-one relations.\n */\n relationsWithJoinColumns: RelationMetadata[] = [];\n\n /**\n * Tree parent relation. Used only in tree-tables.\n */\n treeParentRelation?: RelationMetadata;\n\n /**\n * Tree children relation. Used only in tree-tables.\n */\n treeChildrenRelation?: RelationMetadata;\n\n /**\n * Entity's relation id metadatas.\n */\n relationIds: RelationIdMetadata[] = [];\n\n /**\n * Entity's relation id metadatas.\n */\n relationCounts: RelationCountMetadata[] = [];\n\n /**\n * Entity's foreign key metadatas.\n */\n foreignKeys: ForeignKeyMetadata[] = [];\n\n /**\n * Entity's embedded metadatas.\n */\n embeddeds: EmbeddedMetadata[] = [];\n\n /**\n * All embeddeds - embeddeds from this entity metadata and from all child embeddeds, etc.\n */\n allEmbeddeds: EmbeddedMetadata[] = [];\n\n /**\n * Entity's own indices.\n */\n ownIndices: IndexMetadata[] = [];\n\n /**\n * Entity's index metadatas.\n */\n indices: IndexMetadata[] = [];\n\n /**\n * Entity's unique metadatas.\n */\n uniques: UniqueMetadata[] = [];\n\n /**\n * Entity's own uniques.\n */\n ownUniques: UniqueMetadata[] = [];\n\n /**\n * Entity's check metadatas.\n */\n checks: CheckMetadata[] = [];\n\n /**\n * Entity's exclusion metadatas.\n */\n exclusions: ExclusionMetadata[] = [];\n\n /**\n * Entity's own listener metadatas.\n */\n ownListeners: EntityListenerMetadata[] = [];\n\n /**\n * Entity listener metadatas.\n */\n listeners: EntityListenerMetadata[] = [];\n\n /**\n * Listener metadatas with \"AFTER LOAD\" type.\n */\n afterLoadListeners: EntityListenerMetadata[] = [];\n\n /**\n * Listener metadatas with \"AFTER INSERT\" type.\n */\n beforeInsertListeners: EntityListenerMetadata[] = [];\n\n /**\n * Listener metadatas with \"AFTER INSERT\" type.\n */\n afterInsertListeners: EntityListenerMetadata[] = [];\n\n /**\n * Listener metadatas with \"AFTER UPDATE\" type.\n */\n beforeUpdateListeners: EntityListenerMetadata[] = [];\n\n /**\n * Listener metadatas with \"AFTER UPDATE\" type.\n */\n afterUpdateListeners: EntityListenerMetadata[] = [];\n\n /**\n * Listener metadatas with \"AFTER REMOVE\" type.\n */\n beforeRemoveListeners: EntityListenerMetadata[] = [];\n\n /**\n * Listener metadatas with \"AFTER REMOVE\" type.\n */\n afterRemoveListeners: EntityListenerMetadata[] = [];\n\n /**\n * Map of columns and relations of the entity.\n *\n * example: Post{ id: number, name: string, counterEmbed: { count: number }, category: Category }.\n * This method will create following object:\n * { id: \"id\", counterEmbed: { count: \"counterEmbed.count\" }, category: \"category\" }\n */\n propertiesMap: ObjectLiteral;\n\n // ---------------------------------------------------------------------\n // Constructor\n // ---------------------------------------------------------------------\n\n constructor(options: {\n connection: Connection,\n inheritanceTree?: Function[],\n inheritancePattern?: \"STI\"/*|\"CTI\"*/,\n tableTree?: TreeMetadataArgs,\n parentClosureEntityMetadata?: EntityMetadata,\n args: TableMetadataArgs\n }) {\n this.connection = options.connection;\n this.inheritanceTree = options.inheritanceTree || [];\n this.inheritancePattern = options.inheritancePattern;\n this.treeType = options.tableTree ? options.tableTree.type : undefined;\n this.treeOptions = options.tableTree ? options.tableTree.options : undefined;\n this.parentClosureEntityMetadata = options.parentClosureEntityMetadata!;\n this.tableMetadataArgs = options.args;\n this.target = this.tableMetadataArgs.target;\n this.tableType = this.tableMetadataArgs.type;\n this.expression = this.tableMetadataArgs.expression;\n this.withoutRowid = this.tableMetadataArgs.withoutRowid;\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new entity.\n */\n create(queryRunner?: QueryRunner, options?: { fromDeserializer?: boolean }): any {\n // if target is set to a function (e.g. class) that can be created then create it\n let ret: any;\n if (this.target instanceof Function) {\n if (!options?.fromDeserializer || this.isAlwaysUsingConstructor) {\n ret = new (<any> this.target)();\n } else {\n ret = Object.create(this.target.prototype);\n }\n\n this.lazyRelations.forEach(relation => this.connection.relationLoader.enableLazyLoad(relation, ret, queryRunner));\n return ret;\n }\n\n // otherwise simply return a new empty object\n const newObject = {};\n this.lazyRelations.forEach(relation => this.connection.relationLoader.enableLazyLoad(relation, newObject, queryRunner));\n return newObject;\n }\n\n /**\n * Checks if given entity has an id.\n */\n hasId(entity: ObjectLiteral): boolean {\n if (!entity)\n return false;\n\n return this.primaryColumns.every(primaryColumn => {\n const value = primaryColumn.getEntityValue(entity);\n return value !== null && value !== undefined && value !== \"\";\n });\n }\n\n /**\n * Checks if given entity / object contains ALL primary keys entity must have.\n * Returns true if it contains all of them, false if at least one of them is not defined.\n */\n hasAllPrimaryKeys(entity: ObjectLiteral): boolean {\n return this.primaryColumns.every(primaryColumn => {\n const value = primaryColumn.getEntityValue(entity);\n return value !== null && value !== undefined;\n });\n }\n\n /**\n * Ensures that given object is an entity id map.\n * If given id is an object then it means its already id map.\n * If given id isn't an object then it means its a value of the id column\n * and it creates a new id map with this value and name of the primary column.\n */\n ensureEntityIdMap(id: any): ObjectLiteral {\n if (id instanceof Object)\n return id;\n\n if (this.hasMultiplePrimaryKeys)\n throw new CannotCreateEntityIdMapError(this, id);\n\n return this.primaryColumns[0].createValueMap(id);\n }\n\n /**\n * Gets primary keys of the entity and returns them in a literal object.\n * For example, for Post{ id: 1, title: \"hello\" } where id is primary it will return { id: 1 }\n * For multiple primary keys it returns multiple keys in object.\n * For primary keys inside embeds it returns complex object literal with keys in them.\n */\n getEntityIdMap(entity: ObjectLiteral|undefined): ObjectLiteral|undefined {\n if (!entity)\n return undefined;\n\n return EntityMetadata.getValueMap(entity, this.primaryColumns, { skipNulls: true });\n }\n\n /**\n * Creates a \"mixed id map\".\n * If entity has multiple primary keys (ids) then it will return just regular id map, like what getEntityIdMap returns.\n * But if entity has a single primary key then it will return just value of the id column of the entity, just value.\n * This is called mixed id map.\n */\n getEntityIdMixedMap(entity: ObjectLiteral|undefined): ObjectLiteral|undefined {\n if (!entity)\n return entity;\n\n const idMap = this.getEntityIdMap(entity);\n if (this.hasMultiplePrimaryKeys) {\n return idMap;\n\n } else if (idMap) {\n return this.primaryColumns[0].getEntityValue(idMap); // todo: what about parent primary column?\n }\n\n return idMap;\n }\n\n /**\n * Compares two different entities by their ids.\n * Returns true if they match, false otherwise.\n */\n compareEntities(firstEntity: ObjectLiteral, secondEntity: ObjectLiteral): boolean {\n\n const firstEntityIdMap = this.getEntityIdMap(firstEntity);\n if (!firstEntityIdMap) return false;\n\n const secondEntityIdMap = this.getEntityIdMap(secondEntity);\n if (!secondEntityIdMap) return false;\n\n return OrmUtils.compareIds(firstEntityIdMap, secondEntityIdMap);\n }\n\n /**\n * Finds column with a given property name.\n */\n findColumnWithPropertyName(propertyName: string): ColumnMetadata|undefined {\n return this.columns.find(column => column.propertyName === propertyName);\n }\n\n /**\n * Finds column with a given database name.\n */\n findColumnWithDatabaseName(databaseName: string): ColumnMetadata|undefined {\n return this.columns.find(column => column.databaseName === databaseName);\n }\n\n /**\n * Checks if there is a column or relationship with a given property path.\n */\n hasColumnWithPropertyPath(propertyPath: string): boolean {\n const hasColumn = this.columns.some(column => column.propertyPath === propertyPath);\n return hasColumn || this.hasRelationWithPropertyPath(propertyPath);\n }\n\n /**\n * Finds column with a given property path.\n */\n findColumnWithPropertyPath(propertyPath: string): ColumnMetadata|undefined {\n const column = this.columns.find(column => column.propertyPath === propertyPath);\n if (column)\n return column;\n\n // in the case if column with property path was not found, try to find a relation with such property path\n // if we find relation and it has a single join column then its the column user was seeking\n const relation = this.relations.find(relation => relation.propertyPath === propertyPath);\n if (relation && relation.joinColumns.length === 1)\n return relation.joinColumns[0];\n\n return undefined;\n }\n\n /**\n * Finds columns with a given property path.\n * Property path can match a relation, and relations can contain multiple columns.\n */\n findColumnsWithPropertyPath(propertyPath: string): ColumnMetadata[] {\n const column = this.columns.find(column => column.propertyPath === propertyPath);\n if (column)\n return [column];\n\n // in the case if column with property path was not found, try to find a relation with such property path\n // if we find relation and it has a single join column then its the column user was seeking\n const relation = this.findRelationWithPropertyPath(propertyPath);\n if (relation && relation.joinColumns)\n return relation.joinColumns;\n\n return [];\n }\n\n /**\n * Checks if there is a relation with the given property path.\n */\n hasRelationWithPropertyPath(propertyPath: string): boolean {\n return this.relations.some(relation => relation.propertyPath === propertyPath);\n }\n\n /**\n * Finds relation with the given property path.\n */\n findRelationWithPropertyPath(propertyPath: string): RelationMetadata|undefined {\n return this.relations.find(relation => relation.propertyPath === propertyPath);\n }\n\n /**\n * Checks if there is an embedded with a given property path.\n */\n hasEmbeddedWithPropertyPath(propertyPath: string): boolean {\n return this.allEmbeddeds.some(embedded => embedded.propertyPath === propertyPath);\n }\n\n /**\n * Finds embedded with a given property path.\n */\n findEmbeddedWithPropertyPath(propertyPath: string): EmbeddedMetadata|undefined {\n return this.allEmbeddeds.find(embedded => embedded.propertyPath === propertyPath);\n }\n\n /**\n * Iterates through entity and finds and extracts all values from relations in the entity.\n * If relation value is an array its being flattened.\n */\n extractRelationValuesFromEntity(entity: ObjectLiteral, relations: RelationMetadata[]): [RelationMetadata, any, EntityMetadata][] {\n const relationsAndValues: [RelationMetadata, any, EntityMetadata][] = [];\n relations.forEach(relation => {\n const value = relation.getEntityValue(entity);\n if (Array.isArray(value)) {\n value.forEach(subValue => relationsAndValues.push([relation, subValue, this.getInverseEntityMetadata(subValue, relation)]));\n } else if (value) {\n relationsAndValues.push([relation, value, this.getInverseEntityMetadata(value, relation)]);\n }\n });\n return relationsAndValues;\n }\n\n private getInverseEntityMetadata(value: any, relation: RelationMetadata): EntityMetadata {\n const childEntityMetadata = relation.inverseEntityMetadata.childEntityMetadatas.find(metadata =>\n metadata.target === value.constructor\n );\n return childEntityMetadata ? childEntityMetadata : relation.inverseEntityMetadata;\n }\n\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a property paths for a given entity.\n *\n * @deprecated\n */\n static createPropertyPath(metadata: EntityMetadata, entity: ObjectLiteral, prefix: string = \"\") {\n const paths: string[] = [];\n Object.keys(entity).forEach(key => {\n\n // check for function is needed in the cases when createPropertyPath used on values containg a function as a value\n // example: .update().set({ name: () => `SUBSTR('', 1, 2)` })\n const parentPath = prefix ? prefix + \".\" + key : key;\n if (metadata.hasEmbeddedWithPropertyPath(parentPath)) {\n const subPaths = this.createPropertyPath(metadata, entity[key], parentPath);\n paths.push(...subPaths);\n } else {\n const path = prefix ? prefix + \".\" + key : key;\n paths.push(path);\n }\n });\n return paths;\n }\n\n /**\n * Finds difference between two entity id maps.\n * Returns items that exist in the first array and absent in the second array.\n */\n static difference(firstIdMaps: ObjectLiteral[], secondIdMaps: ObjectLiteral[]): ObjectLiteral[] {\n return firstIdMaps.filter(firstIdMap => {\n return !secondIdMaps.find(secondIdMap => OrmUtils.compareIds(firstIdMap, secondIdMap));\n });\n }\n\n /**\n * Creates value map from the given values and columns.\n * Examples of usages are primary columns map and join columns map.\n */\n static getValueMap(entity: ObjectLiteral, columns: ColumnMetadata[], options?: { skipNulls?: boolean }): ObjectLiteral|undefined {\n return columns.reduce((map, column) => {\n const value = column.getEntityValueMap(entity, options);\n\n // make sure that none of the values of the columns are not missing\n if (map === undefined || value === null || value === undefined)\n return undefined;\n\n return OrmUtils.mergeDeep(map, value);\n }, {} as ObjectLiteral|undefined);\n }\n\n // ---------------------------------------------------------------------\n // Public Builder Methods\n // ---------------------------------------------------------------------\n\n build() {\n const namingStrategy = this.connection.namingStrategy;\n const entityPrefix = this.connection.options.entityPrefix;\n const entitySkipConstructor = this.connection.options.entitySkipConstructor;\n\n this.engine = this.tableMetadataArgs.engine;\n this.database = this.tableMetadataArgs.type === \"entity-child\" && this.parentEntityMetadata ? this.parentEntityMetadata.database : this.tableMetadataArgs.database;\n if (this.tableMetadataArgs.schema) {\n this.schema = this.tableMetadataArgs.schema;\n }\n else if ((this.tableMetadataArgs.type === \"entity-child\") && this.parentEntityMetadata) {\n this.schema = this.parentEntityMetadata.schema;\n } else if (this.connection.options?.hasOwnProperty(\"schema\")) {\n this.schema = (this.connection.options as any).schema;\n }\n this.givenTableName = this.tableMetadataArgs.type === \"entity-child\" && this.parentEntityMetadata ? this.parentEntityMetadata.givenTableName : this.tableMetadataArgs.name;\n this.synchronize = this.tableMetadataArgs.synchronize === false ? false : true;\n this.targetName = this.tableMetadataArgs.target instanceof Function ? (this.tableMetadataArgs.target as any).name : this.tableMetadataArgs.target;\n if (this.tableMetadataArgs.type === \"closure-junction\") {\n this.tableNameWithoutPrefix = namingStrategy.closureJunctionTableName(this.givenTableName!);\n } else if (this.tableMetadataArgs.type === \"entity-child\" && this.parentEntityMetadata) {\n this.tableNameWithoutPrefix = namingStrategy.tableName(this.parentEntityMetadata.targetName, this.parentEntityMetadata.givenTableName);\n } else {\n this.tableNameWithoutPrefix = namingStrategy.tableName(this.targetName, this.givenTableName);\n\n if (this.connection.driver.maxAliasLength && this.connection.driver.maxAliasLength > 0 && this.tableNameWithoutPrefix.length > this.connection.driver.maxAliasLength) {\n this.tableNameWithoutPrefix = shorten(this.tableNameWithoutPrefix, { separator: \"_\", segmentLength: 3 });\n }\n }\n this.tableName = entityPrefix ? namingStrategy.prefixTableName(entityPrefix, this.tableNameWithoutPrefix) : this.tableNameWithoutPrefix;\n this.target = this.target ? this.target : this.tableName;\n this.name = this.targetName ? this.targetName : this.tableName;\n this.expression = this.tableMetadataArgs.expression;\n this.withoutRowid = this.tableMetadataArgs.withoutRowid === true ? true : false;\n this.tablePath = this.connection.driver.buildTableName(this.tableName, this.schema, this.database);\n this.orderBy = (this.tableMetadataArgs.orderBy instanceof Function) ? this.tableMetadataArgs.orderBy(this.propertiesMap) : this.tableMetadataArgs.orderBy; // todo: is propertiesMap available here? Looks like its not\n\n if (entitySkipConstructor !== undefined) {\n this.isAlwaysUsingConstructor = !entitySkipConstructor;\n }\n\n this.isJunction = this.tableMetadataArgs.type === \"closure-junction\" || this.tableMetadataArgs.type === \"junction\";\n this.isClosureJunction = this.tableMetadataArgs.type === \"closure-junction\";\n }\n\n /**\n * Registers a new column in the entity and recomputes all depend properties.\n */\n registerColumn(column: ColumnMetadata) {\n if (this.ownColumns.indexOf(column) !== -1)\n return;\n\n this.ownColumns.push(column);\n this.columns = this.embeddeds.reduce((columns, embedded) => columns.concat(embedded.columnsFromTree), this.ownColumns);\n this.primaryColumns = this.columns.filter(column => column.isPrimary);\n this.hasMultiplePrimaryKeys = this.primaryColumns.length > 1;\n this.hasUUIDGeneratedColumns = this.columns.filter(column => column.isGenerated || column.generationStrategy === \"uuid\").length > 0;\n this.propertiesMap = this.createPropertiesMap();\n if (this.childEntityMetadatas)\n this.childEntityMetadatas.forEach(entityMetadata => entityMetadata.registerColumn(column));\n }\n\n /**\n * Creates a special object - all columns and relations of the object (plus columns and relations from embeds)\n * in a special format - { propertyName: propertyName }.\n *\n * example: Post{ id: number, name: string, counterEmbed: { count: number }, category: Category }.\n * This method will create following object:\n * { id: \"id\", counterEmbed: { count: \"counterEmbed.count\" }, category: \"category\" }\n */\n createPropertiesMap(): { [name: string]: string|any } {\n const map: { [name: string]: string|any } = {};\n this.columns.forEach(column => OrmUtils.mergeDeep(map, column.createValueMap(column.propertyPath)));\n this.relations.forEach(relation => OrmUtils.mergeDeep(map, relation.createValueMap(relation.propertyPath)));\n return map;\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/metadata/EntityMetadata.ts"],"names":[],"mappings":";;;;AAGA,sFAAmF;AAInF,6CAA0C;AAC1C,mDAA4C;AAgB5C;;GAEG;AACH;IAodI,wEAAwE;IACxE,cAAc;IACd,wEAAwE;IAExE,wBAAY,OAOX;QAhcD;;WAEG;QACH,yBAAoB,GAAqB,EAAE,CAAC;QAE5C;;;;WAIG;QACH,oBAAe,GAAe,EAAE,CAAC;QAEjC;;WAEG;QACH,cAAS,GAAc,SAAS,CAAC;QAiCjC;;WAEG;QACH,iBAAY,GAAa,KAAK,CAAC;QA8B/B;;WAEG;QACH,gBAAW,GAAY,IAAI,CAAC;QA4B5B;;WAEG;QACH,4BAAuB,GAAY,KAAK,CAAC;QAEzC;;;;;WAKG;QACH,eAAU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AI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAA,QAAQ,IAAI,OAAA,mBAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAvE,CAAuE,CAAC,CAAC;QAC5G,OAAO,GAAG,CAAC;IACf,CAAC;IACL,qBAAC;AAAD,CAp1BA,AAo1BC,IAAA;AAp1BY,wCAAc","file":"EntityMetadata.js","sourcesContent":["import {QueryRunner, SelectQueryBuilder} from \"..\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {Connection} from \"../connection/Connection\";\nimport {CannotCreateEntityIdMapError} from \"../error/CannotCreateEntityIdMapError\";\nimport {OrderByCondition} from \"../find-options/OrderByCondition\";\nimport {TableMetadataArgs} from \"../metadata-args/TableMetadataArgs\";\nimport {TreeMetadataArgs} from \"../metadata-args/TreeMetadataArgs\";\nimport {OrmUtils} from \"../util/OrmUtils\";\nimport {shorten} from \"../util/StringUtils\";\nimport {CheckMetadata} from \"./CheckMetadata\";\nimport {ColumnMetadata} from \"./ColumnMetadata\";\nimport {EmbeddedMetadata} from \"./EmbeddedMetadata\";\nimport {EntityListenerMetadata} from \"./EntityListenerMetadata\";\nimport {ExclusionMetadata} from \"./ExclusionMetadata\";\nimport {ForeignKeyMetadata} from \"./ForeignKeyMetadata\";\nimport {IndexMetadata} from \"./IndexMetadata\";\nimport {RelationCountMetadata} from \"./RelationCountMetadata\";\nimport {RelationIdMetadata} from \"./RelationIdMetadata\";\nimport {RelationMetadata} from \"./RelationMetadata\";\nimport {TableType} from \"./types/TableTypes\";\nimport {TreeType} from \"./types/TreeTypes\";\nimport {UniqueMetadata} from \"./UniqueMetadata\";\nimport {ClosureTreeOptions} from \"./types/ClosureTreeOptions\";\n\n/**\n * Contains all entity metadata.\n */\nexport class EntityMetadata {\n\n // -------------------------------------------------------------------------\n // Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection where this entity metadata is created.\n */\n connection: Connection;\n\n /**\n * Metadata arguments used to build this entity metadata.\n */\n tableMetadataArgs: TableMetadataArgs;\n\n /**\n * If entity's table is a closure-typed table, then this entity will have a closure junction table metadata.\n */\n closureJunctionTable: EntityMetadata;\n\n /**\n * If this is entity metadata for a junction closure table then its owner closure table metadata will be set here.\n */\n parentClosureEntityMetadata: EntityMetadata;\n\n /**\n * Parent's entity metadata. Used in inheritance patterns.\n */\n parentEntityMetadata: EntityMetadata;\n\n /**\n * Children entity metadatas. Used in inheritance patterns.\n */\n childEntityMetadatas: EntityMetadata[] = [];\n\n /**\n * All \"inheritance tree\" from a target entity.\n * For example for target Post < ContentModel < Unit it will be an array of [Post, ContentModel, Unit].\n * It also contains child entities for single table inheritance.\n */\n inheritanceTree: Function[] = [];\n\n /**\n * Table type. Tables can be closure, junction, etc.\n */\n tableType: TableType = \"regular\";\n\n /**\n * Target class to which this entity metadata is bind.\n * Note, that when using table inheritance patterns target can be different rather then table's target.\n * For virtual tables which lack of real entity (like junction tables) target is equal to their table name.\n */\n target: Function|string;\n\n /**\n * Gets the name of the target.\n */\n targetName: string;\n\n /**\n * Entity's name.\n * Equal to entity target class's name if target is set to table.\n * If target class is not then then it equals to table name.\n */\n name: string;\n\n /**\n * View's expression.\n * Used in views\n */\n expression?: string|((connection: Connection) => SelectQueryBuilder<any>);\n\n /**\n * View's dependencies.\n * Used in views\n */\n dependsOn?: Set<Function|string>;\n\n /**\n * Enables Sqlite \"WITHOUT ROWID\" modifier for the \"CREATE TABLE\" statement\n */\n withoutRowid?: boolean = false;\n\n /**\n * Original user-given table name (taken from schema or @Entity(tableName) decorator).\n * If user haven't specified a table name this property will be undefined.\n */\n givenTableName?: string;\n\n /**\n * Entity table name in the database.\n * This is final table name of the entity.\n * This name already passed naming strategy, and generated based on\n * multiple criteria, including user table name and global table prefix.\n */\n tableName: string;\n\n /**\n * Entity table path. Contains database name, schema name and table name.\n * E.g. myDB.mySchema.myTable\n */\n tablePath: string;\n\n /**\n * Gets the table name without global table prefix.\n * When querying table you need a table name with prefix, but in some scenarios,\n * for example when you want to name a junction table that contains names of two other tables,\n * you may want a table name without prefix.\n */\n tableNameWithoutPrefix: string;\n\n /**\n * Indicates if schema will be synchronized for this entity or not.\n */\n synchronize: boolean = true;\n\n /**\n * Table's database engine type (like \"InnoDB\", \"MyISAM\", etc).\n */\n engine?: string;\n\n /**\n * Database name.\n */\n database?: string;\n\n /**\n * Schema name. Used in Postgres and Sql Server.\n */\n schema?: string;\n\n /**\n * Specifies a default order by used for queries from this table when no explicit order by is specified.\n */\n orderBy?: OrderByCondition;\n\n /**\n * If this entity metadata's table using one of the inheritance patterns,\n * then this will contain what pattern it uses.\n */\n inheritancePattern?: \"STI\"/*|\"CTI\"*/;\n\n /**\n * Checks if there any non-nullable column exist in this entity.\n */\n hasNonNullableRelations: boolean = false;\n\n /**\n * Indicates if this entity metadata of a junction table, or not.\n * Junction table is a table created by many-to-many relationship.\n *\n * Its also possible to understand if entity is junction via tableType.\n */\n isJunction: boolean = false;\n\n /**\n * Indicates if the entity should be instantiated using the constructor\n * or via allocating a new object via `Object.create()`.\n */\n isAlwaysUsingConstructor: boolean = true;\n\n /**\n * Indicates if this entity is a tree, what type of tree it is.\n */\n treeType?: TreeType;\n\n /**\n * Indicates if this entity is a tree, what options of tree it has.\n */\n treeOptions?: ClosureTreeOptions;\n\n /**\n * Checks if this table is a junction table of the closure table.\n * This type is for tables that contain junction metadata of the closure tables.\n */\n isClosureJunction: boolean = false;\n\n /**\n * Checks if entity's table has multiple primary columns.\n */\n hasMultiplePrimaryKeys: boolean = false;\n\n /**\n * Indicates if this entity metadata has uuid generated columns.\n */\n hasUUIDGeneratedColumns: boolean = false;\n\n /**\n * If this entity metadata is a child table of some table, it should have a discriminator value.\n * Used to store a value in a discriminator column.\n */\n discriminatorValue?: string;\n\n /**\n * Entity's column metadatas defined by user.\n */\n ownColumns: ColumnMetadata[] = [];\n\n /**\n * Columns of the entity, including columns that are coming from the embeddeds of this entity.\n */\n columns: ColumnMetadata[] = [];\n\n /**\n * Ancestor columns used only in closure junction tables.\n */\n ancestorColumns: ColumnMetadata[] = [];\n\n /**\n * Descendant columns used only in closure junction tables.\n */\n descendantColumns: ColumnMetadata[] = [];\n\n /**\n * All columns except for virtual columns.\n */\n nonVirtualColumns: ColumnMetadata[] = [];\n\n /**\n * In the case if this entity metadata is junction table's entity metadata,\n * this will contain all referenced columns of owner entity.\n */\n ownerColumns: ColumnMetadata[] = [];\n\n /**\n * In the case if this entity metadata is junction table's entity metadata,\n * this will contain all referenced columns of inverse entity.\n */\n inverseColumns: ColumnMetadata[] = [];\n\n /**\n * Gets the column with generated flag.\n */\n generatedColumns: ColumnMetadata[] = [];\n\n /**\n * Gets the object id column used with mongodb database.\n */\n objectIdColumn?: ColumnMetadata;\n\n /**\n * Gets entity column which contains a create date value.\n */\n createDateColumn?: ColumnMetadata;\n\n /**\n * Gets entity column which contains an update date value.\n */\n updateDateColumn?: ColumnMetadata;\n\n /**\n * Gets entity column which contains a delete date value.\n */\n deleteDateColumn?: ColumnMetadata;\n\n /**\n * Gets entity column which contains an entity version.\n */\n versionColumn?: ColumnMetadata;\n\n /**\n * Gets the discriminator column used to store entity identificator in single-table inheritance tables.\n */\n discriminatorColumn?: ColumnMetadata;\n\n /**\n * Special column that stores tree level in tree entities.\n */\n treeLevelColumn?: ColumnMetadata;\n\n /**\n * Nested set's left value column.\n * Used only in tree entities with nested set pattern applied.\n */\n nestedSetLeftColumn?: ColumnMetadata;\n\n /**\n * Nested set's right value column.\n * Used only in tree entities with nested set pattern applied.\n */\n nestedSetRightColumn?: ColumnMetadata;\n\n /**\n * Materialized path column.\n * Used only in tree entities with materialized path pattern applied.\n */\n materializedPathColumn?: ColumnMetadata;\n\n /**\n * Gets the primary columns.\n */\n primaryColumns: ColumnMetadata[] = [];\n\n /**\n * Entity's relation metadatas.\n */\n ownRelations: RelationMetadata[] = [];\n\n /**\n * Relations of the entity, including relations that are coming from the embeddeds of this entity.\n */\n relations: RelationMetadata[] = [];\n\n /**\n * List of eager relations this metadata has.\n */\n eagerRelations: RelationMetadata[] = [];\n\n /**\n * List of eager relations this metadata has.\n */\n lazyRelations: RelationMetadata[] = [];\n\n /**\n * Gets only one-to-one relations of the entity.\n */\n oneToOneRelations: RelationMetadata[] = [];\n\n /**\n * Gets only owner one-to-one relations of the entity.\n */\n ownerOneToOneRelations: RelationMetadata[] = [];\n\n /**\n * Gets only one-to-many relations of the entity.\n */\n oneToManyRelations: RelationMetadata[] = [];\n\n /**\n * Gets only many-to-one relations of the entity.\n */\n manyToOneRelations: RelationMetadata[] = [];\n\n /**\n * Gets only many-to-many relations of the entity.\n */\n manyToManyRelations: RelationMetadata[] = [];\n\n /**\n * Gets only owner many-to-many relations of the entity.\n */\n ownerManyToManyRelations: RelationMetadata[] = [];\n\n /**\n * Gets only owner one-to-one and many-to-one relations.\n */\n relationsWithJoinColumns: RelationMetadata[] = [];\n\n /**\n * Tree parent relation. Used only in tree-tables.\n */\n treeParentRelation?: RelationMetadata;\n\n /**\n * Tree children relation. Used only in tree-tables.\n */\n treeChildrenRelation?: RelationMetadata;\n\n /**\n * Entity's relation id metadatas.\n */\n relationIds: RelationIdMetadata[] = [];\n\n /**\n * Entity's relation id metadatas.\n */\n relationCounts: RelationCountMetadata[] = [];\n\n /**\n * Entity's foreign key metadatas.\n */\n foreignKeys: ForeignKeyMetadata[] = [];\n\n /**\n * Entity's embedded metadatas.\n */\n embeddeds: EmbeddedMetadata[] = [];\n\n /**\n * All embeddeds - embeddeds from this entity metadata and from all child embeddeds, etc.\n */\n allEmbeddeds: EmbeddedMetadata[] = [];\n\n /**\n * Entity's own indices.\n */\n ownIndices: IndexMetadata[] = [];\n\n /**\n * Entity's index metadatas.\n */\n indices: IndexMetadata[] = [];\n\n /**\n * Entity's unique metadatas.\n */\n uniques: UniqueMetadata[] = [];\n\n /**\n * Entity's own uniques.\n */\n ownUniques: UniqueMetadata[] = [];\n\n /**\n * Entity's check metadatas.\n */\n checks: CheckMetadata[] = [];\n\n /**\n * Entity's exclusion metadatas.\n */\n exclusions: ExclusionMetadata[] = [];\n\n /**\n * Entity's own listener metadatas.\n */\n ownListeners: EntityListenerMetadata[] = [];\n\n /**\n * Entity listener metadatas.\n */\n listeners: EntityListenerMetadata[] = [];\n\n /**\n * Listener metadatas with \"AFTER LOAD\" type.\n */\n afterLoadListeners: EntityListenerMetadata[] = [];\n\n /**\n * Listener metadatas with \"AFTER INSERT\" type.\n */\n beforeInsertListeners: EntityListenerMetadata[] = [];\n\n /**\n * Listener metadatas with \"AFTER INSERT\" type.\n */\n afterInsertListeners: EntityListenerMetadata[] = [];\n\n /**\n * Listener metadatas with \"AFTER UPDATE\" type.\n */\n beforeUpdateListeners: EntityListenerMetadata[] = [];\n\n /**\n * Listener metadatas with \"AFTER UPDATE\" type.\n */\n afterUpdateListeners: EntityListenerMetadata[] = [];\n\n /**\n * Listener metadatas with \"AFTER REMOVE\" type.\n */\n beforeRemoveListeners: EntityListenerMetadata[] = [];\n\n /**\n * Listener metadatas with \"AFTER REMOVE\" type.\n */\n afterRemoveListeners: EntityListenerMetadata[] = [];\n\n /**\n * Map of columns and relations of the entity.\n *\n * example: Post{ id: number, name: string, counterEmbed: { count: number }, category: Category }.\n * This method will create following object:\n * { id: \"id\", counterEmbed: { count: \"counterEmbed.count\" }, category: \"category\" }\n */\n propertiesMap: ObjectLiteral;\n\n // ---------------------------------------------------------------------\n // Constructor\n // ---------------------------------------------------------------------\n\n constructor(options: {\n connection: Connection,\n inheritanceTree?: Function[],\n inheritancePattern?: \"STI\"/*|\"CTI\"*/,\n tableTree?: TreeMetadataArgs,\n parentClosureEntityMetadata?: EntityMetadata,\n args: TableMetadataArgs\n }) {\n this.connection = options.connection;\n this.inheritanceTree = options.inheritanceTree || [];\n this.inheritancePattern = options.inheritancePattern;\n this.treeType = options.tableTree ? options.tableTree.type : undefined;\n this.treeOptions = options.tableTree ? options.tableTree.options : undefined;\n this.parentClosureEntityMetadata = options.parentClosureEntityMetadata!;\n this.tableMetadataArgs = options.args;\n this.target = this.tableMetadataArgs.target;\n this.tableType = this.tableMetadataArgs.type;\n this.expression = this.tableMetadataArgs.expression;\n this.withoutRowid = this.tableMetadataArgs.withoutRowid;\n this.dependsOn = this.tableMetadataArgs.dependsOn;\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new entity.\n */\n create(queryRunner?: QueryRunner, options?: { fromDeserializer?: boolean }): any {\n // if target is set to a function (e.g. class) that can be created then create it\n let ret: any;\n if (this.target instanceof Function) {\n if (!options?.fromDeserializer || this.isAlwaysUsingConstructor) {\n ret = new (<any> this.target)();\n } else {\n ret = Object.create(this.target.prototype);\n }\n\n this.lazyRelations.forEach(relation => this.connection.relationLoader.enableLazyLoad(relation, ret, queryRunner));\n return ret;\n }\n\n // otherwise simply return a new empty object\n const newObject = {};\n this.lazyRelations.forEach(relation => this.connection.relationLoader.enableLazyLoad(relation, newObject, queryRunner));\n return newObject;\n }\n\n /**\n * Checks if given entity has an id.\n */\n hasId(entity: ObjectLiteral): boolean {\n if (!entity)\n return false;\n\n return this.primaryColumns.every(primaryColumn => {\n const value = primaryColumn.getEntityValue(entity);\n return value !== null && value !== undefined && value !== \"\";\n });\n }\n\n /**\n * Checks if given entity / object contains ALL primary keys entity must have.\n * Returns true if it contains all of them, false if at least one of them is not defined.\n */\n hasAllPrimaryKeys(entity: ObjectLiteral): boolean {\n return this.primaryColumns.every(primaryColumn => {\n const value = primaryColumn.getEntityValue(entity);\n return value !== null && value !== undefined;\n });\n }\n\n /**\n * Ensures that given object is an entity id map.\n * If given id is an object then it means its already id map.\n * If given id isn't an object then it means its a value of the id column\n * and it creates a new id map with this value and name of the primary column.\n */\n ensureEntityIdMap(id: any): ObjectLiteral {\n if (id instanceof Object)\n return id;\n\n if (this.hasMultiplePrimaryKeys)\n throw new CannotCreateEntityIdMapError(this, id);\n\n return this.primaryColumns[0].createValueMap(id);\n }\n\n /**\n * Gets primary keys of the entity and returns them in a literal object.\n * For example, for Post{ id: 1, title: \"hello\" } where id is primary it will return { id: 1 }\n * For multiple primary keys it returns multiple keys in object.\n * For primary keys inside embeds it returns complex object literal with keys in them.\n */\n getEntityIdMap(entity: ObjectLiteral|undefined): ObjectLiteral|undefined {\n if (!entity)\n return undefined;\n\n return EntityMetadata.getValueMap(entity, this.primaryColumns, { skipNulls: true });\n }\n\n /**\n * Creates a \"mixed id map\".\n * If entity has multiple primary keys (ids) then it will return just regular id map, like what getEntityIdMap returns.\n * But if entity has a single primary key then it will return just value of the id column of the entity, just value.\n * This is called mixed id map.\n */\n getEntityIdMixedMap(entity: ObjectLiteral|undefined): ObjectLiteral|undefined {\n if (!entity)\n return entity;\n\n const idMap = this.getEntityIdMap(entity);\n if (this.hasMultiplePrimaryKeys) {\n return idMap;\n\n } else if (idMap) {\n return this.primaryColumns[0].getEntityValue(idMap); // todo: what about parent primary column?\n }\n\n return idMap;\n }\n\n /**\n * Compares two different entities by their ids.\n * Returns true if they match, false otherwise.\n */\n compareEntities(firstEntity: ObjectLiteral, secondEntity: ObjectLiteral): boolean {\n\n const firstEntityIdMap = this.getEntityIdMap(firstEntity);\n if (!firstEntityIdMap) return false;\n\n const secondEntityIdMap = this.getEntityIdMap(secondEntity);\n if (!secondEntityIdMap) return false;\n\n return OrmUtils.compareIds(firstEntityIdMap, secondEntityIdMap);\n }\n\n /**\n * Finds column with a given property name.\n */\n findColumnWithPropertyName(propertyName: string): ColumnMetadata|undefined {\n return this.columns.find(column => column.propertyName === propertyName);\n }\n\n /**\n * Finds column with a given database name.\n */\n findColumnWithDatabaseName(databaseName: string): ColumnMetadata|undefined {\n return this.columns.find(column => column.databaseName === databaseName);\n }\n\n /**\n * Checks if there is a column or relationship with a given property path.\n */\n hasColumnWithPropertyPath(propertyPath: string): boolean {\n const hasColumn = this.columns.some(column => column.propertyPath === propertyPath);\n return hasColumn || this.hasRelationWithPropertyPath(propertyPath);\n }\n\n /**\n * Finds column with a given property path.\n */\n findColumnWithPropertyPath(propertyPath: string): ColumnMetadata|undefined {\n const column = this.columns.find(column => column.propertyPath === propertyPath);\n if (column)\n return column;\n\n // in the case if column with property path was not found, try to find a relation with such property path\n // if we find relation and it has a single join column then its the column user was seeking\n const relation = this.relations.find(relation => relation.propertyPath === propertyPath);\n if (relation && relation.joinColumns.length === 1)\n return relation.joinColumns[0];\n\n return undefined;\n }\n\n /**\n * Finds columns with a given property path.\n * Property path can match a relation, and relations can contain multiple columns.\n */\n findColumnsWithPropertyPath(propertyPath: string): ColumnMetadata[] {\n const column = this.columns.find(column => column.propertyPath === propertyPath);\n if (column)\n return [column];\n\n // in the case if column with property path was not found, try to find a relation with such property path\n // if we find relation and it has a single join column then its the column user was seeking\n const relation = this.findRelationWithPropertyPath(propertyPath);\n if (relation && relation.joinColumns)\n return relation.joinColumns;\n\n return [];\n }\n\n /**\n * Checks if there is a relation with the given property path.\n */\n hasRelationWithPropertyPath(propertyPath: string): boolean {\n return this.relations.some(relation => relation.propertyPath === propertyPath);\n }\n\n /**\n * Finds relation with the given property path.\n */\n findRelationWithPropertyPath(propertyPath: string): RelationMetadata|undefined {\n return this.relations.find(relation => relation.propertyPath === propertyPath);\n }\n\n /**\n * Checks if there is an embedded with a given property path.\n */\n hasEmbeddedWithPropertyPath(propertyPath: string): boolean {\n return this.allEmbeddeds.some(embedded => embedded.propertyPath === propertyPath);\n }\n\n /**\n * Finds embedded with a given property path.\n */\n findEmbeddedWithPropertyPath(propertyPath: string): EmbeddedMetadata|undefined {\n return this.allEmbeddeds.find(embedded => embedded.propertyPath === propertyPath);\n }\n\n /**\n * Iterates through entity and finds and extracts all values from relations in the entity.\n * If relation value is an array its being flattened.\n */\n extractRelationValuesFromEntity(entity: ObjectLiteral, relations: RelationMetadata[]): [RelationMetadata, any, EntityMetadata][] {\n const relationsAndValues: [RelationMetadata, any, EntityMetadata][] = [];\n relations.forEach(relation => {\n const value = relation.getEntityValue(entity);\n if (Array.isArray(value)) {\n value.forEach(subValue => relationsAndValues.push([relation, subValue, this.getInverseEntityMetadata(subValue, relation)]));\n } else if (value) {\n relationsAndValues.push([relation, value, this.getInverseEntityMetadata(value, relation)]);\n }\n });\n return relationsAndValues;\n }\n\n private getInverseEntityMetadata(value: any, relation: RelationMetadata): EntityMetadata {\n const childEntityMetadata = relation.inverseEntityMetadata.childEntityMetadatas.find(metadata =>\n metadata.target === value.constructor\n );\n return childEntityMetadata ? childEntityMetadata : relation.inverseEntityMetadata;\n }\n\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a property paths for a given entity.\n *\n * @deprecated\n */\n static createPropertyPath(metadata: EntityMetadata, entity: ObjectLiteral, prefix: string = \"\") {\n const paths: string[] = [];\n Object.keys(entity).forEach(key => {\n\n // check for function is needed in the cases when createPropertyPath used on values containg a function as a value\n // example: .update().set({ name: () => `SUBSTR('', 1, 2)` })\n const parentPath = prefix ? prefix + \".\" + key : key;\n if (metadata.hasEmbeddedWithPropertyPath(parentPath)) {\n const subPaths = this.createPropertyPath(metadata, entity[key], parentPath);\n paths.push(...subPaths);\n } else {\n const path = prefix ? prefix + \".\" + key : key;\n paths.push(path);\n }\n });\n return paths;\n }\n\n /**\n * Finds difference between two entity id maps.\n * Returns items that exist in the first array and absent in the second array.\n */\n static difference(firstIdMaps: ObjectLiteral[], secondIdMaps: ObjectLiteral[]): ObjectLiteral[] {\n return firstIdMaps.filter(firstIdMap => {\n return !secondIdMaps.find(secondIdMap => OrmUtils.compareIds(firstIdMap, secondIdMap));\n });\n }\n\n /**\n * Creates value map from the given values and columns.\n * Examples of usages are primary columns map and join columns map.\n */\n static getValueMap(entity: ObjectLiteral, columns: ColumnMetadata[], options?: { skipNulls?: boolean }): ObjectLiteral|undefined {\n return columns.reduce((map, column) => {\n const value = column.getEntityValueMap(entity, options);\n\n // make sure that none of the values of the columns are not missing\n if (map === undefined || value === null || value === undefined)\n return undefined;\n\n return OrmUtils.mergeDeep(map, value);\n }, {} as ObjectLiteral|undefined);\n }\n\n // ---------------------------------------------------------------------\n // Public Builder Methods\n // ---------------------------------------------------------------------\n\n build() {\n const namingStrategy = this.connection.namingStrategy;\n const entityPrefix = this.connection.options.entityPrefix;\n const entitySkipConstructor = this.connection.options.entitySkipConstructor;\n\n this.engine = this.tableMetadataArgs.engine;\n this.database = this.tableMetadataArgs.type === \"entity-child\" && this.parentEntityMetadata ? this.parentEntityMetadata.database : this.tableMetadataArgs.database;\n if (this.tableMetadataArgs.schema) {\n this.schema = this.tableMetadataArgs.schema;\n }\n else if ((this.tableMetadataArgs.type === \"entity-child\") && this.parentEntityMetadata) {\n this.schema = this.parentEntityMetadata.schema;\n } else if (this.connection.options?.hasOwnProperty(\"schema\")) {\n this.schema = (this.connection.options as any).schema;\n }\n this.givenTableName = this.tableMetadataArgs.type === \"entity-child\" && this.parentEntityMetadata ? this.parentEntityMetadata.givenTableName : this.tableMetadataArgs.name;\n this.synchronize = this.tableMetadataArgs.synchronize === false ? false : true;\n this.targetName = this.tableMetadataArgs.target instanceof Function ? (this.tableMetadataArgs.target as any).name : this.tableMetadataArgs.target;\n if (this.tableMetadataArgs.type === \"closure-junction\") {\n this.tableNameWithoutPrefix = namingStrategy.closureJunctionTableName(this.givenTableName!);\n } else if (this.tableMetadataArgs.type === \"entity-child\" && this.parentEntityMetadata) {\n this.tableNameWithoutPrefix = namingStrategy.tableName(this.parentEntityMetadata.targetName, this.parentEntityMetadata.givenTableName);\n } else {\n this.tableNameWithoutPrefix = namingStrategy.tableName(this.targetName, this.givenTableName);\n\n if (this.connection.driver.maxAliasLength && this.connection.driver.maxAliasLength > 0 && this.tableNameWithoutPrefix.length > this.connection.driver.maxAliasLength) {\n this.tableNameWithoutPrefix = shorten(this.tableNameWithoutPrefix, { separator: \"_\", segmentLength: 3 });\n }\n }\n this.tableName = entityPrefix ? namingStrategy.prefixTableName(entityPrefix, this.tableNameWithoutPrefix) : this.tableNameWithoutPrefix;\n this.target = this.target ? this.target : this.tableName;\n this.name = this.targetName ? this.targetName : this.tableName;\n this.expression = this.tableMetadataArgs.expression;\n this.withoutRowid = this.tableMetadataArgs.withoutRowid === true ? true : false;\n this.tablePath = this.connection.driver.buildTableName(this.tableName, this.schema, this.database);\n this.orderBy = (this.tableMetadataArgs.orderBy instanceof Function) ? this.tableMetadataArgs.orderBy(this.propertiesMap) : this.tableMetadataArgs.orderBy; // todo: is propertiesMap available here? Looks like its not\n\n if (entitySkipConstructor !== undefined) {\n this.isAlwaysUsingConstructor = !entitySkipConstructor;\n }\n\n this.isJunction = this.tableMetadataArgs.type === \"closure-junction\" || this.tableMetadataArgs.type === \"junction\";\n this.isClosureJunction = this.tableMetadataArgs.type === \"closure-junction\";\n }\n\n /**\n * Registers a new column in the entity and recomputes all depend properties.\n */\n registerColumn(column: ColumnMetadata) {\n if (this.ownColumns.indexOf(column) !== -1)\n return;\n\n this.ownColumns.push(column);\n this.columns = this.embeddeds.reduce((columns, embedded) => columns.concat(embedded.columnsFromTree), this.ownColumns);\n this.primaryColumns = this.columns.filter(column => column.isPrimary);\n this.hasMultiplePrimaryKeys = this.primaryColumns.length > 1;\n this.hasUUIDGeneratedColumns = this.columns.filter(column => column.isGenerated || column.generationStrategy === \"uuid\").length > 0;\n this.propertiesMap = this.createPropertiesMap();\n if (this.childEntityMetadatas)\n this.childEntityMetadatas.forEach(entityMetadata => entityMetadata.registerColumn(column));\n }\n\n /**\n * Creates a special object - all columns and relations of the object (plus columns and relations from embeds)\n * in a special format - { propertyName: propertyName }.\n *\n * example: Post{ id: number, name: string, counterEmbed: { count: number }, category: Category }.\n * This method will create following object:\n * { id: \"id\", counterEmbed: { count: \"counterEmbed.count\" }, category: \"category\" }\n */\n createPropertiesMap(): { [name: string]: string|any } {\n const map: { [name: string]: string|any } = {};\n this.columns.forEach(column => OrmUtils.mergeDeep(map, column.createValueMap(column.propertyPath)));\n this.relations.forEach(relation => OrmUtils.mergeDeep(map, relation.createValueMap(relation.propertyPath)));\n return map;\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -45,6 +45,10 @@ export interface TableMetadataArgs {
|
|
|
45
45
|
* View expression.
|
|
46
46
|
*/
|
|
47
47
|
expression?: string | ((connection: Connection) => SelectQueryBuilder<any>);
|
|
48
|
+
/**
|
|
49
|
+
* View dependencies.
|
|
50
|
+
*/
|
|
51
|
+
dependsOn?: Set<Function | string>;
|
|
48
52
|
/**
|
|
49
53
|
* Indicates if view is materialized
|
|
50
54
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/metadata-args/TableMetadataArgs.ts"],"names":[],"mappings":"","file":"TableMetadataArgs.js","sourcesContent":["import {Connection, SelectQueryBuilder} from \"..\";\nimport {OrderByCondition} from \"../find-options/OrderByCondition\";\nimport {TableType} from \"../metadata/types/TableTypes\";\n\n/**\n * Arguments for TableMetadata class, helps to construct an TableMetadata object.\n */\nexport interface TableMetadataArgs {\n\n /**\n * Class to which table is applied.\n * Function target is a table defined in the class.\n * String target is a table defined in a json schema.\n */\n target: Function|string;\n\n /**\n * Table's name. If name is not set then table's name will be generated from target's name.\n */\n name?: string;\n\n /**\n * Table type. Tables can be abstract, closure, junction, embedded, etc.\n */\n type: TableType;\n\n /**\n * Specifies a default order by used for queries from this table when no explicit order by is specified.\n */\n orderBy?: OrderByCondition|((object: any) => OrderByCondition|any);\n\n /**\n * Table's database engine type (like \"InnoDB\", \"MyISAM\", etc).\n */\n engine?: string;\n\n /**\n * Database name. Used in MySql and Sql Server.\n */\n database?: string;\n\n /**\n * Schema name. Used in Postgres and Sql Server.\n */\n schema?: string;\n\n /**\n * Indicates if schema synchronization is enabled or disabled for this entity.\n * If it will be set to false then schema sync will and migrations ignore this entity.\n * By default schema synchronization is enabled for all entities.\n */\n synchronize?: boolean;\n\n /**\n * View expression.\n */\n expression?: string|((connection: Connection) => SelectQueryBuilder<any>);\n\n /**\n * Indicates if view is materialized\n */\n materialized?: boolean;\n\n /**\n * If set to 'true' this option disables Sqlite's default behaviour of secretly creating\n * an integer primary key column named 'rowid' on table creation
|
|
1
|
+
{"version":3,"sources":["../../src/metadata-args/TableMetadataArgs.ts"],"names":[],"mappings":"","file":"TableMetadataArgs.js","sourcesContent":["import {Connection, SelectQueryBuilder} from \"..\";\nimport {OrderByCondition} from \"../find-options/OrderByCondition\";\nimport {TableType} from \"../metadata/types/TableTypes\";\n\n/**\n * Arguments for TableMetadata class, helps to construct an TableMetadata object.\n */\nexport interface TableMetadataArgs {\n\n /**\n * Class to which table is applied.\n * Function target is a table defined in the class.\n * String target is a table defined in a json schema.\n */\n target: Function|string;\n\n /**\n * Table's name. If name is not set then table's name will be generated from target's name.\n */\n name?: string;\n\n /**\n * Table type. Tables can be abstract, closure, junction, embedded, etc.\n */\n type: TableType;\n\n /**\n * Specifies a default order by used for queries from this table when no explicit order by is specified.\n */\n orderBy?: OrderByCondition|((object: any) => OrderByCondition|any);\n\n /**\n * Table's database engine type (like \"InnoDB\", \"MyISAM\", etc).\n */\n engine?: string;\n\n /**\n * Database name. Used in MySql and Sql Server.\n */\n database?: string;\n\n /**\n * Schema name. Used in Postgres and Sql Server.\n */\n schema?: string;\n\n /**\n * Indicates if schema synchronization is enabled or disabled for this entity.\n * If it will be set to false then schema sync will and migrations ignore this entity.\n * By default schema synchronization is enabled for all entities.\n */\n synchronize?: boolean;\n\n /**\n * View expression.\n */\n expression?: string|((connection: Connection) => SelectQueryBuilder<any>);\n\n /**\n * View dependencies.\n */\n dependsOn?: Set<Function|string>;\n\n /**\n * Indicates if view is materialized\n */\n materialized?: boolean;\n\n /**\n * If set to 'true' this option disables Sqlite's default behaviour of secretly creating\n * an integer primary key column named 'rowid' on table creation.\n */\n withoutRowid?: boolean;\n}\n"],"sourceRoot":".."}
|
|
@@ -87,5 +87,5 @@ export declare class MigrationExecutor {
|
|
|
87
87
|
* Delete previously executed migration's data from the migrations table.
|
|
88
88
|
*/
|
|
89
89
|
protected deleteExecutedMigration(queryRunner: QueryRunner, migration: Migration): Promise<void>;
|
|
90
|
-
protected withQueryRunner<T extends any>(callback: (queryRunner: QueryRunner) => T): Promise<T>;
|
|
90
|
+
protected withQueryRunner<T extends any>(callback: (queryRunner: QueryRunner) => T | Promise<T>): Promise<T>;
|
|
91
91
|
}
|
|
@@ -123,26 +123,14 @@ var MigrationExecutor = /** @class */ (function () {
|
|
|
123
123
|
*/
|
|
124
124
|
MigrationExecutor.prototype.insertMigration = function (migration) {
|
|
125
125
|
var _this = this;
|
|
126
|
-
return
|
|
127
|
-
_this.withQueryRunner(function (queryRunner) {
|
|
128
|
-
_this.insertExecutedMigration(queryRunner, migration)
|
|
129
|
-
.then(resolve)
|
|
130
|
-
.catch(reject);
|
|
131
|
-
});
|
|
132
|
-
});
|
|
126
|
+
return this.withQueryRunner(function (q) { return _this.insertExecutedMigration(q, migration); });
|
|
133
127
|
};
|
|
134
128
|
/**
|
|
135
129
|
* Deletes an executed migration.
|
|
136
130
|
*/
|
|
137
131
|
MigrationExecutor.prototype.deleteMigration = function (migration) {
|
|
138
132
|
var _this = this;
|
|
139
|
-
return
|
|
140
|
-
_this.withQueryRunner(function (queryRunner) {
|
|
141
|
-
_this.deleteExecutedMigration(queryRunner, migration)
|
|
142
|
-
.then(resolve)
|
|
143
|
-
.catch(reject);
|
|
144
|
-
});
|
|
145
|
-
});
|
|
133
|
+
return this.withQueryRunner(function (q) { return _this.deleteExecutedMigration(q, migration); });
|
|
146
134
|
};
|
|
147
135
|
/**
|
|
148
136
|
* Lists all migrations and whether they have been executed or not
|
|
@@ -270,6 +258,10 @@ var MigrationExecutor = /** @class */ (function () {
|
|
|
270
258
|
transactionStartedByUs = true;
|
|
271
259
|
_c.label = 2;
|
|
272
260
|
case 2: return [4 /*yield*/, migration.instance.up(queryRunner)
|
|
261
|
+
.catch(function (error) {
|
|
262
|
+
_this.connection.logger.logMigration("Migration \"" + migration.name + "\" has been failed, error: " + (error === null || error === void 0 ? void 0 : error.message));
|
|
263
|
+
throw error;
|
|
264
|
+
})
|
|
273
265
|
.then(function () { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
|
|
274
266
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
275
267
|
switch (_a.label) {
|