typeorm 0.2.41-dev.b2c8168 → 0.2.41-dev.c59ef29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/cache/DbQueryResultCache.js +12 -3
- package/browser/cache/DbQueryResultCache.js.map +1 -1
- package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js +16 -16
- package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachQueryRunner.js +7 -7
- package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/browser/driver/mongodb/MongoQueryRunner.d.ts +2 -0
- package/browser/driver/mongodb/MongoQueryRunner.js +3 -0
- package/browser/driver/mongodb/MongoQueryRunner.js.map +1 -1
- package/browser/driver/mysql/MysqlQueryRunner.js +16 -16
- package/browser/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/browser/driver/oracle/OracleDriver.js +1 -1
- package/browser/driver/oracle/OracleDriver.js.map +1 -1
- package/browser/driver/oracle/OracleQueryRunner.js +6 -7
- package/browser/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.js +7 -7
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/driver/sap/SapQueryRunner.js +17 -16
- package/browser/driver/sap/SapQueryRunner.js.map +1 -1
- package/browser/driver/sqlserver/SqlServerQueryRunner.js +6 -6
- package/browser/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/browser/query-runner/BaseQueryRunner.d.ts +1 -0
- package/browser/query-runner/BaseQueryRunner.js +3 -0
- package/browser/query-runner/BaseQueryRunner.js.map +1 -1
- package/browser/query-runner/QueryRunner.d.ts +5 -0
- package/browser/query-runner/QueryRunner.js.map +1 -1
- package/cache/DbQueryResultCache.js +12 -3
- package/cache/DbQueryResultCache.js.map +1 -1
- package/driver/aurora-data-api/AuroraDataApiQueryRunner.js +16 -16
- package/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
- package/driver/cockroachdb/CockroachQueryRunner.js +7 -7
- package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/driver/mongodb/MongoQueryRunner.d.ts +2 -0
- package/driver/mongodb/MongoQueryRunner.js +3 -0
- package/driver/mongodb/MongoQueryRunner.js.map +1 -1
- package/driver/mysql/MysqlQueryRunner.js +16 -16
- package/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/driver/oracle/OracleDriver.js +1 -1
- package/driver/oracle/OracleDriver.js.map +1 -1
- package/driver/oracle/OracleQueryRunner.js +6 -7
- package/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/driver/postgres/PostgresQueryRunner.js +7 -7
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/driver/sap/SapQueryRunner.js +17 -16
- package/driver/sap/SapQueryRunner.js.map +1 -1
- package/driver/sqlserver/SqlServerQueryRunner.js +6 -6
- package/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/package.json +1 -1
- package/query-runner/BaseQueryRunner.d.ts +1 -0
- package/query-runner/BaseQueryRunner.js +3 -0
- package/query-runner/BaseQueryRunner.js.map +1 -1
- package/query-runner/QueryRunner.d.ts +5 -0
- package/query-runner/QueryRunner.js.map +1 -1
|
@@ -115,6 +115,7 @@ export declare abstract class BaseQueryRunner {
|
|
|
115
115
|
* Executes down sql queries.
|
|
116
116
|
*/
|
|
117
117
|
executeMemoryDownSql(): Promise<void>;
|
|
118
|
+
getReplicationMode(): ReplicationMode;
|
|
118
119
|
/**
|
|
119
120
|
* Gets view from previously loaded views, otherwise loads it from database.
|
|
120
121
|
*/
|
|
@@ -231,6 +231,9 @@ var BaseQueryRunner = /** @class */ (function () {
|
|
|
231
231
|
});
|
|
232
232
|
});
|
|
233
233
|
};
|
|
234
|
+
BaseQueryRunner.prototype.getReplicationMode = function () {
|
|
235
|
+
return this.mode;
|
|
236
|
+
};
|
|
234
237
|
// -------------------------------------------------------------------------
|
|
235
238
|
// Protected Methods
|
|
236
239
|
// -------------------------------------------------------------------------
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/query-runner/BaseQueryRunner.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAC;AASlD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C;IAAA;QAEI,4EAA4E;QAC5E,oBAAoB;QACpB,4EAA4E;QAY5E;;;WAGG;QACH,eAAU,GAAG,KAAK,CAAC;QAEnB;;WAEG;QACH,wBAAmB,GAAG,KAAK,CAAC;QAE5B;;;WAGG;QACH,SAAI,GAAG,EAAE,CAAC;QAEV;;WAEG;QACH,iBAAY,GAAY,EAAE,CAAC;QAE3B;;WAEG;QACH,gBAAW,GAAW,EAAE,CAAC;QAgBzB;;WAEG;QACO,kBAAa,GAAY,KAAK,CAAC;QAEzC;;WAEG;QACO,gBAAW,GAAgB,IAAI,WAAW,EAAE,CAAC;QAS/C,qBAAgB,GAA2B,EAAE,CAAC;IA0Z1D,CAAC;IAvYG,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACG,kCAAQ,GAAd,UAAe,SAAiB;;;;;;wBAC5B,KAAA,IAAI,CAAA;wBAAgB,qBAAM,IAAI,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,EAAA;;wBAAtD,GAAK,YAAY,GAAG,SAAkC,CAAC;wBACvD,sBAAO,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAC;;;;KAC1E;IAED;;OAEG;IACG,mCAAS,GAAf,UAAgB,UAAqB;;;;;;6BAC7B,CAAC,UAAU,EAA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I;eACnE,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS;YAC3E,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC;QAEhF,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;OAEG;IACa,wCAAc,GAA9B,UAA+B,SAAwB,EAAE,WAA0B;;;;;;;wBAC/E,IAAI,SAAS,YAAY,KAAK;4BAC1B,SAAS,GAAG,CAAC,SAAS,CAAC,CAAC;wBAC5B,IAAI,WAAW,YAAY,KAAK;4BAC5B,WAAW,GAAG,CAAC,WAAW,CAAC,CAAC;wBAEhC,CAAA,KAAA,IAAI,CAAC,WAAW,CAAC,SAAS,CAAA,CAAC,IAAI,oCAAI,SAAS,WAAE;wBAC9C,CAAA,KAAA,IAAI,CAAC,WAAW,CAAC,WAAW,CAAA,CAAC,IAAI,oCAAI,WAAW,WAAE;wBAElD,8EAA8E;wBAC9E,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI;4BAC3B,sBAAO,OAAO,CAAC,OAAO,EAAkB,EAAC;;;;wBAEX,cAAA,SAAA,SAAS,CAAA;;;;wBAAhC,wBAAmB,EAAlB,KAAK,WAAA,EAAE,UAAU,gBAAA;wBACzB,qBAAM,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,EAAA;;wBAAnC,SAAmC,CAAC;;;;;;;;;;;;;;;;;;;;KAE3C;IAEL,sBAAC;AAAD,CApeA,AAoeC,IAAA","file":"BaseQueryRunner.js","sourcesContent":["import {PostgresConnectionOptions} from \"../driver/postgres/PostgresConnectionOptions\";\nimport {Query} from \"../driver/Query\";\nimport {SqlInMemory} from \"../driver/SqlInMemory\";\nimport {SqlServerConnectionOptions} from \"../driver/sqlserver/SqlServerConnectionOptions\";\nimport {View} from \"../schema-builder/view/View\";\nimport {Connection} from \"../connection/Connection\";\nimport {Table} from \"../schema-builder/table/Table\";\nimport {EntityManager} from \"../entity-manager/EntityManager\";\nimport {TableColumn} from \"../schema-builder/table/TableColumn\";\nimport {Broadcaster} from \"../subscriber/Broadcaster\";\nimport {ReplicationMode} from \"../driver/types/ReplicationMode\";\nimport { TypeORMError } from \"../error/TypeORMError\";\nimport { EntityMetadata } from \"../metadata/EntityMetadata\";\nimport { TableForeignKey } from \"../schema-builder/table/TableForeignKey\";\nimport { OrmUtils } from \"../util/OrmUtils\";\nimport {MetadataTableType} from \"../driver/types/MetadataTableType\";\n\nexport abstract class BaseQueryRunner {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection used by this query runner.\n */\n connection: Connection;\n\n /**\n * Entity manager working only with current query runner.\n */\n manager: EntityManager;\n\n /**\n * Indicates if connection for this query runner is released.\n * Once its released, query runner cannot run queries anymore.\n */\n isReleased = false;\n\n /**\n * Indicates if transaction is in progress.\n */\n isTransactionActive = false;\n\n /**\n * Stores temporarily user data.\n * Useful for sharing data with subscribers.\n */\n data = {};\n\n /**\n * All synchronized tables in the database.\n */\n loadedTables: Table[] = [];\n\n /**\n * All synchronized views in the database.\n */\n loadedViews: View[] = [];\n\n /**\n * Broadcaster used on this query runner to broadcast entity events.\n */\n broadcaster: Broadcaster;\n\n // -------------------------------------------------------------------------\n // Protected Properties\n // -------------------------------------------------------------------------\n\n /**\n * Real database connection from a connection pool used to perform queries.\n */\n protected databaseConnection: any;\n\n /**\n * Indicates if special query runner mode in which sql queries won't be executed is enabled.\n */\n protected sqlMemoryMode: boolean = false;\n\n /**\n * Sql-s stored if \"sql in memory\" mode is enabled.\n */\n protected sqlInMemory: SqlInMemory = new SqlInMemory();\n\n /**\n * Mode in which query runner executes.\n * Used for replication.\n * If replication is not setup its value is ignored.\n */\n protected mode: ReplicationMode;\n\n private cachedTablePaths: Record<string, string> = {};\n\n // -------------------------------------------------------------------------\n // Public Abstract Methods\n // -------------------------------------------------------------------------\n\n /**\n * Executes a given SQL query.\n */\n abstract query(query: string, parameters?: any[], useStructuredResult?: boolean): Promise<any>;\n\n // -------------------------------------------------------------------------\n // Protected Abstract Methods\n // -------------------------------------------------------------------------\n\n protected abstract loadTables(tablePaths?: string[]): Promise<Table[]>;\n\n protected abstract loadViews(tablePaths?: string[]): Promise<View[]>;\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Loads given table's data from the database.\n */\n async getTable(tablePath: string): Promise<Table|undefined> {\n this.loadedTables = await this.loadTables([tablePath]);\n return this.loadedTables.length > 0 ? this.loadedTables[0] : undefined;\n }\n\n /**\n * Loads all tables (with given names) from the database.\n */\n async getTables(tableNames?: string[]): Promise<Table[]> {\n if (!tableNames) {\n // Don't cache in this case.\n // This is the new case & isn't used anywhere else anyway.\n return await this.loadTables(tableNames);\n }\n\n this.loadedTables = await this.loadTables(tableNames);\n return this.loadedTables;\n }\n\n /**\n * Loads given view's data from the database.\n */\n async getView(viewPath: string): Promise<View|undefined> {\n this.loadedViews = await this.loadViews([viewPath]);\n return this.loadedViews.length > 0 ? this.loadedViews[0] : undefined;\n }\n\n /**\n * Loads given view's data from the database.\n */\n async getViews(viewPaths?: string[]): Promise<View[]> {\n this.loadedViews = await this.loadViews(viewPaths);\n return this.loadedViews;\n }\n\n /**\n * Enables special query runner mode in which sql queries won't be executed,\n * instead they will be memorized into a special variable inside query runner.\n * You can get memorized sql using getMemorySql() method.\n */\n enableSqlMemory(): void {\n this.sqlInMemory = new SqlInMemory();\n this.sqlMemoryMode = true;\n }\n\n /**\n * Disables special query runner mode in which sql queries won't be executed\n * started by calling enableSqlMemory() method.\n *\n * Previously memorized sql will be flushed.\n */\n disableSqlMemory(): void {\n this.sqlInMemory = new SqlInMemory();\n this.sqlMemoryMode = false;\n }\n\n /**\n * Flushes all memorized sqls.\n */\n clearSqlMemory(): void {\n this.sqlInMemory = new SqlInMemory();\n }\n\n /**\n * Gets sql stored in the memory. Parameters in the sql are already replaced.\n */\n getMemorySql(): SqlInMemory {\n return this.sqlInMemory;\n }\n\n /**\n * Executes up sql queries.\n */\n async executeMemoryUpSql(): Promise<void> {\n for (const {query, parameters} of this.sqlInMemory.upQueries) {\n await this.query(query, parameters);\n }\n }\n\n /**\n * Executes down sql queries.\n */\n async executeMemoryDownSql(): Promise<void> {\n for (const {query, parameters} of this.sqlInMemory.downQueries.reverse()) {\n await this.query(query, parameters);\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets view from previously loaded views, otherwise loads it from database.\n */\n protected async getCachedView(viewName: string): Promise<View> {\n const view = this.loadedViews.find(view => view.name === viewName);\n if (view) return view;\n\n const foundViews = await this.loadViews([viewName]);\n if (foundViews.length > 0) {\n this.loadedViews.push(foundViews[0]);\n return foundViews[0];\n } else {\n throw new TypeORMError(`View \"${viewName}\" does not exist.`);\n }\n }\n\n /**\n * Gets table from previously loaded tables, otherwise loads it from database.\n */\n protected async getCachedTable(tableName: string): Promise<Table> {\n if (tableName in this.cachedTablePaths) {\n const tablePath = this.cachedTablePaths[tableName];\n const table = this.loadedTables.find(table => this.getTablePath(table) === tablePath);\n\n if (table) {\n return table;\n }\n }\n\n const foundTables = await this.loadTables([tableName]);\n\n if (foundTables.length > 0) {\n const foundTablePath = this.getTablePath(foundTables[0]);\n\n const cachedTable = this.loadedTables.find((table) => this.getTablePath(table) === foundTablePath);\n\n if (!cachedTable) {\n this.cachedTablePaths[tableName] = this.getTablePath(foundTables[0]);\n this.loadedTables.push(foundTables[0]);\n return foundTables[0];\n } else {\n return cachedTable;\n }\n } else {\n throw new TypeORMError(`Table \"${tableName}\" does not exist.`);\n }\n }\n\n /**\n * Replaces loaded table with given changed table.\n */\n protected replaceCachedTable(table: Table, changedTable: Table): void {\n const oldTablePath = this.getTablePath(table);\n const foundTable = this.loadedTables.find(loadedTable => this.getTablePath(loadedTable) === oldTablePath);\n\n // Clean up the lookup cache..\n for (const [key, cachedPath] of Object.entries(this.cachedTablePaths)) {\n if (cachedPath === oldTablePath) {\n this.cachedTablePaths[key] = this.getTablePath(changedTable);\n }\n }\n\n if (foundTable) {\n foundTable.database = changedTable.database;\n foundTable.schema = changedTable.schema;\n foundTable.name = changedTable.name;\n foundTable.columns = changedTable.columns;\n foundTable.indices = changedTable.indices;\n foundTable.foreignKeys = changedTable.foreignKeys;\n foundTable.uniques = changedTable.uniques;\n foundTable.checks = changedTable.checks;\n foundTable.justCreated = changedTable.justCreated;\n foundTable.engine = changedTable.engine;\n }\n }\n\n protected getTablePath(target: EntityMetadata | Table | View | TableForeignKey | string): string {\n const parsed = this.connection.driver.parseTableName(target);\n\n return this.connection.driver.buildTableName(\n parsed.tableName,\n parsed.schema,\n parsed.database\n );\n }\n\n protected getTypeormMetadataTableName(): string {\n const options = <SqlServerConnectionOptions|PostgresConnectionOptions>this.connection.driver.options;\n return this.connection.driver.buildTableName(\"typeorm_metadata\", options.schema, options.database);\n }\n\n /**\n * Generates SQL query to insert a record into \"typeorm_metadata\" table.\n */\n protected insertTypeormMetadataSql({\n database,\n schema,\n table,\n type,\n name,\n value\n }: {\n database?: string,\n schema?: string,\n table?: string,\n type: MetadataTableType\n name: string,\n value?: string\n }): Query {\n const [query, parameters] = this.connection.createQueryBuilder()\n .insert()\n .into(this.getTypeormMetadataTableName())\n .values({ database: database, schema: schema, table: table, type: type, name: name, value: value })\n .getQueryAndParameters();\n\n return new Query(query, parameters);\n }\n\n /**\n * Generates SQL query to delete a record from \"typeorm_metadata\" table.\n */\n protected deleteTypeormMetadataSql({\n database,\n schema,\n table,\n type,\n name\n }: {\n database?: string,\n schema?: string,\n table?: string,\n type: MetadataTableType,\n name: string\n }): Query {\n\n const qb = this.connection.createQueryBuilder();\n const deleteQb = qb.delete()\n .from(this.getTypeormMetadataTableName())\n .where(`${qb.escape(\"type\")} = :type`, { type })\n .andWhere(`${qb.escape(\"name\")} = :name`, { name });\n\n if (database) {\n deleteQb.andWhere(`${qb.escape(\"database\")} = :database`, { database });\n }\n\n if (schema) {\n deleteQb.andWhere(`${qb.escape(\"schema\")} = :schema`, { schema });\n }\n\n if (table) {\n deleteQb.andWhere(`${qb.escape(\"table\")} = :table`, { table });\n }\n\n const [query, parameters] = deleteQb.getQueryAndParameters();\n return new Query(query, parameters);\n }\n\n /**\n * Checks if at least one of column properties was changed.\n * Does not checks column type, length and autoincrement, because these properties changes separately.\n */\n protected isColumnChanged(oldColumn: TableColumn, newColumn: TableColumn, checkDefault?: boolean, checkComment?: boolean): boolean {\n // this logs need to debug issues in column change detection. Do not delete it!\n\n // console.log(\"charset ---------------\");\n // console.log(oldColumn.charset !== newColumn.charset);\n // console.log(oldColumn.charset, newColumn.charset);\n // console.log(\"collation ---------------\");\n // console.log(oldColumn.collation !== newColumn.collation);\n // console.log(oldColumn.collation, newColumn.collation);\n // console.log(\"precision ---------------\");\n // console.log(oldColumn.precision !== newColumn.precision);\n // console.log(oldColumn.precision, newColumn.precision);\n // console.log(\"scale ---------------\");\n // console.log(oldColumn.scale !== newColumn.scale);\n // console.log(oldColumn.scale, newColumn.scale);\n // console.log(\"default ---------------\");\n // console.log((checkDefault && oldColumn.default !== newColumn.default));\n // console.log(oldColumn.default, newColumn.default);\n // console.log(\"isNullable ---------------\");\n // console.log(oldColumn.isNullable !== newColumn.isNullable);\n // console.log(oldColumn.isNullable, newColumn.isNullable);\n // console.log(\"comment ---------------\");\n // console.log((checkComment && oldColumn.comment !== newColumn.comment));\n // console.log(oldColumn.comment, newColumn.comment);\n // console.log(\"enum ---------------\");\n // console.log(!OrmUtils.isArraysEqual(oldColumn.enum || [], newColumn.enum || []));\n // console.log(oldColumn.enum, newColumn.enum);\n\n return oldColumn.charset !== newColumn.charset\n || oldColumn.collation !== newColumn.collation\n || oldColumn.precision !== newColumn.precision\n || oldColumn.scale !== newColumn.scale\n || oldColumn.width !== newColumn.width // MySQL only\n || oldColumn.zerofill !== newColumn.zerofill // MySQL only\n || oldColumn.unsigned !== newColumn.unsigned // MySQL only\n || oldColumn.asExpression !== newColumn.asExpression // MySQL only\n || (checkDefault && oldColumn.default !== newColumn.default)\n || oldColumn.onUpdate !== newColumn.onUpdate // MySQL only\n || oldColumn.isNullable !== newColumn.isNullable\n || (checkComment && oldColumn.comment !== newColumn.comment)\n || !OrmUtils.isArraysEqual(oldColumn.enum || [], newColumn.enum || []);\n }\n\n /**\n * Checks if column length is by default.\n */\n protected isDefaultColumnLength(table: Table, column: TableColumn, length: string): boolean {\n // if table have metadata, we check if length is specified in column metadata\n if (this.connection.hasMetadata(table.name)) {\n const metadata = this.connection.getMetadata(table.name);\n const columnMetadata = metadata.findColumnWithDatabaseName(column.name);\n\n if (columnMetadata) {\n const columnMetadataLength = this.connection.driver.getColumnLength(columnMetadata);\n if (columnMetadataLength)\n return false;\n }\n }\n\n if (this.connection.driver.dataTypeDefaults\n && this.connection.driver.dataTypeDefaults[column.type]\n && this.connection.driver.dataTypeDefaults[column.type].length) {\n return this.connection.driver.dataTypeDefaults[column.type].length!.toString() === length.toString();\n }\n\n return false;\n }\n\n /**\n * Checks if column precision is by default.\n */\n protected isDefaultColumnPrecision(table: Table, column: TableColumn, precision: number): boolean {\n // if table have metadata, we check if length is specified in column metadata\n if (this.connection.hasMetadata(table.name)) {\n const metadata = this.connection.getMetadata(table.name);\n const columnMetadata = metadata.findColumnWithDatabaseName(column.name);\n if (columnMetadata && columnMetadata.precision !== null && columnMetadata.precision !== undefined)\n return false;\n }\n\n if (this.connection.driver.dataTypeDefaults\n && this.connection.driver.dataTypeDefaults[column.type]\n && this.connection.driver.dataTypeDefaults[column.type].precision !== null\n && this.connection.driver.dataTypeDefaults[column.type].precision !== undefined)\n return this.connection.driver.dataTypeDefaults[column.type].precision === precision;\n\n return false;\n }\n\n /**\n * Checks if column scale is by default.\n */\n protected isDefaultColumnScale(table: Table, column: TableColumn, scale: number): boolean {\n // if table have metadata, we check if length is specified in column metadata\n if (this.connection.hasMetadata(table.name)) {\n const metadata = this.connection.getMetadata(table.name);\n const columnMetadata = metadata.findColumnWithDatabaseName(column.name);\n if (columnMetadata && columnMetadata.scale !== null && columnMetadata.scale !== undefined)\n return false;\n }\n\n if (this.connection.driver.dataTypeDefaults\n && this.connection.driver.dataTypeDefaults[column.type]\n && this.connection.driver.dataTypeDefaults[column.type].scale !== null\n && this.connection.driver.dataTypeDefaults[column.type].scale !== undefined)\n return this.connection.driver.dataTypeDefaults[column.type].scale === scale;\n\n return false;\n }\n\n /**\n * Executes sql used special for schema build.\n */\n protected async executeQueries(upQueries: Query|Query[], downQueries: Query|Query[]): Promise<void> {\n if (upQueries instanceof Query)\n upQueries = [upQueries];\n if (downQueries instanceof Query)\n downQueries = [downQueries];\n\n this.sqlInMemory.upQueries.push(...upQueries);\n this.sqlInMemory.downQueries.push(...downQueries);\n\n // if sql-in-memory mode is enabled then simply store sql in memory and return\n if (this.sqlMemoryMode === true)\n return Promise.resolve() as Promise<any>;\n\n for (const {query, parameters} of upQueries) {\n await this.query(query, parameters);\n }\n }\n\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/query-runner/BaseQueryRunner.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAC;AASlD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C;IAAA;QAEI,4EAA4E;QAC5E,oBAAoB;QACpB,4EAA4E;QAY5E;;;WAGG;QACH,eAAU,GAAG,KAAK,CAAC;QAEnB;;WAEG;QACH,wBAAmB,GAAG,KAAK,CAAC;QAE5B;;;WAGG;QACH,SAAI,GAAG,EAAE,CAAC;QAEV;;WAEG;QACH,iBAAY,GAAY,EAAE,CAAC;QAE3B;;WAEG;QACH,gBAAW,GAAW,EAAE,CAAC;QAgBzB;;WAE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S,WAAE;wBAC9C,CAAA,KAAA,IAAI,CAAC,WAAW,CAAC,WAAW,CAAA,CAAC,IAAI,oCAAI,WAAW,WAAE;wBAElD,8EAA8E;wBAC9E,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI;4BAC3B,sBAAO,OAAO,CAAC,OAAO,EAAkB,EAAC;;;;wBAEX,cAAA,SAAA,SAAS,CAAA;;;;wBAAhC,wBAAmB,EAAlB,KAAK,WAAA,EAAE,UAAU,gBAAA;wBACzB,qBAAM,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,EAAA;;wBAAnC,SAAmC,CAAC;;;;;;;;;;;;;;;;;;;;KAE3C;IAEL,sBAAC;AAAD,CAxeA,AAweC,IAAA","file":"BaseQueryRunner.js","sourcesContent":["import {PostgresConnectionOptions} from \"../driver/postgres/PostgresConnectionOptions\";\nimport {Query} from \"../driver/Query\";\nimport {SqlInMemory} from \"../driver/SqlInMemory\";\nimport {SqlServerConnectionOptions} from \"../driver/sqlserver/SqlServerConnectionOptions\";\nimport {View} from \"../schema-builder/view/View\";\nimport {Connection} from \"../connection/Connection\";\nimport {Table} from \"../schema-builder/table/Table\";\nimport {EntityManager} from \"../entity-manager/EntityManager\";\nimport {TableColumn} from \"../schema-builder/table/TableColumn\";\nimport {Broadcaster} from \"../subscriber/Broadcaster\";\nimport {ReplicationMode} from \"../driver/types/ReplicationMode\";\nimport { TypeORMError } from \"../error/TypeORMError\";\nimport { EntityMetadata } from \"../metadata/EntityMetadata\";\nimport { TableForeignKey } from \"../schema-builder/table/TableForeignKey\";\nimport { OrmUtils } from \"../util/OrmUtils\";\nimport {MetadataTableType} from \"../driver/types/MetadataTableType\";\n\nexport abstract class BaseQueryRunner {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection used by this query runner.\n */\n connection: Connection;\n\n /**\n * Entity manager working only with current query runner.\n */\n manager: EntityManager;\n\n /**\n * Indicates if connection for this query runner is released.\n * Once its released, query runner cannot run queries anymore.\n */\n isReleased = false;\n\n /**\n * Indicates if transaction is in progress.\n */\n isTransactionActive = false;\n\n /**\n * Stores temporarily user data.\n * Useful for sharing data with subscribers.\n */\n data = {};\n\n /**\n * All synchronized tables in the database.\n */\n loadedTables: Table[] = [];\n\n /**\n * All synchronized views in the database.\n */\n loadedViews: View[] = [];\n\n /**\n * Broadcaster used on this query runner to broadcast entity events.\n */\n broadcaster: Broadcaster;\n\n // -------------------------------------------------------------------------\n // Protected Properties\n // -------------------------------------------------------------------------\n\n /**\n * Real database connection from a connection pool used to perform queries.\n */\n protected databaseConnection: any;\n\n /**\n * Indicates if special query runner mode in which sql queries won't be executed is enabled.\n */\n protected sqlMemoryMode: boolean = false;\n\n /**\n * Sql-s stored if \"sql in memory\" mode is enabled.\n */\n protected sqlInMemory: SqlInMemory = new SqlInMemory();\n\n /**\n * Mode in which query runner executes.\n * Used for replication.\n * If replication is not setup its value is ignored.\n */\n protected mode: ReplicationMode;\n\n private cachedTablePaths: Record<string, string> = {};\n\n // -------------------------------------------------------------------------\n // Public Abstract Methods\n // -------------------------------------------------------------------------\n\n /**\n * Executes a given SQL query.\n */\n abstract query(query: string, parameters?: any[], useStructuredResult?: boolean): Promise<any>;\n\n // -------------------------------------------------------------------------\n // Protected Abstract Methods\n // -------------------------------------------------------------------------\n\n protected abstract loadTables(tablePaths?: string[]): Promise<Table[]>;\n\n protected abstract loadViews(tablePaths?: string[]): Promise<View[]>;\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Loads given table's data from the database.\n */\n async getTable(tablePath: string): Promise<Table|undefined> {\n this.loadedTables = await this.loadTables([tablePath]);\n return this.loadedTables.length > 0 ? this.loadedTables[0] : undefined;\n }\n\n /**\n * Loads all tables (with given names) from the database.\n */\n async getTables(tableNames?: string[]): Promise<Table[]> {\n if (!tableNames) {\n // Don't cache in this case.\n // This is the new case & isn't used anywhere else anyway.\n return await this.loadTables(tableNames);\n }\n\n this.loadedTables = await this.loadTables(tableNames);\n return this.loadedTables;\n }\n\n /**\n * Loads given view's data from the database.\n */\n async getView(viewPath: string): Promise<View|undefined> {\n this.loadedViews = await this.loadViews([viewPath]);\n return this.loadedViews.length > 0 ? this.loadedViews[0] : undefined;\n }\n\n /**\n * Loads given view's data from the database.\n */\n async getViews(viewPaths?: string[]): Promise<View[]> {\n this.loadedViews = await this.loadViews(viewPaths);\n return this.loadedViews;\n }\n\n /**\n * Enables special query runner mode in which sql queries won't be executed,\n * instead they will be memorized into a special variable inside query runner.\n * You can get memorized sql using getMemorySql() method.\n */\n enableSqlMemory(): void {\n this.sqlInMemory = new SqlInMemory();\n this.sqlMemoryMode = true;\n }\n\n /**\n * Disables special query runner mode in which sql queries won't be executed\n * started by calling enableSqlMemory() method.\n *\n * Previously memorized sql will be flushed.\n */\n disableSqlMemory(): void {\n this.sqlInMemory = new SqlInMemory();\n this.sqlMemoryMode = false;\n }\n\n /**\n * Flushes all memorized sqls.\n */\n clearSqlMemory(): void {\n this.sqlInMemory = new SqlInMemory();\n }\n\n /**\n * Gets sql stored in the memory. Parameters in the sql are already replaced.\n */\n getMemorySql(): SqlInMemory {\n return this.sqlInMemory;\n }\n\n /**\n * Executes up sql queries.\n */\n async executeMemoryUpSql(): Promise<void> {\n for (const {query, parameters} of this.sqlInMemory.upQueries) {\n await this.query(query, parameters);\n }\n }\n\n /**\n * Executes down sql queries.\n */\n async executeMemoryDownSql(): Promise<void> {\n for (const {query, parameters} of this.sqlInMemory.downQueries.reverse()) {\n await this.query(query, parameters);\n }\n }\n\n getReplicationMode(): ReplicationMode {\n return this.mode;\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets view from previously loaded views, otherwise loads it from database.\n */\n protected async getCachedView(viewName: string): Promise<View> {\n const view = this.loadedViews.find(view => view.name === viewName);\n if (view) return view;\n\n const foundViews = await this.loadViews([viewName]);\n if (foundViews.length > 0) {\n this.loadedViews.push(foundViews[0]);\n return foundViews[0];\n } else {\n throw new TypeORMError(`View \"${viewName}\" does not exist.`);\n }\n }\n\n /**\n * Gets table from previously loaded tables, otherwise loads it from database.\n */\n protected async getCachedTable(tableName: string): Promise<Table> {\n if (tableName in this.cachedTablePaths) {\n const tablePath = this.cachedTablePaths[tableName];\n const table = this.loadedTables.find(table => this.getTablePath(table) === tablePath);\n\n if (table) {\n return table;\n }\n }\n\n const foundTables = await this.loadTables([tableName]);\n\n if (foundTables.length > 0) {\n const foundTablePath = this.getTablePath(foundTables[0]);\n\n const cachedTable = this.loadedTables.find((table) => this.getTablePath(table) === foundTablePath);\n\n if (!cachedTable) {\n this.cachedTablePaths[tableName] = this.getTablePath(foundTables[0]);\n this.loadedTables.push(foundTables[0]);\n return foundTables[0];\n } else {\n return cachedTable;\n }\n } else {\n throw new TypeORMError(`Table \"${tableName}\" does not exist.`);\n }\n }\n\n /**\n * Replaces loaded table with given changed table.\n */\n protected replaceCachedTable(table: Table, changedTable: Table): void {\n const oldTablePath = this.getTablePath(table);\n const foundTable = this.loadedTables.find(loadedTable => this.getTablePath(loadedTable) === oldTablePath);\n\n // Clean up the lookup cache..\n for (const [key, cachedPath] of Object.entries(this.cachedTablePaths)) {\n if (cachedPath === oldTablePath) {\n this.cachedTablePaths[key] = this.getTablePath(changedTable);\n }\n }\n\n if (foundTable) {\n foundTable.database = changedTable.database;\n foundTable.schema = changedTable.schema;\n foundTable.name = changedTable.name;\n foundTable.columns = changedTable.columns;\n foundTable.indices = changedTable.indices;\n foundTable.foreignKeys = changedTable.foreignKeys;\n foundTable.uniques = changedTable.uniques;\n foundTable.checks = changedTable.checks;\n foundTable.justCreated = changedTable.justCreated;\n foundTable.engine = changedTable.engine;\n }\n }\n\n protected getTablePath(target: EntityMetadata | Table | View | TableForeignKey | string): string {\n const parsed = this.connection.driver.parseTableName(target);\n\n return this.connection.driver.buildTableName(\n parsed.tableName,\n parsed.schema,\n parsed.database\n );\n }\n\n protected getTypeormMetadataTableName(): string {\n const options = <SqlServerConnectionOptions|PostgresConnectionOptions>this.connection.driver.options;\n return this.connection.driver.buildTableName(\"typeorm_metadata\", options.schema, options.database);\n }\n\n /**\n * Generates SQL query to insert a record into \"typeorm_metadata\" table.\n */\n protected insertTypeormMetadataSql({\n database,\n schema,\n table,\n type,\n name,\n value\n }: {\n database?: string,\n schema?: string,\n table?: string,\n type: MetadataTableType\n name: string,\n value?: string\n }): Query {\n const [query, parameters] = this.connection.createQueryBuilder()\n .insert()\n .into(this.getTypeormMetadataTableName())\n .values({ database: database, schema: schema, table: table, type: type, name: name, value: value })\n .getQueryAndParameters();\n\n return new Query(query, parameters);\n }\n\n /**\n * Generates SQL query to delete a record from \"typeorm_metadata\" table.\n */\n protected deleteTypeormMetadataSql({\n database,\n schema,\n table,\n type,\n name\n }: {\n database?: string,\n schema?: string,\n table?: string,\n type: MetadataTableType,\n name: string\n }): Query {\n\n const qb = this.connection.createQueryBuilder();\n const deleteQb = qb.delete()\n .from(this.getTypeormMetadataTableName())\n .where(`${qb.escape(\"type\")} = :type`, { type })\n .andWhere(`${qb.escape(\"name\")} = :name`, { name });\n\n if (database) {\n deleteQb.andWhere(`${qb.escape(\"database\")} = :database`, { database });\n }\n\n if (schema) {\n deleteQb.andWhere(`${qb.escape(\"schema\")} = :schema`, { schema });\n }\n\n if (table) {\n deleteQb.andWhere(`${qb.escape(\"table\")} = :table`, { table });\n }\n\n const [query, parameters] = deleteQb.getQueryAndParameters();\n return new Query(query, parameters);\n }\n\n /**\n * Checks if at least one of column properties was changed.\n * Does not checks column type, length and autoincrement, because these properties changes separately.\n */\n protected isColumnChanged(oldColumn: TableColumn, newColumn: TableColumn, checkDefault?: boolean, checkComment?: boolean): boolean {\n // this logs need to debug issues in column change detection. Do not delete it!\n\n // console.log(\"charset ---------------\");\n // console.log(oldColumn.charset !== newColumn.charset);\n // console.log(oldColumn.charset, newColumn.charset);\n // console.log(\"collation ---------------\");\n // console.log(oldColumn.collation !== newColumn.collation);\n // console.log(oldColumn.collation, newColumn.collation);\n // console.log(\"precision ---------------\");\n // console.log(oldColumn.precision !== newColumn.precision);\n // console.log(oldColumn.precision, newColumn.precision);\n // console.log(\"scale ---------------\");\n // console.log(oldColumn.scale !== newColumn.scale);\n // console.log(oldColumn.scale, newColumn.scale);\n // console.log(\"default ---------------\");\n // console.log((checkDefault && oldColumn.default !== newColumn.default));\n // console.log(oldColumn.default, newColumn.default);\n // console.log(\"isNullable ---------------\");\n // console.log(oldColumn.isNullable !== newColumn.isNullable);\n // console.log(oldColumn.isNullable, newColumn.isNullable);\n // console.log(\"comment ---------------\");\n // console.log((checkComment && oldColumn.comment !== newColumn.comment));\n // console.log(oldColumn.comment, newColumn.comment);\n // console.log(\"enum ---------------\");\n // console.log(!OrmUtils.isArraysEqual(oldColumn.enum || [], newColumn.enum || []));\n // console.log(oldColumn.enum, newColumn.enum);\n\n return oldColumn.charset !== newColumn.charset\n || oldColumn.collation !== newColumn.collation\n || oldColumn.precision !== newColumn.precision\n || oldColumn.scale !== newColumn.scale\n || oldColumn.width !== newColumn.width // MySQL only\n || oldColumn.zerofill !== newColumn.zerofill // MySQL only\n || oldColumn.unsigned !== newColumn.unsigned // MySQL only\n || oldColumn.asExpression !== newColumn.asExpression // MySQL only\n || (checkDefault && oldColumn.default !== newColumn.default)\n || oldColumn.onUpdate !== newColumn.onUpdate // MySQL only\n || oldColumn.isNullable !== newColumn.isNullable\n || (checkComment && oldColumn.comment !== newColumn.comment)\n || !OrmUtils.isArraysEqual(oldColumn.enum || [], newColumn.enum || []);\n }\n\n /**\n * Checks if column length is by default.\n */\n protected isDefaultColumnLength(table: Table, column: TableColumn, length: string): boolean {\n // if table have metadata, we check if length is specified in column metadata\n if (this.connection.hasMetadata(table.name)) {\n const metadata = this.connection.getMetadata(table.name);\n const columnMetadata = metadata.findColumnWithDatabaseName(column.name);\n\n if (columnMetadata) {\n const columnMetadataLength = this.connection.driver.getColumnLength(columnMetadata);\n if (columnMetadataLength)\n return false;\n }\n }\n\n if (this.connection.driver.dataTypeDefaults\n && this.connection.driver.dataTypeDefaults[column.type]\n && this.connection.driver.dataTypeDefaults[column.type].length) {\n return this.connection.driver.dataTypeDefaults[column.type].length!.toString() === length.toString();\n }\n\n return false;\n }\n\n /**\n * Checks if column precision is by default.\n */\n protected isDefaultColumnPrecision(table: Table, column: TableColumn, precision: number): boolean {\n // if table have metadata, we check if length is specified in column metadata\n if (this.connection.hasMetadata(table.name)) {\n const metadata = this.connection.getMetadata(table.name);\n const columnMetadata = metadata.findColumnWithDatabaseName(column.name);\n if (columnMetadata && columnMetadata.precision !== null && columnMetadata.precision !== undefined)\n return false;\n }\n\n if (this.connection.driver.dataTypeDefaults\n && this.connection.driver.dataTypeDefaults[column.type]\n && this.connection.driver.dataTypeDefaults[column.type].precision !== null\n && this.connection.driver.dataTypeDefaults[column.type].precision !== undefined)\n return this.connection.driver.dataTypeDefaults[column.type].precision === precision;\n\n return false;\n }\n\n /**\n * Checks if column scale is by default.\n */\n protected isDefaultColumnScale(table: Table, column: TableColumn, scale: number): boolean {\n // if table have metadata, we check if length is specified in column metadata\n if (this.connection.hasMetadata(table.name)) {\n const metadata = this.connection.getMetadata(table.name);\n const columnMetadata = metadata.findColumnWithDatabaseName(column.name);\n if (columnMetadata && columnMetadata.scale !== null && columnMetadata.scale !== undefined)\n return false;\n }\n\n if (this.connection.driver.dataTypeDefaults\n && this.connection.driver.dataTypeDefaults[column.type]\n && this.connection.driver.dataTypeDefaults[column.type].scale !== null\n && this.connection.driver.dataTypeDefaults[column.type].scale !== undefined)\n return this.connection.driver.dataTypeDefaults[column.type].scale === scale;\n\n return false;\n }\n\n /**\n * Executes sql used special for schema build.\n */\n protected async executeQueries(upQueries: Query|Query[], downQueries: Query|Query[]): Promise<void> {\n if (upQueries instanceof Query)\n upQueries = [upQueries];\n if (downQueries instanceof Query)\n downQueries = [downQueries];\n\n this.sqlInMemory.upQueries.push(...upQueries);\n this.sqlInMemory.downQueries.push(...downQueries);\n\n // if sql-in-memory mode is enabled then simply store sql in memory and return\n if (this.sqlMemoryMode === true)\n return Promise.resolve() as Promise<any>;\n\n for (const {query, parameters} of upQueries) {\n await this.query(query, parameters);\n }\n }\n\n}\n"],"sourceRoot":".."}
|
|
@@ -15,6 +15,7 @@ import { TableCheck } from "../schema-builder/table/TableCheck";
|
|
|
15
15
|
import { IsolationLevel } from "../driver/types/IsolationLevel";
|
|
16
16
|
import { TableExclusion } from "../schema-builder/table/TableExclusion";
|
|
17
17
|
import { QueryResult } from "./QueryResult";
|
|
18
|
+
import { ReplicationMode } from "../driver/types/ReplicationMode";
|
|
18
19
|
/**
|
|
19
20
|
* Runs queries on a single database connection.
|
|
20
21
|
*/
|
|
@@ -125,6 +126,10 @@ export interface QueryRunner {
|
|
|
125
126
|
* Loads all views from the database and returns them.
|
|
126
127
|
*/
|
|
127
128
|
getViews(viewPaths?: string[]): Promise<View[]>;
|
|
129
|
+
/**
|
|
130
|
+
* Returns replication mode (ex: `master` or `slave`).
|
|
131
|
+
*/
|
|
132
|
+
getReplicationMode(): ReplicationMode;
|
|
128
133
|
/**
|
|
129
134
|
* Checks if a database with the given name exist.
|
|
130
135
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/query-runner/QueryRunner.ts"],"names":[],"mappings":"","file":"QueryRunner.js","sourcesContent":["import {TableColumn} from \"../schema-builder/table/TableColumn\";\nimport {Table} from \"../schema-builder/table/Table\";\nimport {TableForeignKey} from \"../schema-builder/table/TableForeignKey\";\nimport {TableIndex} from \"../schema-builder/table/TableIndex\";\nimport {Connection} from \"../connection/Connection\";\nimport {ReadStream} from \"../platform/PlatformTools\";\nimport {EntityManager} from \"../entity-manager/EntityManager\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {SqlInMemory} from \"../driver/SqlInMemory\";\nimport {TableUnique} from \"../schema-builder/table/TableUnique\";\nimport {View} from \"../schema-builder/view/View\";\nimport {Broadcaster} from \"../subscriber/Broadcaster\";\nimport {TableCheck} from \"../schema-builder/table/TableCheck\";\nimport {IsolationLevel} from \"../driver/types/IsolationLevel\";\nimport {TableExclusion} from \"../schema-builder/table/TableExclusion\";\nimport {QueryResult} from \"./QueryResult\";\n\n/**\n * Runs queries on a single database connection.\n */\nexport interface QueryRunner {\n\n /**\n * Connection used by this query runner.\n */\n readonly connection: Connection;\n\n /**\n * Broadcaster used on this query runner to broadcast entity events.\n */\n readonly broadcaster: Broadcaster;\n\n /**\n * Entity manager working only with this query runner.\n */\n readonly manager: EntityManager;\n\n /**\n * Indicates if connection for this query runner is released.\n * Once its released, query runner cannot run queries anymore.\n */\n readonly isReleased: boolean;\n\n /**\n * Indicates if transaction is in progress.\n */\n readonly isTransactionActive: boolean;\n\n /**\n * Stores temporarily user data.\n * Useful for sharing data with subscribers.\n */\n data: ObjectLiteral;\n\n /**\n * All synchronized tables in the database.\n *\n * @deprecated Call `getTables()`\n */\n loadedTables: Table[];\n\n /**\n * All synchronized views in the database.\n *\n * @deprecated Call `getViews()`\n */\n loadedViews: View[];\n\n /**\n * Creates/uses database connection from the connection pool to perform further operations.\n * Returns obtained database connection.\n */\n connect(): Promise<any>;\n\n /**\n * Releases used database connection.\n * You cannot use query runner methods after connection is released.\n */\n release(): Promise<void>;\n\n /**\n * Removes all tables from the currently connected database.\n * Be careful with using this method and avoid using it in production or migrations\n * (because it can clear all your database).\n */\n clearDatabase(database?: string): Promise<void>;\n\n /**\n * Starts transaction.\n */\n startTransaction(isolationLevel?: IsolationLevel): Promise<void>;\n\n /**\n * Commits transaction.\n * Error will be thrown if transaction was not started.\n */\n commitTransaction(): Promise<void>;\n\n /**\n * Rollbacks transaction.\n * Error will be thrown if transaction was not started.\n */\n rollbackTransaction(): Promise<void>;\n\n /**\n * Executes a given SQL query and returns raw database results.\n */\n query(query: string, parameters: any[] | undefined, useStructuredResult: true): Promise<QueryResult>;\n\n /**\n * Executes a given SQL query and returns raw database results.\n */\n query(query: string, parameters?: any[]): Promise<any>;\n\n /**\n * Returns raw data stream.\n */\n stream(query: string, parameters?: any[], onEnd?: Function, onError?: Function): Promise<ReadStream>;\n\n /**\n * Returns all available database names including system databases.\n */\n getDatabases(): Promise<string[]>;\n\n /**\n * Returns all available schema names including system schemas.\n * If database parameter specified, returns schemas of that database.\n * Useful for SQLServer and Postgres only.\n */\n getSchemas(database?: string): Promise<string[]>;\n\n /**\n * Loads a table by a given name from the database.\n */\n getTable(tablePath: string): Promise<Table|undefined>;\n\n /**\n * Loads all tables from the database and returns them.\n */\n getTables(tablePaths?: string[]): Promise<Table[]>;\n\n /**\n * Loads a view by a given name from the database.\n */\n getView(viewPath: string): Promise<View|undefined>;\n\n /**\n * Loads all views from the database and returns them.\n */\n getViews(viewPaths?: string[]): Promise<View[]>;\n\n /**\n * Checks if a database with the given name exist.\n */\n hasDatabase(database: string): Promise<boolean>;\n\n /**\n * Loads currently using database\n */\n getCurrentDatabase(): Promise<string|undefined>;\n\n /**\n * Checks if a schema with the given name exist.\n */\n hasSchema(schema: string): Promise<boolean>;\n\n /**\n * Loads currently using database schema\n */\n getCurrentSchema(): Promise<string|undefined>;\n\n /**\n * Checks if a table with the given name exist.\n */\n hasTable(table: Table|string): Promise<boolean>;\n\n /**\n * Checks if a column exist in the table.\n */\n hasColumn(table: Table|string, columnName: string): Promise<boolean>;\n\n /**\n * Creates a new database.\n */\n createDatabase(database: string, ifNotExist?: boolean): Promise<void>;\n\n /**\n * Drops database.\n */\n dropDatabase(database: string, ifExist?: boolean): Promise<void>;\n\n /**\n * Creates a new table schema.\n */\n createSchema(schemaPath: string, ifNotExist?: boolean): Promise<void>;\n\n /**\n * Drops table schema.\n * For SqlServer can accept schema path (e.g. 'dbName.schemaName') as parameter.\n * If schema path passed, it will drop schema in specified database.\n */\n dropSchema(schemaPath: string, ifExist?: boolean, isCascade?: boolean): Promise<void>;\n\n /**\n * Creates a new table.\n */\n createTable(table: Table, ifNotExist?: boolean, createForeignKeys?: boolean, createIndices?: boolean): Promise<void>;\n\n /**\n * Drops a table.\n */\n dropTable(table: Table|string, ifExist?: boolean, dropForeignKeys?: boolean, dropIndices?: boolean): Promise<void>;\n\n /**\n * Creates a new view.\n */\n createView(view: View, oldView?: View): Promise<void>;\n\n /**\n * Drops a view.\n */\n dropView(view: View|string): Promise<void>;\n\n /**\n * Renames a table.\n */\n renameTable(oldTableOrName: Table|string, newTableName: string): Promise<void>;\n\n /**\n * Adds a new column.\n */\n addColumn(table: Table|string, column: TableColumn): Promise<void>;\n\n /**\n * Adds new columns.\n */\n addColumns(table: Table|string, columns: TableColumn[]): Promise<void>;\n\n /**\n * Renames a column.\n */\n renameColumn(table: Table|string, oldColumnOrName: TableColumn|string, newColumnOrName: TableColumn|string): Promise<void>;\n\n /**\n * Changes a column in the table.\n */\n changeColumn(table: Table|string, oldColumn: TableColumn|string, newColumn: TableColumn): Promise<void>;\n\n /**\n * Changes columns in the table.\n */\n changeColumns(table: Table|string, changedColumns: { oldColumn: TableColumn, newColumn: TableColumn }[]): Promise<void>;\n\n /**\n * Drops a column in the table.\n */\n dropColumn(table: Table|string, column: TableColumn|string): Promise<void>;\n\n /**\n * Drops columns in the table.\n */\n dropColumns(table: Table|string, columns: TableColumn[]|string[]): Promise<void>;\n\n /**\n * Creates a new primary key.\n */\n createPrimaryKey(table: Table|string, columnNames: string[]): Promise<void>;\n\n /**\n * Updates composite primary keys.\n */\n updatePrimaryKeys(table: Table|string, columns: TableColumn[]): Promise<void>;\n\n /**\n * Drops a primary key.\n */\n dropPrimaryKey(table: Table|string): Promise<void>;\n\n /**\n * Creates a new unique constraint.\n */\n createUniqueConstraint(table: Table|string, uniqueConstraint: TableUnique): Promise<void>;\n\n /**\n * Creates new unique constraints.\n */\n createUniqueConstraints(table: Table|string, uniqueConstraints: TableUnique[]): Promise<void>;\n\n /**\n * Drops an unique constraint.\n */\n dropUniqueConstraint(table: Table|string, uniqueOrName: TableUnique|string): Promise<void>;\n\n /**\n * Drops unique constraints.\n */\n dropUniqueConstraints(table: Table|string, uniqueConstraints: TableUnique[]): Promise<void>;\n\n /**\n * Creates a new check constraint.\n */\n createCheckConstraint(table: Table|string, checkConstraint: TableCheck): Promise<void>;\n\n /**\n * Creates new check constraints.\n */\n createCheckConstraints(table: Table|string, checkConstraints: TableCheck[]): Promise<void>;\n\n /**\n * Drops a check constraint.\n */\n dropCheckConstraint(table: Table|string, checkOrName: TableCheck|string): Promise<void>;\n\n /**\n * Drops check constraints.\n */\n dropCheckConstraints(table: Table|string, checkConstraints: TableCheck[]): Promise<void>;\n\n /**\n * Creates a new exclusion constraint.\n */\n createExclusionConstraint(table: Table|string, exclusionConstraint: TableExclusion): Promise<void>;\n\n /**\n * Creates new exclusion constraints.\n */\n createExclusionConstraints(table: Table|string, exclusionConstraints: TableExclusion[]): Promise<void>;\n\n /**\n * Drops a exclusion constraint.\n */\n dropExclusionConstraint(table: Table|string, exclusionOrName: TableExclusion|string): Promise<void>;\n\n /**\n * Drops exclusion constraints.\n */\n dropExclusionConstraints(table: Table|string, exclusionConstraints: TableExclusion[]): Promise<void>;\n\n /**\n * Creates a new foreign key.\n */\n createForeignKey(table: Table|string, foreignKey: TableForeignKey): Promise<void>;\n\n /**\n * Creates new foreign keys.\n */\n createForeignKeys(table: Table|string, foreignKeys: TableForeignKey[]): Promise<void>;\n\n /**\n * Drops a foreign key.\n */\n dropForeignKey(table: Table|string, foreignKeyOrName: TableForeignKey|string): Promise<void>;\n\n /**\n * Drops foreign keys.\n */\n dropForeignKeys(table: Table|string, foreignKeys: TableForeignKey[]): Promise<void>;\n\n /**\n * Creates a new index.\n */\n createIndex(table: Table|string, index: TableIndex): Promise<void>;\n\n /**\n * Creates new indices.\n */\n createIndices(table: Table|string, indices: TableIndex[]): Promise<void>;\n\n /**\n * Drops an index.\n */\n dropIndex(table: Table|string, index: TableIndex|string): Promise<void>;\n\n /**\n * Drops indices.\n */\n dropIndices(table: Table|string, indices: TableIndex[]): Promise<void>;\n\n /**\n * Clears all table contents.\n * Note: this operation uses SQL's TRUNCATE query which cannot be reverted in transactions.\n */\n clearTable(tableName: string): Promise<void>;\n\n /**\n * Enables special query runner mode in which sql queries won't be executed,\n * instead they will be memorized into a special variable inside query runner.\n * You can get memorized sql using getMemorySql() method.\n */\n enableSqlMemory(): void;\n\n /**\n * Disables special query runner mode in which sql queries won't be executed\n * started by calling enableSqlMemory() method.\n *\n * Previously memorized sql will be flushed.\n */\n disableSqlMemory(): void;\n\n /**\n * Flushes all memorized sqls.\n */\n clearSqlMemory(): void;\n\n /**\n * Gets sql stored in the memory. Parameters in the sql are already replaced.\n */\n getMemorySql(): SqlInMemory;\n\n /**\n * Executes up sql queries.\n */\n executeMemoryUpSql(): Promise<void>;\n\n /**\n * Executes down sql queries.\n */\n executeMemoryDownSql(): Promise<void>;\n\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/query-runner/QueryRunner.ts"],"names":[],"mappings":"","file":"QueryRunner.js","sourcesContent":["import {TableColumn} from \"../schema-builder/table/TableColumn\";\nimport {Table} from \"../schema-builder/table/Table\";\nimport {TableForeignKey} from \"../schema-builder/table/TableForeignKey\";\nimport {TableIndex} from \"../schema-builder/table/TableIndex\";\nimport {Connection} from \"../connection/Connection\";\nimport {ReadStream} from \"../platform/PlatformTools\";\nimport {EntityManager} from \"../entity-manager/EntityManager\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {SqlInMemory} from \"../driver/SqlInMemory\";\nimport {TableUnique} from \"../schema-builder/table/TableUnique\";\nimport {View} from \"../schema-builder/view/View\";\nimport {Broadcaster} from \"../subscriber/Broadcaster\";\nimport {TableCheck} from \"../schema-builder/table/TableCheck\";\nimport {IsolationLevel} from \"../driver/types/IsolationLevel\";\nimport {TableExclusion} from \"../schema-builder/table/TableExclusion\";\nimport {QueryResult} from \"./QueryResult\";\nimport {ReplicationMode} from \"../driver/types/ReplicationMode\";\n\n/**\n * Runs queries on a single database connection.\n */\nexport interface QueryRunner {\n\n /**\n * Connection used by this query runner.\n */\n readonly connection: Connection;\n\n /**\n * Broadcaster used on this query runner to broadcast entity events.\n */\n readonly broadcaster: Broadcaster;\n\n /**\n * Entity manager working only with this query runner.\n */\n readonly manager: EntityManager;\n\n /**\n * Indicates if connection for this query runner is released.\n * Once its released, query runner cannot run queries anymore.\n */\n readonly isReleased: boolean;\n\n /**\n * Indicates if transaction is in progress.\n */\n readonly isTransactionActive: boolean;\n\n /**\n * Stores temporarily user data.\n * Useful for sharing data with subscribers.\n */\n data: ObjectLiteral;\n\n /**\n * All synchronized tables in the database.\n *\n * @deprecated Call `getTables()`\n */\n loadedTables: Table[];\n\n /**\n * All synchronized views in the database.\n *\n * @deprecated Call `getViews()`\n */\n loadedViews: View[];\n\n /**\n * Creates/uses database connection from the connection pool to perform further operations.\n * Returns obtained database connection.\n */\n connect(): Promise<any>;\n\n /**\n * Releases used database connection.\n * You cannot use query runner methods after connection is released.\n */\n release(): Promise<void>;\n\n /**\n * Removes all tables from the currently connected database.\n * Be careful with using this method and avoid using it in production or migrations\n * (because it can clear all your database).\n */\n clearDatabase(database?: string): Promise<void>;\n\n /**\n * Starts transaction.\n */\n startTransaction(isolationLevel?: IsolationLevel): Promise<void>;\n\n /**\n * Commits transaction.\n * Error will be thrown if transaction was not started.\n */\n commitTransaction(): Promise<void>;\n\n /**\n * Rollbacks transaction.\n * Error will be thrown if transaction was not started.\n */\n rollbackTransaction(): Promise<void>;\n\n /**\n * Executes a given SQL query and returns raw database results.\n */\n query(query: string, parameters: any[] | undefined, useStructuredResult: true): Promise<QueryResult>;\n\n /**\n * Executes a given SQL query and returns raw database results.\n */\n query(query: string, parameters?: any[]): Promise<any>;\n\n /**\n * Returns raw data stream.\n */\n stream(query: string, parameters?: any[], onEnd?: Function, onError?: Function): Promise<ReadStream>;\n\n /**\n * Returns all available database names including system databases.\n */\n getDatabases(): Promise<string[]>;\n\n /**\n * Returns all available schema names including system schemas.\n * If database parameter specified, returns schemas of that database.\n * Useful for SQLServer and Postgres only.\n */\n getSchemas(database?: string): Promise<string[]>;\n\n /**\n * Loads a table by a given name from the database.\n */\n getTable(tablePath: string): Promise<Table|undefined>;\n\n /**\n * Loads all tables from the database and returns them.\n */\n getTables(tablePaths?: string[]): Promise<Table[]>;\n\n /**\n * Loads a view by a given name from the database.\n */\n getView(viewPath: string): Promise<View|undefined>;\n\n /**\n * Loads all views from the database and returns them.\n */\n getViews(viewPaths?: string[]): Promise<View[]>;\n\n /**\n * Returns replication mode (ex: `master` or `slave`).\n */\n getReplicationMode(): ReplicationMode;\n\n /**\n * Checks if a database with the given name exist.\n */\n hasDatabase(database: string): Promise<boolean>;\n\n /**\n * Loads currently using database\n */\n getCurrentDatabase(): Promise<string|undefined>;\n\n /**\n * Checks if a schema with the given name exist.\n */\n hasSchema(schema: string): Promise<boolean>;\n\n /**\n * Loads currently using database schema\n */\n getCurrentSchema(): Promise<string|undefined>;\n\n /**\n * Checks if a table with the given name exist.\n */\n hasTable(table: Table|string): Promise<boolean>;\n\n /**\n * Checks if a column exist in the table.\n */\n hasColumn(table: Table|string, columnName: string): Promise<boolean>;\n\n /**\n * Creates a new database.\n */\n createDatabase(database: string, ifNotExist?: boolean): Promise<void>;\n\n /**\n * Drops database.\n */\n dropDatabase(database: string, ifExist?: boolean): Promise<void>;\n\n /**\n * Creates a new table schema.\n */\n createSchema(schemaPath: string, ifNotExist?: boolean): Promise<void>;\n\n /**\n * Drops table schema.\n * For SqlServer can accept schema path (e.g. 'dbName.schemaName') as parameter.\n * If schema path passed, it will drop schema in specified database.\n */\n dropSchema(schemaPath: string, ifExist?: boolean, isCascade?: boolean): Promise<void>;\n\n /**\n * Creates a new table.\n */\n createTable(table: Table, ifNotExist?: boolean, createForeignKeys?: boolean, createIndices?: boolean): Promise<void>;\n\n /**\n * Drops a table.\n */\n dropTable(table: Table|string, ifExist?: boolean, dropForeignKeys?: boolean, dropIndices?: boolean): Promise<void>;\n\n /**\n * Creates a new view.\n */\n createView(view: View, oldView?: View): Promise<void>;\n\n /**\n * Drops a view.\n */\n dropView(view: View|string): Promise<void>;\n\n /**\n * Renames a table.\n */\n renameTable(oldTableOrName: Table|string, newTableName: string): Promise<void>;\n\n /**\n * Adds a new column.\n */\n addColumn(table: Table|string, column: TableColumn): Promise<void>;\n\n /**\n * Adds new columns.\n */\n addColumns(table: Table|string, columns: TableColumn[]): Promise<void>;\n\n /**\n * Renames a column.\n */\n renameColumn(table: Table|string, oldColumnOrName: TableColumn|string, newColumnOrName: TableColumn|string): Promise<void>;\n\n /**\n * Changes a column in the table.\n */\n changeColumn(table: Table|string, oldColumn: TableColumn|string, newColumn: TableColumn): Promise<void>;\n\n /**\n * Changes columns in the table.\n */\n changeColumns(table: Table|string, changedColumns: { oldColumn: TableColumn, newColumn: TableColumn }[]): Promise<void>;\n\n /**\n * Drops a column in the table.\n */\n dropColumn(table: Table|string, column: TableColumn|string): Promise<void>;\n\n /**\n * Drops columns in the table.\n */\n dropColumns(table: Table|string, columns: TableColumn[]|string[]): Promise<void>;\n\n /**\n * Creates a new primary key.\n */\n createPrimaryKey(table: Table|string, columnNames: string[]): Promise<void>;\n\n /**\n * Updates composite primary keys.\n */\n updatePrimaryKeys(table: Table|string, columns: TableColumn[]): Promise<void>;\n\n /**\n * Drops a primary key.\n */\n dropPrimaryKey(table: Table|string): Promise<void>;\n\n /**\n * Creates a new unique constraint.\n */\n createUniqueConstraint(table: Table|string, uniqueConstraint: TableUnique): Promise<void>;\n\n /**\n * Creates new unique constraints.\n */\n createUniqueConstraints(table: Table|string, uniqueConstraints: TableUnique[]): Promise<void>;\n\n /**\n * Drops an unique constraint.\n */\n dropUniqueConstraint(table: Table|string, uniqueOrName: TableUnique|string): Promise<void>;\n\n /**\n * Drops unique constraints.\n */\n dropUniqueConstraints(table: Table|string, uniqueConstraints: TableUnique[]): Promise<void>;\n\n /**\n * Creates a new check constraint.\n */\n createCheckConstraint(table: Table|string, checkConstraint: TableCheck): Promise<void>;\n\n /**\n * Creates new check constraints.\n */\n createCheckConstraints(table: Table|string, checkConstraints: TableCheck[]): Promise<void>;\n\n /**\n * Drops a check constraint.\n */\n dropCheckConstraint(table: Table|string, checkOrName: TableCheck|string): Promise<void>;\n\n /**\n * Drops check constraints.\n */\n dropCheckConstraints(table: Table|string, checkConstraints: TableCheck[]): Promise<void>;\n\n /**\n * Creates a new exclusion constraint.\n */\n createExclusionConstraint(table: Table|string, exclusionConstraint: TableExclusion): Promise<void>;\n\n /**\n * Creates new exclusion constraints.\n */\n createExclusionConstraints(table: Table|string, exclusionConstraints: TableExclusion[]): Promise<void>;\n\n /**\n * Drops a exclusion constraint.\n */\n dropExclusionConstraint(table: Table|string, exclusionOrName: TableExclusion|string): Promise<void>;\n\n /**\n * Drops exclusion constraints.\n */\n dropExclusionConstraints(table: Table|string, exclusionConstraints: TableExclusion[]): Promise<void>;\n\n /**\n * Creates a new foreign key.\n */\n createForeignKey(table: Table|string, foreignKey: TableForeignKey): Promise<void>;\n\n /**\n * Creates new foreign keys.\n */\n createForeignKeys(table: Table|string, foreignKeys: TableForeignKey[]): Promise<void>;\n\n /**\n * Drops a foreign key.\n */\n dropForeignKey(table: Table|string, foreignKeyOrName: TableForeignKey|string): Promise<void>;\n\n /**\n * Drops foreign keys.\n */\n dropForeignKeys(table: Table|string, foreignKeys: TableForeignKey[]): Promise<void>;\n\n /**\n * Creates a new index.\n */\n createIndex(table: Table|string, index: TableIndex): Promise<void>;\n\n /**\n * Creates new indices.\n */\n createIndices(table: Table|string, indices: TableIndex[]): Promise<void>;\n\n /**\n * Drops an index.\n */\n dropIndex(table: Table|string, index: TableIndex|string): Promise<void>;\n\n /**\n * Drops indices.\n */\n dropIndices(table: Table|string, indices: TableIndex[]): Promise<void>;\n\n /**\n * Clears all table contents.\n * Note: this operation uses SQL's TRUNCATE query which cannot be reverted in transactions.\n */\n clearTable(tableName: string): Promise<void>;\n\n /**\n * Enables special query runner mode in which sql queries won't be executed,\n * instead they will be memorized into a special variable inside query runner.\n * You can get memorized sql using getMemorySql() method.\n */\n enableSqlMemory(): void;\n\n /**\n * Disables special query runner mode in which sql queries won't be executed\n * started by calling enableSqlMemory() method.\n *\n * Previously memorized sql will be flushed.\n */\n disableSqlMemory(): void;\n\n /**\n * Flushes all memorized sqls.\n */\n clearSqlMemory(): void;\n\n /**\n * Gets sql stored in the memory. Parameters in the sql are already replaced.\n */\n getMemorySql(): SqlInMemory;\n\n /**\n * Executes up sql queries.\n */\n executeMemoryUpSql(): Promise<void>;\n\n /**\n * Executes down sql queries.\n */\n executeMemoryDownSql(): Promise<void>;\n\n}\n"],"sourceRoot":".."}
|
|
@@ -154,11 +154,14 @@ var DbQueryResultCache = /** @class */ (function () {
|
|
|
154
154
|
*/
|
|
155
155
|
DbQueryResultCache.prototype.storeInCache = function (options, savedCache, queryRunner) {
|
|
156
156
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
157
|
-
var insertedValues, qb, qb;
|
|
157
|
+
var shouldCreateQueryRunner, insertedValues, qb, qb;
|
|
158
158
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
159
159
|
switch (_a.label) {
|
|
160
160
|
case 0:
|
|
161
|
-
|
|
161
|
+
shouldCreateQueryRunner = queryRunner === undefined || (queryRunner === null || queryRunner === void 0 ? void 0 : queryRunner.getReplicationMode()) === "slave";
|
|
162
|
+
if (queryRunner === undefined || shouldCreateQueryRunner) {
|
|
163
|
+
queryRunner = this.connection.createQueryRunner("master");
|
|
164
|
+
}
|
|
162
165
|
insertedValues = options;
|
|
163
166
|
if (this.connection.driver instanceof SqlServerDriver_1.SqlServerDriver) { // todo: bad abstraction, re-implement this part, probably better if we create an entity metadata for cache table
|
|
164
167
|
insertedValues = {
|
|
@@ -205,7 +208,13 @@ var DbQueryResultCache = /** @class */ (function () {
|
|
|
205
208
|
case 5:
|
|
206
209
|
_a.sent();
|
|
207
210
|
_a.label = 6;
|
|
208
|
-
case 6:
|
|
211
|
+
case 6:
|
|
212
|
+
if (!shouldCreateQueryRunner) return [3 /*break*/, 8];
|
|
213
|
+
return [4 /*yield*/, queryRunner.release()];
|
|
214
|
+
case 7:
|
|
215
|
+
_a.sent();
|
|
216
|
+
_a.label = 8;
|
|
217
|
+
case 8: return [2 /*return*/];
|
|
209
218
|
}
|
|
210
219
|
});
|
|
211
220
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cache/DbQueryResultCache.ts"],"names":[],"mappings":";;;;AAEA,8DAA2D;AAC3D,qEAAkE;AAClE,uEAAoE;AAEpE,uDAAoD;AAIpD;;GAEG;AACH;IAYI,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,4BAAsB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QAEhC,IAAA,MAAM,GAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAe,OAA5C,CAA6C;QAC3D,IAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjD,IAAM,YAAY,GAAG,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5G,IAAM,cAAc,GAAG,YAAY,CAAC,SAAS,IAAI,oBAAoB,CAAC;QAEtE,IAAI,CAAC,wBAAwB,GAAG,QAAQ,CAAC;QACzC,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC;QACrC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACzG,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACG,oCAAO,GAAb;;;;;;KACC;IAED;;OAEG;IACG,uCAAU,GAAhB;;;;;;KACC;IAED;;OAEG;IACG,wCAAW,GAAjB,UAAkB,WAAyB;;;;;;wBACvC,WA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AAyB,WAAkC;QACvD,IAAI,WAAW;YACX,OAAO,WAAW,CAAC;QAEvB,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;IAC/C,CAAC;IAEL,yBAAC;AAAD,CApOA,AAoOC,IAAA;AApOY,gDAAkB","file":"DbQueryResultCache.js","sourcesContent":["import {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {Connection} from \"../connection/Connection\";\nimport {OracleDriver} from \"../driver/oracle/OracleDriver\";\nimport {MssqlParameter} from \"../driver/sqlserver/MssqlParameter\";\nimport {SqlServerDriver} from \"../driver/sqlserver/SqlServerDriver\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {Table} from \"../schema-builder/table/Table\";\nimport {QueryResultCache} from \"./QueryResultCache\";\nimport {QueryResultCacheOptions} from \"./QueryResultCacheOptions\";\n\n/**\n * Caches query result into current database, into separate table called \"query-result-cache\".\n */\nexport class DbQueryResultCache implements QueryResultCache {\n\n // -------------------------------------------------------------------------\n // Private properties\n // -------------------------------------------------------------------------\n\n private queryResultCacheTable: string;\n\n private queryResultCacheDatabase?: string;\n\n private queryResultCacheSchema?: string;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: Connection) {\n\n const { schema } = (this.connection.driver.options as any);\n const database = this.connection.driver.database;\n const cacheOptions = typeof this.connection.options.cache === \"object\" ? this.connection.options.cache : {};\n const cacheTableName = cacheOptions.tableName || \"query-result-cache\";\n\n this.queryResultCacheDatabase = database;\n this.queryResultCacheSchema = schema;\n this.queryResultCacheTable = this.connection.driver.buildTableName(cacheTableName, schema, database);\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a connection with given cache provider.\n */\n async connect(): Promise<void> {\n }\n\n /**\n * Disconnects with given cache provider.\n */\n async disconnect(): Promise<void> {\n }\n\n /**\n * Creates table for storing cache if it does not exist yet.\n */\n async synchronize(queryRunner?: QueryRunner): Promise<void> {\n queryRunner = this.getQueryRunner(queryRunner);\n const driver = this.connection.driver;\n const tableExist = await queryRunner.hasTable(this.queryResultCacheTable); // todo: table name should be configurable\n if (tableExist)\n return;\n\n await queryRunner.createTable(new Table(\n {\n database: this.queryResultCacheDatabase,\n schema: this.queryResultCacheSchema,\n name: this.queryResultCacheTable,\n columns: [\n {\n name: \"id\",\n isPrimary: true,\n isNullable: false,\n type: driver.normalizeType({type: driver.mappedDataTypes.cacheId}),\n generationStrategy: \"increment\",\n isGenerated: true\n },\n {\n name: \"identifier\",\n type: driver.normalizeType({type: driver.mappedDataTypes.cacheIdentifier}),\n isNullable: true\n },\n {\n name: \"time\",\n type: driver.normalizeType({type: driver.mappedDataTypes.cacheTime}),\n isPrimary: false,\n isNullable: false\n },\n {\n name: \"duration\",\n type: driver.normalizeType({type: driver.mappedDataTypes.cacheDuration}),\n isPrimary: false,\n isNullable: false\n },\n {\n name: \"query\",\n type: driver.normalizeType({type: driver.mappedDataTypes.cacheQuery}),\n isPrimary: false,\n isNullable: false\n },\n {\n name: \"result\",\n type: driver.normalizeType({type: driver.mappedDataTypes.cacheResult}),\n isNullable: false\n },\n ]\n },\n ));\n }\n\n /**\n * Caches given query result.\n * Returns cache result if found.\n * Returns undefined if result is not cached.\n */\n getFromCache(options: QueryResultCacheOptions, queryRunner?: QueryRunner): Promise<QueryResultCacheOptions|undefined> {\n queryRunner = this.getQueryRunner(queryRunner);\n const qb = this.connection\n .createQueryBuilder(queryRunner)\n .select()\n .from(this.queryResultCacheTable, \"cache\");\n\n if (options.identifier) {\n return qb\n .where(`${qb.escape(\"cache\")}.${qb.escape(\"identifier\")} = :identifier`)\n .setParameters({ identifier: this.connection.driver instanceof SqlServerDriver ? new MssqlParameter(options.identifier, \"nvarchar\") : options.identifier })\n .getRawOne();\n\n } else if (options.query) {\n if (this.connection.driver instanceof OracleDriver) {\n return qb\n .where(`dbms_lob.compare(${qb.escape(\"cache\")}.${qb.escape(\"query\")}, :query) = 0`, { query: options.query })\n .getRawOne();\n }\n\n return qb\n .where(`${qb.escape(\"cache\")}.${qb.escape(\"query\")} = :query`)\n .setParameters({ query: this.connection.driver instanceof SqlServerDriver ? new MssqlParameter(options.query, \"nvarchar\") : options.query })\n .getRawOne();\n }\n\n return Promise.resolve(undefined);\n }\n\n /**\n * Checks if cache is expired or not.\n */\n isExpired(savedCache: QueryResultCacheOptions): boolean {\n const duration = typeof savedCache.duration === \"string\" ? parseInt(savedCache.duration) : savedCache.duration;\n return ((typeof savedCache.time === \"string\" ? parseInt(savedCache.time as any) : savedCache.time)! + duration) < new Date().getTime();\n }\n\n /**\n * Stores given query result in the cache.\n */\n async storeInCache(options: QueryResultCacheOptions, savedCache: QueryResultCacheOptions|undefined, queryRunner?: QueryRunner): Promise<void> {\n queryRunner = this.getQueryRunner(queryRunner);\n\n let insertedValues: ObjectLiteral = options;\n if (this.connection.driver instanceof SqlServerDriver) { // todo: bad abstraction, re-implement this part, probably better if we create an entity metadata for cache table\n insertedValues = {\n identifier: new MssqlParameter(options.identifier, \"nvarchar\"),\n time: new MssqlParameter(options.time, \"bigint\"),\n duration: new MssqlParameter(options.duration, \"int\"),\n query: new MssqlParameter(options.query, \"nvarchar\"),\n result: new MssqlParameter(options.result, \"nvarchar\"),\n };\n }\n\n if (savedCache && savedCache.identifier) { // if exist then update\n const qb = queryRunner.manager\n .createQueryBuilder()\n .update(this.queryResultCacheTable)\n .set(insertedValues);\n\n qb.where(`${qb.escape(\"identifier\")} = :condition`, { condition: insertedValues.identifier });\n await qb.execute();\n\n } else if (savedCache && savedCache.query) { // if exist then update\n const qb = queryRunner.manager\n .createQueryBuilder()\n .update(this.queryResultCacheTable)\n .set(insertedValues);\n\n if (this.connection.driver instanceof OracleDriver) {\n qb.where(`dbms_lob.compare(\"query\", :condition) = 0`, { condition: insertedValues.query });\n\n } else {\n qb.where(`${qb.escape(\"query\")} = :condition`, { condition: insertedValues.query });\n }\n\n await qb.execute();\n\n } else { // otherwise insert\n await queryRunner.manager\n .createQueryBuilder()\n .insert()\n .into(this.queryResultCacheTable)\n .values(insertedValues)\n .execute();\n }\n }\n\n /**\n * Clears everything stored in the cache.\n */\n async clear(queryRunner: QueryRunner): Promise<void> {\n return this.getQueryRunner(queryRunner).clearTable(this.queryResultCacheTable);\n }\n\n /**\n * Removes all cached results by given identifiers from cache.\n */\n async remove(identifiers: string[], queryRunner?: QueryRunner): Promise<void> {\n await Promise.all(identifiers.map(identifier => {\n const qb = this.getQueryRunner(queryRunner).manager.createQueryBuilder();\n return qb.delete()\n .from(this.queryResultCacheTable)\n .where(`${qb.escape(\"identifier\")} = :identifier`, {identifier})\n .execute();\n }));\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets a query runner to work with.\n */\n protected getQueryRunner(queryRunner: QueryRunner|undefined): QueryRunner {\n if (queryRunner)\n return queryRunner;\n\n return this.connection.createQueryRunner();\n }\n\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/cache/DbQueryResultCache.ts"],"names":[],"mappings":";;;;AAEA,8DAA2D;AAC3D,qEAAkE;AAClE,uEAAoE;AAEpE,uDAAoD;AAIpD;;GAEG;AACH;IAYI,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,4BAAsB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QAEhC,IAAA,MAAM,GAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAe,OAA5C,CAA6C;QAC3D,IAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjD,IAAM,YAAY,GAAG,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5G,IAAM,cAAc,GAAG,YAAY,CAAC,SAAS,IAAI,oBAA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ACG,kCAAK,GAAX,UAAY,WAAwB;;;gBAChC,sBAAO,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,EAAC;;;KAClF;IAED;;OAEG;IACG,mCAAM,GAAZ,UAAa,WAAqB,EAAE,WAAyB;;;;;4BACzD,qBAAM,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,UAAA,UAAU;4BACxC,IAAM,EAAE,GAAG,KAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;4BACzE,OAAO,EAAE,CAAC,MAAM,EAAE;iCACb,IAAI,CAAC,KAAI,CAAC,qBAAqB,CAAC;iCAChC,KAAK,CAAI,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,mBAAgB,EAAE,EAAC,UAAU,YAAA,EAAC,CAAC;iCAC/D,OAAO,EAAE,CAAC;wBACnB,CAAC,CAAC,CAAC,EAAA;;wBANH,SAMG,CAAC;;;;;KACP;IAED,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;OAEG;IACO,2CAAc,GAAxB,UAAyB,WAAkC;QACvD,IAAI,WAAW;YACX,OAAO,WAAW,CAAC;QAEvB,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;IAC/C,CAAC;IAEL,yBAAC;AAAD,CA5OA,AA4OC,IAAA;AA5OY,gDAAkB","file":"DbQueryResultCache.js","sourcesContent":["import {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {Connection} from \"../connection/Connection\";\nimport {OracleDriver} from \"../driver/oracle/OracleDriver\";\nimport {MssqlParameter} from \"../driver/sqlserver/MssqlParameter\";\nimport {SqlServerDriver} from \"../driver/sqlserver/SqlServerDriver\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {Table} from \"../schema-builder/table/Table\";\nimport {QueryResultCache} from \"./QueryResultCache\";\nimport {QueryResultCacheOptions} from \"./QueryResultCacheOptions\";\n\n/**\n * Caches query result into current database, into separate table called \"query-result-cache\".\n */\nexport class DbQueryResultCache implements QueryResultCache {\n\n // -------------------------------------------------------------------------\n // Private properties\n // -------------------------------------------------------------------------\n\n private queryResultCacheTable: string;\n\n private queryResultCacheDatabase?: string;\n\n private queryResultCacheSchema?: string;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: Connection) {\n\n const { schema } = (this.connection.driver.options as any);\n const database = this.connection.driver.database;\n const cacheOptions = typeof this.connection.options.cache === \"object\" ? this.connection.options.cache : {};\n const cacheTableName = cacheOptions.tableName || \"query-result-cache\";\n\n this.queryResultCacheDatabase = database;\n this.queryResultCacheSchema = schema;\n this.queryResultCacheTable = this.connection.driver.buildTableName(cacheTableName, schema, database);\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a connection with given cache provider.\n */\n async connect(): Promise<void> {\n }\n\n /**\n * Disconnects with given cache provider.\n */\n async disconnect(): Promise<void> {\n }\n\n /**\n * Creates table for storing cache if it does not exist yet.\n */\n async synchronize(queryRunner?: QueryRunner): Promise<void> {\n queryRunner = this.getQueryRunner(queryRunner);\n const driver = this.connection.driver;\n const tableExist = await queryRunner.hasTable(this.queryResultCacheTable); // todo: table name should be configurable\n if (tableExist)\n return;\n\n await queryRunner.createTable(new Table(\n {\n database: this.queryResultCacheDatabase,\n schema: this.queryResultCacheSchema,\n name: this.queryResultCacheTable,\n columns: [\n {\n name: \"id\",\n isPrimary: true,\n isNullable: false,\n type: driver.normalizeType({type: driver.mappedDataTypes.cacheId}),\n generationStrategy: \"increment\",\n isGenerated: true\n },\n {\n name: \"identifier\",\n type: driver.normalizeType({type: driver.mappedDataTypes.cacheIdentifier}),\n isNullable: true\n },\n {\n name: \"time\",\n type: driver.normalizeType({type: driver.mappedDataTypes.cacheTime}),\n isPrimary: false,\n isNullable: false\n },\n {\n name: \"duration\",\n type: driver.normalizeType({type: driver.mappedDataTypes.cacheDuration}),\n isPrimary: false,\n isNullable: false\n },\n {\n name: \"query\",\n type: driver.normalizeType({type: driver.mappedDataTypes.cacheQuery}),\n isPrimary: false,\n isNullable: false\n },\n {\n name: \"result\",\n type: driver.normalizeType({type: driver.mappedDataTypes.cacheResult}),\n isNullable: false\n },\n ]\n },\n ));\n }\n\n /**\n * Caches given query result.\n * Returns cache result if found.\n * Returns undefined if result is not cached.\n */\n getFromCache(options: QueryResultCacheOptions, queryRunner?: QueryRunner): Promise<QueryResultCacheOptions|undefined> {\n queryRunner = this.getQueryRunner(queryRunner);\n const qb = this.connection\n .createQueryBuilder(queryRunner)\n .select()\n .from(this.queryResultCacheTable, \"cache\");\n\n if (options.identifier) {\n return qb\n .where(`${qb.escape(\"cache\")}.${qb.escape(\"identifier\")} = :identifier`)\n .setParameters({ identifier: this.connection.driver instanceof SqlServerDriver ? new MssqlParameter(options.identifier, \"nvarchar\") : options.identifier })\n .getRawOne();\n\n } else if (options.query) {\n if (this.connection.driver instanceof OracleDriver) {\n return qb\n .where(`dbms_lob.compare(${qb.escape(\"cache\")}.${qb.escape(\"query\")}, :query) = 0`, { query: options.query })\n .getRawOne();\n }\n\n return qb\n .where(`${qb.escape(\"cache\")}.${qb.escape(\"query\")} = :query`)\n .setParameters({ query: this.connection.driver instanceof SqlServerDriver ? new MssqlParameter(options.query, \"nvarchar\") : options.query })\n .getRawOne();\n }\n\n return Promise.resolve(undefined);\n }\n\n /**\n * Checks if cache is expired or not.\n */\n isExpired(savedCache: QueryResultCacheOptions): boolean {\n const duration = typeof savedCache.duration === \"string\" ? parseInt(savedCache.duration) : savedCache.duration;\n return ((typeof savedCache.time === \"string\" ? parseInt(savedCache.time as any) : savedCache.time)! + duration) < new Date().getTime();\n }\n\n /**\n * Stores given query result in the cache.\n */\n async storeInCache(options: QueryResultCacheOptions, savedCache: QueryResultCacheOptions|undefined, queryRunner?: QueryRunner): Promise<void> {\n const shouldCreateQueryRunner = queryRunner === undefined || queryRunner?.getReplicationMode() === \"slave\";\n\n if (queryRunner === undefined || shouldCreateQueryRunner) {\n queryRunner = this.connection.createQueryRunner(\"master\");\n }\n\n let insertedValues: ObjectLiteral = options;\n if (this.connection.driver instanceof SqlServerDriver) { // todo: bad abstraction, re-implement this part, probably better if we create an entity metadata for cache table\n insertedValues = {\n identifier: new MssqlParameter(options.identifier, \"nvarchar\"),\n time: new MssqlParameter(options.time, \"bigint\"),\n duration: new MssqlParameter(options.duration, \"int\"),\n query: new MssqlParameter(options.query, \"nvarchar\"),\n result: new MssqlParameter(options.result, \"nvarchar\"),\n };\n }\n\n if (savedCache && savedCache.identifier) { // if exist then update\n const qb = queryRunner.manager\n .createQueryBuilder()\n .update(this.queryResultCacheTable)\n .set(insertedValues);\n\n qb.where(`${qb.escape(\"identifier\")} = :condition`, { condition: insertedValues.identifier });\n await qb.execute();\n\n } else if (savedCache && savedCache.query) { // if exist then update\n const qb = queryRunner.manager\n .createQueryBuilder()\n .update(this.queryResultCacheTable)\n .set(insertedValues);\n\n if (this.connection.driver instanceof OracleDriver) {\n qb.where(`dbms_lob.compare(\"query\", :condition) = 0`, { condition: insertedValues.query });\n\n } else {\n qb.where(`${qb.escape(\"query\")} = :condition`, { condition: insertedValues.query });\n }\n\n await qb.execute();\n\n } else { // otherwise insert\n await queryRunner.manager\n .createQueryBuilder()\n .insert()\n .into(this.queryResultCacheTable)\n .values(insertedValues)\n .execute();\n }\n\n if (shouldCreateQueryRunner) {\n await queryRunner.release();\n }\n }\n\n /**\n * Clears everything stored in the cache.\n */\n async clear(queryRunner: QueryRunner): Promise<void> {\n return this.getQueryRunner(queryRunner).clearTable(this.queryResultCacheTable);\n }\n\n /**\n * Removes all cached results by given identifiers from cache.\n */\n async remove(identifiers: string[], queryRunner?: QueryRunner): Promise<void> {\n await Promise.all(identifiers.map(identifier => {\n const qb = this.getQueryRunner(queryRunner).manager.createQueryBuilder();\n return qb.delete()\n .from(this.queryResultCacheTable)\n .where(`${qb.escape(\"identifier\")} = :identifier`, {identifier})\n .execute();\n }));\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets a query runner to work with.\n */\n protected getQueryRunner(queryRunner: QueryRunner|undefined): QueryRunner {\n if (queryRunner)\n return queryRunner;\n\n return this.connection.createQueryRunner();\n }\n\n}\n"],"sourceRoot":".."}
|
|
@@ -1771,23 +1771,23 @@ var AuroraDataApiQueryRunner = /** @class */ (function (_super) {
|
|
|
1771
1771
|
table.columns = dbColumns
|
|
1772
1772
|
.filter(function (dbColumn) { return dbColumn["TABLE_NAME"] === dbTable["TABLE_NAME"] && dbColumn["TABLE_SCHEMA"] === dbTable["TABLE_SCHEMA"]; })
|
|
1773
1773
|
.map(function (dbColumn) {
|
|
1774
|
-
var
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
if (dbIndex["COLUMN_NAME"] !== dbColumn["COLUMN_NAME"]) {
|
|
1780
|
-
return false;
|
|
1781
|
-
}
|
|
1782
|
-
var nonUnique = parseInt(dbIndex["NON_UNIQUE"], 10);
|
|
1783
|
-
return nonUnique === 0;
|
|
1774
|
+
var columnUniqueIndices = dbIndices.filter(function (dbIndex) {
|
|
1775
|
+
return dbIndex["TABLE_NAME"] === dbTable["TABLE_NAME"]
|
|
1776
|
+
&& dbIndex["TABLE_SCHEMA"] === dbTable["TABLE_SCHEMA"]
|
|
1777
|
+
&& dbIndex["COLUMN_NAME"] === dbColumn["COLUMN_NAME"]
|
|
1778
|
+
&& parseInt(dbIndex["NON_UNIQUE"], 10) === 0;
|
|
1784
1779
|
});
|
|
1785
1780
|
var tableMetadata = _this.connection.entityMetadatas.find(function (metadata) { return _this.getTablePath(table) === _this.getTablePath(metadata); });
|
|
1786
|
-
var hasIgnoredIndex =
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1781
|
+
var hasIgnoredIndex = columnUniqueIndices.length > 0
|
|
1782
|
+
&& tableMetadata
|
|
1783
|
+
&& tableMetadata.indices.some(function (index) {
|
|
1784
|
+
return columnUniqueIndices.some(function (uniqueIndex) {
|
|
1785
|
+
return index.name === uniqueIndex["INDEX_NAME"] && index.synchronize === false;
|
|
1786
|
+
});
|
|
1787
|
+
});
|
|
1788
|
+
var isConstraintComposite = columnUniqueIndices.every(function (uniqueIndex) {
|
|
1789
|
+
return dbIndices.some(function (dbIndex) { return dbIndex["INDEX_NAME"] === uniqueIndex["INDEX_NAME"] && dbIndex["COLUMN_NAME"] !== dbColumn["COLUMN_NAME"]; });
|
|
1790
|
+
});
|
|
1791
1791
|
var tableColumn = new TableColumn_1.TableColumn();
|
|
1792
1792
|
tableColumn.name = dbColumn["COLUMN_NAME"];
|
|
1793
1793
|
tableColumn.type = dbColumn["DATA_TYPE"].toLowerCase();
|
|
@@ -1809,7 +1809,7 @@ var AuroraDataApiQueryRunner = /** @class */ (function (_super) {
|
|
|
1809
1809
|
tableColumn.asExpression = dbColumn["GENERATION_EXPRESSION"];
|
|
1810
1810
|
tableColumn.generatedType = dbColumn["EXTRA"].indexOf("VIRTUAL") !== -1 ? "VIRTUAL" : "STORED";
|
|
1811
1811
|
}
|
|
1812
|
-
tableColumn.isUnique =
|
|
1812
|
+
tableColumn.isUnique = columnUniqueIndices.length > 0 && !hasIgnoredIndex && !isConstraintComposite;
|
|
1813
1813
|
tableColumn.isNullable = dbColumn["IS_NULLABLE"] === "YES";
|
|
1814
1814
|
tableColumn.isPrimary = dbPrimaryKeys.some(function (dbPrimaryKey) {
|
|
1815
1815
|
return (dbPrimaryKey["TABLE_NAME"] === dbColumn["TABLE_NAME"] &&
|