typeorm 0.3.26-dev.5904ac3 → 0.3.26-dev.66ee307
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 +0 -3
- package/browser/driver/sap/SapConnectionOptions.d.ts +33 -8
- package/browser/driver/sap/SapConnectionOptions.js.map +1 -1
- package/browser/driver/sap/SapDriver.d.ts +20 -21
- package/browser/driver/sap/SapDriver.js +86 -77
- package/browser/driver/sap/SapDriver.js.map +1 -1
- package/browser/driver/sap/SapQueryRunner.js +36 -25
- package/browser/driver/sap/SapQueryRunner.js.map +1 -1
- package/browser/platform/PlatformTools.js +0 -2
- package/browser/platform/PlatformTools.js.map +1 -1
- package/browser/query-builder/QueryExpressionMap.js +1 -0
- package/browser/query-builder/QueryExpressionMap.js.map +1 -1
- package/driver/sap/SapConnectionOptions.d.ts +33 -8
- package/driver/sap/SapConnectionOptions.js.map +1 -1
- package/driver/sap/SapDriver.d.ts +20 -21
- package/driver/sap/SapDriver.js +86 -77
- package/driver/sap/SapDriver.js.map +1 -1
- package/driver/sap/SapQueryRunner.js +41 -30
- package/driver/sap/SapQueryRunner.js.map +1 -1
- package/package.json +1 -1
- package/platform/PlatformTools.js +0 -2
- package/platform/PlatformTools.js.map +1 -1
- package/query-builder/QueryExpressionMap.js +1 -0
- package/query-builder/QueryExpressionMap.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/platform/PlatformTools.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,OAAO,CAAA;AACxB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAIzD,OAAO,EAAE,YAAY,EAAE,MAAM,Q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CAAC,IAAI,CAAC,IAAS;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAU;QACnB,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAC1B,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,OAAe;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC/B,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,MAAc,EAAE,GAAS;QACtC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;QACrC,IAAI,GAAG;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC;;AAvQD;;GAEG;AACI,kBAAI,GAAuB,MAAM,CAAA","file":"PlatformTools.js","sourcesContent":["import ansi from \"ansis\"\nimport dotenv from \"dotenv\"\nimport fs from \"fs\"\nimport path from \"path\"\nimport { highlight } from \"sql-highlight\"\nimport { format as sqlFormat } from \"@sqltools/formatter\"\nimport { type Config as SqlFormatterConfig } from \"@sqltools/formatter/lib/core/types\"\nimport { type DatabaseType } from \"../driver/types/DatabaseType\"\n\nexport { EventEmitter } from \"events\"\nexport { ReadStream } from \"fs\"\nexport { Readable, Writable } from \"stream\"\n\n/**\n * Platform-specific tools.\n */\nexport class PlatformTools {\n /**\n * Type of the currently running platform.\n */\n static type: \"browser\" | \"node\" = \"node\"\n\n /**\n * Gets global variable where global stuff can be stored.\n */\n static getGlobalVariable(): any {\n return global\n }\n\n /**\n * Loads (\"require\"-s) given file or package.\n * This operation only supports on node platform\n */\n static load(name: string): any {\n // if name is not absolute or relative, then try to load package from the node_modules of the directory we are currently in\n // this is useful when we are using typeorm package globally installed and it accesses drivers\n // that are not installed globally\n\n try {\n // switch case to explicit require statements for webpack compatibility.\n switch (name) {\n /**\n * spanner\n */\n case \"spanner\":\n return require(\"@google-cloud/spanner\")\n\n /**\n * mongodb\n */\n case \"mongodb\":\n return require(\"mongodb\")\n\n /**\n * hana\n */\n case \"@sap/hana-client\":\n return require(\"@sap/hana-client\")\n\n case \"@sap/hana-client/extension/Stream\":\n return require(\"@sap/hana-client/extension/Stream\")\n\n case \"hdb-pool\":\n return require(\"hdb-pool\")\n\n /**\n * mysql\n */\n case \"mysql\":\n return require(\"mysql\")\n\n case \"mysql2\":\n return require(\"mysql2\")\n\n /**\n * oracle\n */\n case \"oracledb\":\n return require(\"oracledb\")\n\n /**\n * postgres\n */\n case \"pg\":\n return require(\"pg\")\n\n case \"pg-native\":\n return require(\"pg-native\")\n\n case \"pg-query-stream\":\n return require(\"pg-query-stream\")\n\n case \"typeorm-aurora-data-api-driver\":\n return require(\"typeorm-aurora-data-api-driver\")\n\n /**\n * redis\n */\n case \"redis\":\n return require(\"redis\")\n\n case \"ioredis\":\n return require(\"ioredis\")\n\n /**\n * better-sqlite3\n */\n case \"better-sqlite3\":\n return require(\"better-sqlite3\")\n\n /**\n * sqlite\n */\n case \"sqlite3\":\n return require(\"sqlite3\")\n\n /**\n * sql.js\n */\n case \"sql.js\":\n return require(\"sql.js\")\n\n /**\n * sqlserver\n */\n case \"mssql\":\n return require(\"mssql\")\n\n /**\n * react-native-sqlite\n */\n case \"react-native-sqlite-storage\":\n return require(\"react-native-sqlite-storage\")\n }\n } catch (err) {\n return require(path.resolve(\n process.cwd() + \"/node_modules/\" + name,\n ))\n }\n\n // If nothing above matched and we get here, the package was not listed within PlatformTools\n // and is an Invalid Package. To make it explicit that this is NOT the intended use case for\n // PlatformTools.load - it's not just a way to replace `require` all willy-nilly - let's throw\n // an error.\n throw new TypeError(`Invalid Package for PlatformTools.load: ${name}`)\n }\n\n /**\n * Normalizes given path. Does \"path.normalize\" and replaces backslashes with forward slashes on Windows.\n */\n static pathNormalize(pathStr: string): string {\n let normalizedPath = path.normalize(pathStr)\n if (process.platform === \"win32\")\n normalizedPath = normalizedPath.replace(/\\\\/g, \"/\")\n return normalizedPath\n }\n\n /**\n * Gets file extension. Does \"path.extname\".\n */\n static pathExtname(pathStr: string): string {\n return path.extname(pathStr)\n }\n\n /**\n * Resolved given path. Does \"path.resolve\".\n */\n static pathResolve(pathStr: string): string {\n return path.resolve(pathStr)\n }\n\n /**\n * Synchronously checks if file exist. Does \"fs.existsSync\".\n */\n static fileExist(pathStr: string): boolean {\n return fs.existsSync(pathStr)\n }\n\n static readFileSync(filename: string): Buffer {\n return fs.readFileSync(filename)\n }\n\n static appendFileSync(filename: string, data: any): void {\n fs.appendFileSync(filename, data)\n }\n\n static async writeFile(path: string, data: any): Promise<void> {\n return fs.promises.writeFile(path, data)\n }\n\n /**\n * Loads a dotenv file into the environment variables.\n *\n * @param path The file to load as a dotenv configuration\n */\n static dotenv(pathStr: string): void {\n dotenv.config({ path: pathStr })\n }\n\n /**\n * Gets environment variable.\n */\n static getEnvVariable(name: string): any {\n return process.env[name]\n }\n\n /**\n * Highlights sql string to be printed in the console.\n */\n static highlightSql(sql: string) {\n return highlight(sql, {\n colors: {\n keyword: ansi.blueBright.open,\n function: ansi.magentaBright.open,\n number: ansi.green.open,\n string: ansi.white.open,\n identifier: ansi.white.open,\n special: ansi.white.open,\n bracket: ansi.white.open,\n comment: ansi.gray.open,\n clear: ansi.reset.open,\n },\n })\n }\n\n /**\n * Pretty-print sql string to be print in the console.\n */\n static formatSql(sql: string, dataSourceType?: DatabaseType): string {\n const databaseLanguageMap: Record<\n string,\n SqlFormatterConfig[\"language\"]\n > = {\n oracle: \"pl/sql\",\n }\n\n const databaseLanguage = dataSourceType\n ? databaseLanguageMap[dataSourceType] || \"sql\"\n : \"sql\"\n\n return sqlFormat(sql, {\n language: databaseLanguage,\n indent: \" \",\n })\n }\n\n /**\n * Logging functions needed by AdvancedConsoleLogger\n */\n static logInfo(prefix: string, info: any) {\n console.log(ansi.gray.underline(prefix), info)\n }\n\n static logError(prefix: string, error: any) {\n console.log(ansi.underline.red(prefix), error)\n }\n\n static logWarn(prefix: string, warning: any) {\n console.log(ansi.underline.yellow(prefix), warning)\n }\n\n static log(message: string) {\n console.log(ansi.underline(message))\n }\n\n static info(info: any) {\n return ansi.gray(info)\n }\n\n static error(error: any) {\n return ansi.red(error)\n }\n\n static warn(message: string) {\n return ansi.yellow(message)\n }\n\n static logCmdErr(prefix: string, err?: any) {\n console.log(ansi.black.bgRed(prefix))\n if (err) console.error(err)\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/platform/PlatformTools.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,OAAO,CAAA;AACxB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAIzD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAE3C;;GAEG;AACH,MAAM,OAAO,aAAa;IAMtB;;OAEG;IACH,MAAM,CAAC,iBAAiB;QACpB,OAAO,MAAM,CAAA;IACjB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,IAAI,CAAC,IAAY;QACpB,2HAA2H;QAC3H,8FAA8F;QAC9F,kCAAkC;QAElC,IAAI,CAAC;YACD,wEAAwE;YACxE,QAAQ,IAAI,EAAE,CAAC;gBACX;;mBAEG;gBACH,KAAK,SAAS;oBACV,OAAO,OAAO,CAAC,uBAAuB,CAAC,CAAA;gBAE3C;;mBAEG;gBACH,KAAK,SAAS;oBACV,OAAO,OAAO,CAAC,SAAS,CAAC,CAAA;gBAE7B;;mBAEG;gBACH,KAAK,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\"path\"\nimport { highlight } from \"sql-highlight\"\nimport { format as sqlFormat } from \"@sqltools/formatter\"\nimport { type Config as SqlFormatterConfig } from \"@sqltools/formatter/lib/core/types\"\nimport { type DatabaseType } from \"../driver/types/DatabaseType\"\n\nexport { EventEmitter } from \"events\"\nexport { ReadStream } from \"fs\"\nexport { Readable, Writable } from \"stream\"\n\n/**\n * Platform-specific tools.\n */\nexport class PlatformTools {\n /**\n * Type of the currently running platform.\n */\n static type: \"browser\" | \"node\" = \"node\"\n\n /**\n * Gets global variable where global stuff can be stored.\n */\n static getGlobalVariable(): any {\n return global\n }\n\n /**\n * Loads (\"require\"-s) given file or package.\n * This operation only supports on node platform\n */\n static load(name: string): any {\n // if name is not absolute or relative, then try to load package from the node_modules of the directory we are currently in\n // this is useful when we are using typeorm package globally installed and it accesses drivers\n // that are not installed globally\n\n try {\n // switch case to explicit require statements for webpack compatibility.\n switch (name) {\n /**\n * spanner\n */\n case \"spanner\":\n return require(\"@google-cloud/spanner\")\n\n /**\n * mongodb\n */\n case \"mongodb\":\n return require(\"mongodb\")\n\n /**\n * hana\n */\n case \"@sap/hana-client\":\n return require(\"@sap/hana-client\")\n\n case \"@sap/hana-client/extension/Stream\":\n return require(\"@sap/hana-client/extension/Stream\")\n\n /**\n * mysql\n */\n case \"mysql\":\n return require(\"mysql\")\n\n case \"mysql2\":\n return require(\"mysql2\")\n\n /**\n * oracle\n */\n case \"oracledb\":\n return require(\"oracledb\")\n\n /**\n * postgres\n */\n case \"pg\":\n return require(\"pg\")\n\n case \"pg-native\":\n return require(\"pg-native\")\n\n case \"pg-query-stream\":\n return require(\"pg-query-stream\")\n\n case \"typeorm-aurora-data-api-driver\":\n return require(\"typeorm-aurora-data-api-driver\")\n\n /**\n * redis\n */\n case \"redis\":\n return require(\"redis\")\n\n case \"ioredis\":\n return require(\"ioredis\")\n\n /**\n * better-sqlite3\n */\n case \"better-sqlite3\":\n return require(\"better-sqlite3\")\n\n /**\n * sqlite\n */\n case \"sqlite3\":\n return require(\"sqlite3\")\n\n /**\n * sql.js\n */\n case \"sql.js\":\n return require(\"sql.js\")\n\n /**\n * sqlserver\n */\n case \"mssql\":\n return require(\"mssql\")\n\n /**\n * react-native-sqlite\n */\n case \"react-native-sqlite-storage\":\n return require(\"react-native-sqlite-storage\")\n }\n } catch (err) {\n return require(path.resolve(\n process.cwd() + \"/node_modules/\" + name,\n ))\n }\n\n // If nothing above matched and we get here, the package was not listed within PlatformTools\n // and is an Invalid Package. To make it explicit that this is NOT the intended use case for\n // PlatformTools.load - it's not just a way to replace `require` all willy-nilly - let's throw\n // an error.\n throw new TypeError(`Invalid Package for PlatformTools.load: ${name}`)\n }\n\n /**\n * Normalizes given path. Does \"path.normalize\" and replaces backslashes with forward slashes on Windows.\n */\n static pathNormalize(pathStr: string): string {\n let normalizedPath = path.normalize(pathStr)\n if (process.platform === \"win32\")\n normalizedPath = normalizedPath.replace(/\\\\/g, \"/\")\n return normalizedPath\n }\n\n /**\n * Gets file extension. Does \"path.extname\".\n */\n static pathExtname(pathStr: string): string {\n return path.extname(pathStr)\n }\n\n /**\n * Resolved given path. Does \"path.resolve\".\n */\n static pathResolve(pathStr: string): string {\n return path.resolve(pathStr)\n }\n\n /**\n * Synchronously checks if file exist. Does \"fs.existsSync\".\n */\n static fileExist(pathStr: string): boolean {\n return fs.existsSync(pathStr)\n }\n\n static readFileSync(filename: string): Buffer {\n return fs.readFileSync(filename)\n }\n\n static appendFileSync(filename: string, data: any): void {\n fs.appendFileSync(filename, data)\n }\n\n static async writeFile(path: string, data: any): Promise<void> {\n return fs.promises.writeFile(path, data)\n }\n\n /**\n * Loads a dotenv file into the environment variables.\n *\n * @param path The file to load as a dotenv configuration\n */\n static dotenv(pathStr: string): void {\n dotenv.config({ path: pathStr })\n }\n\n /**\n * Gets environment variable.\n */\n static getEnvVariable(name: string): any {\n return process.env[name]\n }\n\n /**\n * Highlights sql string to be printed in the console.\n */\n static highlightSql(sql: string) {\n return highlight(sql, {\n colors: {\n keyword: ansi.blueBright.open,\n function: ansi.magentaBright.open,\n number: ansi.green.open,\n string: ansi.white.open,\n identifier: ansi.white.open,\n special: ansi.white.open,\n bracket: ansi.white.open,\n comment: ansi.gray.open,\n clear: ansi.reset.open,\n },\n })\n }\n\n /**\n * Pretty-print sql string to be print in the console.\n */\n static formatSql(sql: string, dataSourceType?: DatabaseType): string {\n const databaseLanguageMap: Record<\n string,\n SqlFormatterConfig[\"language\"]\n > = {\n oracle: \"pl/sql\",\n }\n\n const databaseLanguage = dataSourceType\n ? databaseLanguageMap[dataSourceType] || \"sql\"\n : \"sql\"\n\n return sqlFormat(sql, {\n language: databaseLanguage,\n indent: \" \",\n })\n }\n\n /**\n * Logging functions needed by AdvancedConsoleLogger\n */\n static logInfo(prefix: string, info: any) {\n console.log(ansi.gray.underline(prefix), info)\n }\n\n static logError(prefix: string, error: any) {\n console.log(ansi.underline.red(prefix), error)\n }\n\n static logWarn(prefix: string, warning: any) {\n console.log(ansi.underline.yellow(prefix), warning)\n }\n\n static log(message: string) {\n console.log(ansi.underline(message))\n }\n\n static info(info: any) {\n return ansi.gray(info)\n }\n\n static error(error: any) {\n return ansi.red(error)\n }\n\n static warn(message: string) {\n return ansi.yellow(message)\n }\n\n static logCmdErr(prefix: string, err?: any) {\n console.log(ansi.black.bgRed(prefix))\n if (err) console.error(err)\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -286,6 +286,7 @@ export class QueryExpressionMap {
|
|
|
286
286
|
map.offset = this.offset;
|
|
287
287
|
map.skip = this.skip;
|
|
288
288
|
map.take = this.take;
|
|
289
|
+
map.useIndex = this.useIndex;
|
|
289
290
|
map.lockMode = this.lockMode;
|
|
290
291
|
map.onLocked = this.onLocked;
|
|
291
292
|
map.lockVersion = this.lockVersion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/query-builder/QueryExpressionMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAG/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AG,IAAI,CAAC,UAAU,CAAA;QAChC,GAAG,CAAC,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAA;QAC/D,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC1B,GAAG,CAAC,sBAAsB,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CACxD,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YACb,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,YAAY,EACR,OAAO,UAAU,CAAC,YAAY,KAAK,QAAQ;gBACvC,CAAC,CAAC,UAAU,CAAC,YAAY;gBACzB,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,KAAK,EAAE;YACzC,OAAO,EAAE,UAAU,CAAC,OAAO;SAC9B,CAAC,CACL,CAAA;QACD,OAAO,GAAG,CAAA;IACd,CAAC;CACJ","file":"QueryExpressionMap.js","sourcesContent":["import { Alias } from \"./Alias\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { OrderByCondition } from \"../find-options/OrderByCondition\"\nimport { JoinAttribute } from \"./JoinAttribute\"\nimport { QueryBuilder } from \"./QueryBuilder\"\nimport { QueryBuilderCteOptions } from \"./QueryBuilderCte\"\nimport { RelationIdAttribute } from \"./relation-id/RelationIdAttribute\"\nimport { RelationCountAttribute } from \"./relation-count/RelationCountAttribute\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { EntityMetadata } from \"../metadata/EntityMetadata\"\nimport { SelectQuery } from \"./SelectQuery\"\nimport { ColumnMetadata } from \"../metadata/ColumnMetadata\"\nimport { RelationMetadata } from \"../metadata/RelationMetadata\"\nimport { SelectQueryBuilderOption } from \"./SelectQueryBuilderOption\"\nimport { TypeORMError } from \"../error\"\nimport { WhereClause } from \"./WhereClause\"\nimport { UpsertType } from \"../driver/types/UpsertType\"\nimport { CockroachConnectionOptions } from \"../driver/cockroachdb/CockroachConnectionOptions\"\n\n/**\n * Contains all properties of the QueryBuilder that needs to be build a final query.\n */\nexport class QueryExpressionMap {\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Strategy to load relations.\n */\n relationLoadStrategy: \"join\" | \"query\" = \"join\"\n\n /**\n * Indicates if QueryBuilder used to select entities and not a raw results.\n */\n queryEntity: boolean = false\n\n /**\n * Main alias is a main selection object selected by QueryBuilder.\n */\n mainAlias?: Alias\n\n /**\n * All aliases (including main alias) used in the query.\n */\n aliases: Alias[] = []\n\n /**\n * Represents query type. QueryBuilder is able to build SELECT, UPDATE and DELETE queries.\n */\n queryType:\n | \"select\"\n | \"update\"\n | \"delete\"\n | \"insert\"\n | \"relation\"\n | \"soft-delete\"\n | \"restore\" = \"select\"\n\n /**\n * Data needs to be SELECT-ed.\n */\n selects: SelectQuery[] = []\n\n /**\n * Max execution time in millisecond.\n */\n maxExecutionTime: number = 0\n\n /**\n * Whether SELECT is DISTINCT.\n */\n selectDistinct: boolean = false\n\n /**\n * SELECT DISTINCT ON query (postgres).\n */\n selectDistinctOn: string[] = []\n\n /**\n * FROM-s to be selected.\n */\n // froms: { target: string, alias: string }[] = [];\n\n /**\n * If update query was used, it needs \"update set\" - properties which will be updated by this query.\n * If insert query was used, it needs \"insert set\" - values that needs to be inserted.\n */\n valuesSet?: ObjectLiteral | ObjectLiteral[]\n\n /**\n * Optional returning (or output) clause for insert, update or delete queries.\n */\n returning: string | string[]\n\n /**\n * Extra returning columns to be added to the returning statement if driver supports it.\n */\n extraReturningColumns: ColumnMetadata[] = []\n\n /**\n * Optional on conflict statement used in insertion query in postgres.\n */\n onConflict: string = \"\"\n\n /**\n * Optional on ignore statement used in insertion query in databases.\n */\n onIgnore: boolean = false\n\n /**\n * Optional on update statement used in insertion query in databases.\n */\n onUpdate: {\n conflict?: string | string[]\n columns?: string[]\n overwrite?: string[]\n skipUpdateIfNoValuesChanged?: boolean\n indexPredicate?: string\n upsertType?: UpsertType\n overwriteCondition?: WhereClause[]\n }\n\n /**\n * JOIN queries.\n */\n joinAttributes: JoinAttribute[] = []\n\n /**\n * RelationId queries.\n */\n relationIdAttributes: RelationIdAttribute[] = []\n\n /**\n * Relation count queries.\n */\n relationCountAttributes: RelationCountAttribute[] = []\n\n /**\n * WHERE queries.\n */\n wheres: WhereClause[] = []\n\n /**\n * HAVING queries.\n */\n havings: { type: \"simple\" | \"and\" | \"or\"; condition: string }[] = []\n\n /**\n * ORDER BY queries.\n */\n orderBys: OrderByCondition = {}\n\n /**\n * GROUP BY queries.\n */\n groupBys: string[] = []\n\n /**\n * LIMIT query.\n */\n limit?: number\n\n /**\n * OFFSET query.\n */\n offset?: number\n\n /**\n * Number of rows to skip of result using pagination.\n */\n skip?: number\n\n /**\n * Number of rows to take using pagination.\n */\n take?: number\n\n /**\n * Use certain index for the query.\n *\n * SELECT * FROM table_name USE INDEX (col1_index, col2_index) WHERE col1=1 AND col2=2 AND col3=3;\n */\n useIndex?: string\n\n /**\n * Locking mode.\n */\n lockMode?:\n | \"optimistic\"\n | \"pessimistic_read\"\n | \"pessimistic_write\"\n | \"dirty_read\"\n /*\n \"pessimistic_partial_write\" and \"pessimistic_write_or_fail\" are deprecated and\n will be removed in a future version.\n\n Use onLocked instead.\n */\n | \"pessimistic_partial_write\"\n | \"pessimistic_write_or_fail\"\n | \"for_no_key_update\"\n | \"for_key_share\"\n\n /**\n * Current version of the entity, used for locking.\n */\n lockVersion?: number | Date\n\n /**\n * Tables to be specified in the \"FOR UPDATE OF\" clause, referred by their alias\n */\n lockTables?: string[]\n\n /**\n * Modify behavior when encountering locked rows. NOWAIT or SKIP LOCKED\n */\n onLocked?: \"nowait\" | \"skip_locked\"\n\n /**\n * Indicates if soft-deleted rows should be included in entity result.\n * By default the soft-deleted rows are not included.\n */\n withDeleted: boolean = false\n\n /**\n * Parameters used to be escaped in final query.\n */\n parameters: ObjectLiteral = {}\n\n /**\n * Indicates if alias, table names and column names will be escaped by driver, or not.\n *\n * todo: rename to isQuotingDisabled, also think if it should be named \"escaping\"\n */\n disableEscaping: boolean = true\n\n /**\n * Indicates if virtual columns should be included in entity result.\n *\n * todo: what to do with it? is it properly used? what about persistence?\n */\n enableRelationIdValues: boolean = false\n\n /**\n * Extra where condition appended to the end of original where conditions with AND keyword.\n * Original condition will be wrapped into brackets.\n */\n extraAppendedAndWhereCondition: string = \"\"\n\n /**\n * Indicates if query builder creates a subquery.\n */\n subQuery: boolean = false\n\n /**\n * Indicates if property names are prefixed with alias names during property replacement.\n * By default this is enabled, however we need this because aliases are not supported in UPDATE and DELETE queries,\n * but user can use them in WHERE expressions.\n */\n aliasNamePrefixingEnabled: boolean = true\n\n /**\n * Indicates if query result cache is enabled or not.\n * It is undefined by default to avoid overriding the `alwaysEnabled` config\n */\n cache?: boolean\n\n /**\n * Time in milliseconds in which cache will expire.\n * If not set then global caching time will be used.\n */\n cacheDuration: number\n\n /**\n * Cache id.\n * Used to identifier your cache queries.\n */\n cacheId: string\n\n /**\n * Options that define QueryBuilder behaviour.\n */\n options: SelectQueryBuilderOption[] = []\n\n /**\n * Property path of relation to work with.\n * Used in relational query builder.\n */\n relationPropertyPath: string\n\n /**\n * Entity (target) which relations will be updated.\n */\n of: any | any[]\n\n /**\n * List of columns where data should be inserted.\n * Used in INSERT query.\n */\n insertColumns: string[] = []\n\n /**\n * Used if user wants to update or delete a specific entities.\n */\n whereEntities: ObjectLiteral[] = []\n\n /**\n * Indicates if entity must be updated after insertion / updation.\n * This may produce extra query or use RETURNING / OUTPUT statement (depend on database).\n */\n updateEntity: boolean = true\n\n /**\n * Indicates if listeners and subscribers must be called before and after query execution.\n */\n callListeners: boolean = true\n\n /**\n * Indicates if query must be wrapped into transaction.\n */\n useTransaction: boolean = false\n\n /**\n * Indicates if query should be time travel query\n * https://www.cockroachlabs.com/docs/stable/as-of-system-time.html\n */\n timeTravel?: boolean | string\n\n /**\n * Extra parameters.\n *\n * @deprecated Use standard parameters instead\n */\n nativeParameters: ObjectLiteral = {}\n\n /**\n * Query Comment to include extra information for debugging or other purposes.\n */\n comment?: string\n\n /**\n * Items from an entity that have been locally generated & are recorded here for later use.\n * Examples include the UUID generation when the database does not natively support it.\n * These are included in the entity index order.\n */\n locallyGenerated: { [key: number]: ObjectLiteral } = {}\n\n commonTableExpressions: {\n queryBuilder: QueryBuilder<any> | string\n alias: string\n options: QueryBuilderCteOptions\n }[] = []\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: DataSource) {\n if (connection.options.relationLoadStrategy) {\n this.relationLoadStrategy = connection.options.relationLoadStrategy\n }\n\n this.timeTravel =\n (connection.options as CockroachConnectionOptions)\n ?.timeTravelQueries || false\n }\n\n // -------------------------------------------------------------------------\n // Accessors\n // -------------------------------------------------------------------------\n\n /**\n * Get all ORDER BY queries - if order by is specified by user then it uses them,\n * otherwise it uses default entity order by if it was set.\n */\n get allOrderBys() {\n if (\n !Object.keys(this.orderBys).length &&\n this.mainAlias!.hasMetadata &&\n this.options.indexOf(\"disable-global-order\") === -1\n ) {\n const entityOrderBy = this.mainAlias!.metadata.orderBy || {}\n return Object.keys(entityOrderBy).reduce((orderBy, key) => {\n orderBy[this.mainAlias!.name + \".\" + key] = entityOrderBy[key]\n return orderBy\n }, {} as OrderByCondition)\n }\n\n return this.orderBys\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a main alias and adds it to the current expression map.\n */\n setMainAlias(alias: Alias): Alias {\n // if main alias is already set then remove it from the array\n // if (this.mainAlias)\n // this.aliases.splice(this.aliases.indexOf(this.mainAlias));\n\n // set new main alias\n this.mainAlias = alias\n\n return alias\n }\n\n /**\n * Creates a new alias and adds it to the current expression map.\n */\n createAlias(options: {\n type: \"from\" | \"select\" | \"join\" | \"other\"\n name?: string\n target?: Function | string\n tablePath?: string\n subQuery?: string\n metadata?: EntityMetadata\n }): Alias {\n let aliasName = options.name\n if (!aliasName && options.tablePath) aliasName = options.tablePath\n if (!aliasName && typeof options.target === \"function\")\n aliasName = options.target.name\n if (!aliasName && typeof options.target === \"string\")\n aliasName = options.target\n\n const alias = new Alias()\n alias.type = options.type\n if (aliasName) alias.name = aliasName\n if (options.metadata) alias.metadata = options.metadata\n if (options.target && !alias.hasMetadata)\n alias.metadata = this.connection.getMetadata(options.target)\n if (options.tablePath) alias.tablePath = options.tablePath\n if (options.subQuery) alias.subQuery = options.subQuery\n\n this.aliases.push(alias)\n return alias\n }\n\n /**\n * Finds alias with the given name.\n * If alias was not found it throw an exception.\n */\n findAliasByName(aliasName: string): Alias {\n const alias = this.aliases.find((alias) => alias.name === aliasName)\n if (!alias)\n throw new TypeORMError(\n `\"${aliasName}\" alias was not found. Maybe you forgot to join it?`,\n )\n\n return alias\n }\n\n findColumnByAliasExpression(\n aliasExpression: string,\n ): ColumnMetadata | undefined {\n const [aliasName, propertyPath] = aliasExpression.split(\".\")\n const alias = this.findAliasByName(aliasName)\n return alias.metadata.findColumnWithPropertyName(propertyPath)\n }\n\n /**\n * Gets relation metadata of the relation this query builder works with.\n *\n * todo: add proper exceptions\n */\n get relationMetadata(): RelationMetadata {\n if (!this.mainAlias)\n throw new TypeORMError(`Entity to work with is not specified!`) // todo: better message\n\n const relationMetadata =\n this.mainAlias.metadata.findRelationWithPropertyPath(\n this.relationPropertyPath,\n )\n if (!relationMetadata)\n throw new TypeORMError(\n `Relation ${this.relationPropertyPath} was not found in entity ${this.mainAlias.name}`,\n ) // todo: better message\n\n return relationMetadata\n }\n\n /**\n * Copies all properties of the current QueryExpressionMap into a new one.\n * Useful when QueryBuilder needs to create a copy of itself.\n */\n clone(): QueryExpressionMap {\n const map = new QueryExpressionMap(this.connection)\n map.queryType = this.queryType\n map.selects = this.selects.map((select) => select)\n map.maxExecutionTime = this.maxExecutionTime\n map.selectDistinct = this.selectDistinct\n map.selectDistinctOn = this.selectDistinctOn\n this.aliases.forEach((alias) => map.aliases.push(new Alias(alias)))\n map.relationLoadStrategy = this.relationLoadStrategy\n map.mainAlias = this.mainAlias\n map.valuesSet = this.valuesSet\n map.returning = this.returning\n map.onConflict = this.onConflict\n map.onIgnore = this.onIgnore\n map.onUpdate = this.onUpdate\n map.joinAttributes = this.joinAttributes.map(\n (join) => new JoinAttribute(this.connection, this, join),\n )\n map.relationIdAttributes = this.relationIdAttributes.map(\n (relationId) => new RelationIdAttribute(this, relationId),\n )\n map.relationCountAttributes = this.relationCountAttributes.map(\n (relationCount) => new RelationCountAttribute(this, relationCount),\n )\n map.wheres = this.wheres.map((where) => ({ ...where }))\n map.havings = this.havings.map((having) => ({ ...having }))\n map.orderBys = Object.assign({}, this.orderBys)\n map.groupBys = this.groupBys.map((groupBy) => groupBy)\n map.limit = this.limit\n map.offset = this.offset\n map.skip = this.skip\n map.take = this.take\n map.lockMode = this.lockMode\n map.onLocked = this.onLocked\n map.lockVersion = this.lockVersion\n map.lockTables = this.lockTables\n map.withDeleted = this.withDeleted\n map.parameters = Object.assign({}, this.parameters)\n map.disableEscaping = this.disableEscaping\n map.enableRelationIdValues = this.enableRelationIdValues\n map.extraAppendedAndWhereCondition = this.extraAppendedAndWhereCondition\n map.subQuery = this.subQuery\n map.aliasNamePrefixingEnabled = this.aliasNamePrefixingEnabled\n map.cache = this.cache\n map.cacheId = this.cacheId\n map.cacheDuration = this.cacheDuration\n map.relationPropertyPath = this.relationPropertyPath\n map.of = this.of\n map.insertColumns = this.insertColumns\n map.whereEntities = this.whereEntities\n map.updateEntity = this.updateEntity\n map.callListeners = this.callListeners\n map.useTransaction = this.useTransaction\n map.timeTravel = this.timeTravel\n map.nativeParameters = Object.assign({}, this.nativeParameters)\n map.comment = this.comment\n map.commonTableExpressions = this.commonTableExpressions.map(\n (cteOptions) => ({\n alias: cteOptions.alias,\n queryBuilder:\n typeof cteOptions.queryBuilder === \"string\"\n ? cteOptions.queryBuilder\n : cteOptions.queryBuilder.clone(),\n options: cteOptions.options,\n }),\n )\n return map\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources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AI,CAAC,YAAY,CAAA;QACpC,GAAG,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAA;QACtC,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAA;QACxC,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAA;QAChC,GAAG,CAAC,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAA;QAC/D,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC1B,GAAG,CAAC,sBAAsB,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CACxD,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YACb,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,YAAY,EACR,OAAO,UAAU,CAAC,YAAY,KAAK,QAAQ;gBACvC,CAAC,CAAC,UAAU,CAAC,YAAY;gBACzB,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,KAAK,EAAE;YACzC,OAAO,EAAE,UAAU,CAAC,OAAO;SAC9B,CAAC,CACL,CAAA;QACD,OAAO,GAAG,CAAA;IACd,CAAC;CACJ","file":"QueryExpressionMap.js","sourcesContent":["import { Alias } from \"./Alias\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { OrderByCondition } from \"../find-options/OrderByCondition\"\nimport { JoinAttribute } from \"./JoinAttribute\"\nimport { QueryBuilder } from \"./QueryBuilder\"\nimport { QueryBuilderCteOptions } from \"./QueryBuilderCte\"\nimport { RelationIdAttribute } from \"./relation-id/RelationIdAttribute\"\nimport { RelationCountAttribute } from \"./relation-count/RelationCountAttribute\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { EntityMetadata } from \"../metadata/EntityMetadata\"\nimport { SelectQuery } from \"./SelectQuery\"\nimport { ColumnMetadata } from \"../metadata/ColumnMetadata\"\nimport { RelationMetadata } from \"../metadata/RelationMetadata\"\nimport { SelectQueryBuilderOption } from \"./SelectQueryBuilderOption\"\nimport { TypeORMError } from \"../error\"\nimport { WhereClause } from \"./WhereClause\"\nimport { UpsertType } from \"../driver/types/UpsertType\"\nimport { CockroachConnectionOptions } from \"../driver/cockroachdb/CockroachConnectionOptions\"\n\n/**\n * Contains all properties of the QueryBuilder that needs to be build a final query.\n */\nexport class QueryExpressionMap {\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Strategy to load relations.\n */\n relationLoadStrategy: \"join\" | \"query\" = \"join\"\n\n /**\n * Indicates if QueryBuilder used to select entities and not a raw results.\n */\n queryEntity: boolean = false\n\n /**\n * Main alias is a main selection object selected by QueryBuilder.\n */\n mainAlias?: Alias\n\n /**\n * All aliases (including main alias) used in the query.\n */\n aliases: Alias[] = []\n\n /**\n * Represents query type. QueryBuilder is able to build SELECT, UPDATE and DELETE queries.\n */\n queryType:\n | \"select\"\n | \"update\"\n | \"delete\"\n | \"insert\"\n | \"relation\"\n | \"soft-delete\"\n | \"restore\" = \"select\"\n\n /**\n * Data needs to be SELECT-ed.\n */\n selects: SelectQuery[] = []\n\n /**\n * Max execution time in millisecond.\n */\n maxExecutionTime: number = 0\n\n /**\n * Whether SELECT is DISTINCT.\n */\n selectDistinct: boolean = false\n\n /**\n * SELECT DISTINCT ON query (postgres).\n */\n selectDistinctOn: string[] = []\n\n /**\n * FROM-s to be selected.\n */\n // froms: { target: string, alias: string }[] = [];\n\n /**\n * If update query was used, it needs \"update set\" - properties which will be updated by this query.\n * If insert query was used, it needs \"insert set\" - values that needs to be inserted.\n */\n valuesSet?: ObjectLiteral | ObjectLiteral[]\n\n /**\n * Optional returning (or output) clause for insert, update or delete queries.\n */\n returning: string | string[]\n\n /**\n * Extra returning columns to be added to the returning statement if driver supports it.\n */\n extraReturningColumns: ColumnMetadata[] = []\n\n /**\n * Optional on conflict statement used in insertion query in postgres.\n */\n onConflict: string = \"\"\n\n /**\n * Optional on ignore statement used in insertion query in databases.\n */\n onIgnore: boolean = false\n\n /**\n * Optional on update statement used in insertion query in databases.\n */\n onUpdate: {\n conflict?: string | string[]\n columns?: string[]\n overwrite?: string[]\n skipUpdateIfNoValuesChanged?: boolean\n indexPredicate?: string\n upsertType?: UpsertType\n overwriteCondition?: WhereClause[]\n }\n\n /**\n * JOIN queries.\n */\n joinAttributes: JoinAttribute[] = []\n\n /**\n * RelationId queries.\n */\n relationIdAttributes: RelationIdAttribute[] = []\n\n /**\n * Relation count queries.\n */\n relationCountAttributes: RelationCountAttribute[] = []\n\n /**\n * WHERE queries.\n */\n wheres: WhereClause[] = []\n\n /**\n * HAVING queries.\n */\n havings: { type: \"simple\" | \"and\" | \"or\"; condition: string }[] = []\n\n /**\n * ORDER BY queries.\n */\n orderBys: OrderByCondition = {}\n\n /**\n * GROUP BY queries.\n */\n groupBys: string[] = []\n\n /**\n * LIMIT query.\n */\n limit?: number\n\n /**\n * OFFSET query.\n */\n offset?: number\n\n /**\n * Number of rows to skip of result using pagination.\n */\n skip?: number\n\n /**\n * Number of rows to take using pagination.\n */\n take?: number\n\n /**\n * Use certain index for the query.\n *\n * SELECT * FROM table_name USE INDEX (col1_index, col2_index) WHERE col1=1 AND col2=2 AND col3=3;\n */\n useIndex?: string\n\n /**\n * Locking mode.\n */\n lockMode?:\n | \"optimistic\"\n | \"pessimistic_read\"\n | \"pessimistic_write\"\n | \"dirty_read\"\n /*\n \"pessimistic_partial_write\" and \"pessimistic_write_or_fail\" are deprecated and\n will be removed in a future version.\n\n Use onLocked instead.\n */\n | \"pessimistic_partial_write\"\n | \"pessimistic_write_or_fail\"\n | \"for_no_key_update\"\n | \"for_key_share\"\n\n /**\n * Current version of the entity, used for locking.\n */\n lockVersion?: number | Date\n\n /**\n * Tables to be specified in the \"FOR UPDATE OF\" clause, referred by their alias\n */\n lockTables?: string[]\n\n /**\n * Modify behavior when encountering locked rows. NOWAIT or SKIP LOCKED\n */\n onLocked?: \"nowait\" | \"skip_locked\"\n\n /**\n * Indicates if soft-deleted rows should be included in entity result.\n * By default the soft-deleted rows are not included.\n */\n withDeleted: boolean = false\n\n /**\n * Parameters used to be escaped in final query.\n */\n parameters: ObjectLiteral = {}\n\n /**\n * Indicates if alias, table names and column names will be escaped by driver, or not.\n *\n * todo: rename to isQuotingDisabled, also think if it should be named \"escaping\"\n */\n disableEscaping: boolean = true\n\n /**\n * Indicates if virtual columns should be included in entity result.\n *\n * todo: what to do with it? is it properly used? what about persistence?\n */\n enableRelationIdValues: boolean = false\n\n /**\n * Extra where condition appended to the end of original where conditions with AND keyword.\n * Original condition will be wrapped into brackets.\n */\n extraAppendedAndWhereCondition: string = \"\"\n\n /**\n * Indicates if query builder creates a subquery.\n */\n subQuery: boolean = false\n\n /**\n * Indicates if property names are prefixed with alias names during property replacement.\n * By default this is enabled, however we need this because aliases are not supported in UPDATE and DELETE queries,\n * but user can use them in WHERE expressions.\n */\n aliasNamePrefixingEnabled: boolean = true\n\n /**\n * Indicates if query result cache is enabled or not.\n * It is undefined by default to avoid overriding the `alwaysEnabled` config\n */\n cache?: boolean\n\n /**\n * Time in milliseconds in which cache will expire.\n * If not set then global caching time will be used.\n */\n cacheDuration: number\n\n /**\n * Cache id.\n * Used to identifier your cache queries.\n */\n cacheId: string\n\n /**\n * Options that define QueryBuilder behaviour.\n */\n options: SelectQueryBuilderOption[] = []\n\n /**\n * Property path of relation to work with.\n * Used in relational query builder.\n */\n relationPropertyPath: string\n\n /**\n * Entity (target) which relations will be updated.\n */\n of: any | any[]\n\n /**\n * List of columns where data should be inserted.\n * Used in INSERT query.\n */\n insertColumns: string[] = []\n\n /**\n * Used if user wants to update or delete a specific entities.\n */\n whereEntities: ObjectLiteral[] = []\n\n /**\n * Indicates if entity must be updated after insertion / updation.\n * This may produce extra query or use RETURNING / OUTPUT statement (depend on database).\n */\n updateEntity: boolean = true\n\n /**\n * Indicates if listeners and subscribers must be called before and after query execution.\n */\n callListeners: boolean = true\n\n /**\n * Indicates if query must be wrapped into transaction.\n */\n useTransaction: boolean = false\n\n /**\n * Indicates if query should be time travel query\n * https://www.cockroachlabs.com/docs/stable/as-of-system-time.html\n */\n timeTravel?: boolean | string\n\n /**\n * Extra parameters.\n *\n * @deprecated Use standard parameters instead\n */\n nativeParameters: ObjectLiteral = {}\n\n /**\n * Query Comment to include extra information for debugging or other purposes.\n */\n comment?: string\n\n /**\n * Items from an entity that have been locally generated & are recorded here for later use.\n * Examples include the UUID generation when the database does not natively support it.\n * These are included in the entity index order.\n */\n locallyGenerated: { [key: number]: ObjectLiteral } = {}\n\n commonTableExpressions: {\n queryBuilder: QueryBuilder<any> | string\n alias: string\n options: QueryBuilderCteOptions\n }[] = []\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: DataSource) {\n if (connection.options.relationLoadStrategy) {\n this.relationLoadStrategy = connection.options.relationLoadStrategy\n }\n\n this.timeTravel =\n (connection.options as CockroachConnectionOptions)\n ?.timeTravelQueries || false\n }\n\n // -------------------------------------------------------------------------\n // Accessors\n // -------------------------------------------------------------------------\n\n /**\n * Get all ORDER BY queries - if order by is specified by user then it uses them,\n * otherwise it uses default entity order by if it was set.\n */\n get allOrderBys() {\n if (\n !Object.keys(this.orderBys).length &&\n this.mainAlias!.hasMetadata &&\n this.options.indexOf(\"disable-global-order\") === -1\n ) {\n const entityOrderBy = this.mainAlias!.metadata.orderBy || {}\n return Object.keys(entityOrderBy).reduce((orderBy, key) => {\n orderBy[this.mainAlias!.name + \".\" + key] = entityOrderBy[key]\n return orderBy\n }, {} as OrderByCondition)\n }\n\n return this.orderBys\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a main alias and adds it to the current expression map.\n */\n setMainAlias(alias: Alias): Alias {\n // if main alias is already set then remove it from the array\n // if (this.mainAlias)\n // this.aliases.splice(this.aliases.indexOf(this.mainAlias));\n\n // set new main alias\n this.mainAlias = alias\n\n return alias\n }\n\n /**\n * Creates a new alias and adds it to the current expression map.\n */\n createAlias(options: {\n type: \"from\" | \"select\" | \"join\" | \"other\"\n name?: string\n target?: Function | string\n tablePath?: string\n subQuery?: string\n metadata?: EntityMetadata\n }): Alias {\n let aliasName = options.name\n if (!aliasName && options.tablePath) aliasName = options.tablePath\n if (!aliasName && typeof options.target === \"function\")\n aliasName = options.target.name\n if (!aliasName && typeof options.target === \"string\")\n aliasName = options.target\n\n const alias = new Alias()\n alias.type = options.type\n if (aliasName) alias.name = aliasName\n if (options.metadata) alias.metadata = options.metadata\n if (options.target && !alias.hasMetadata)\n alias.metadata = this.connection.getMetadata(options.target)\n if (options.tablePath) alias.tablePath = options.tablePath\n if (options.subQuery) alias.subQuery = options.subQuery\n\n this.aliases.push(alias)\n return alias\n }\n\n /**\n * Finds alias with the given name.\n * If alias was not found it throw an exception.\n */\n findAliasByName(aliasName: string): Alias {\n const alias = this.aliases.find((alias) => alias.name === aliasName)\n if (!alias)\n throw new TypeORMError(\n `\"${aliasName}\" alias was not found. Maybe you forgot to join it?`,\n )\n\n return alias\n }\n\n findColumnByAliasExpression(\n aliasExpression: string,\n ): ColumnMetadata | undefined {\n const [aliasName, propertyPath] = aliasExpression.split(\".\")\n const alias = this.findAliasByName(aliasName)\n return alias.metadata.findColumnWithPropertyName(propertyPath)\n }\n\n /**\n * Gets relation metadata of the relation this query builder works with.\n *\n * todo: add proper exceptions\n */\n get relationMetadata(): RelationMetadata {\n if (!this.mainAlias)\n throw new TypeORMError(`Entity to work with is not specified!`) // todo: better message\n\n const relationMetadata =\n this.mainAlias.metadata.findRelationWithPropertyPath(\n this.relationPropertyPath,\n )\n if (!relationMetadata)\n throw new TypeORMError(\n `Relation ${this.relationPropertyPath} was not found in entity ${this.mainAlias.name}`,\n ) // todo: better message\n\n return relationMetadata\n }\n\n /**\n * Copies all properties of the current QueryExpressionMap into a new one.\n * Useful when QueryBuilder needs to create a copy of itself.\n */\n clone(): QueryExpressionMap {\n const map = new QueryExpressionMap(this.connection)\n map.queryType = this.queryType\n map.selects = this.selects.map((select) => select)\n map.maxExecutionTime = this.maxExecutionTime\n map.selectDistinct = this.selectDistinct\n map.selectDistinctOn = this.selectDistinctOn\n this.aliases.forEach((alias) => map.aliases.push(new Alias(alias)))\n map.relationLoadStrategy = this.relationLoadStrategy\n map.mainAlias = this.mainAlias\n map.valuesSet = this.valuesSet\n map.returning = this.returning\n map.onConflict = this.onConflict\n map.onIgnore = this.onIgnore\n map.onUpdate = this.onUpdate\n map.joinAttributes = this.joinAttributes.map(\n (join) => new JoinAttribute(this.connection, this, join),\n )\n map.relationIdAttributes = this.relationIdAttributes.map(\n (relationId) => new RelationIdAttribute(this, relationId),\n )\n map.relationCountAttributes = this.relationCountAttributes.map(\n (relationCount) => new RelationCountAttribute(this, relationCount),\n )\n map.wheres = this.wheres.map((where) => ({ ...where }))\n map.havings = this.havings.map((having) => ({ ...having }))\n map.orderBys = Object.assign({}, this.orderBys)\n map.groupBys = this.groupBys.map((groupBy) => groupBy)\n map.limit = this.limit\n map.offset = this.offset\n map.skip = this.skip\n map.take = this.take\n map.useIndex = this.useIndex\n map.lockMode = this.lockMode\n map.onLocked = this.onLocked\n map.lockVersion = this.lockVersion\n map.lockTables = this.lockTables\n map.withDeleted = this.withDeleted\n map.parameters = Object.assign({}, this.parameters)\n map.disableEscaping = this.disableEscaping\n map.enableRelationIdValues = this.enableRelationIdValues\n map.extraAppendedAndWhereCondition = this.extraAppendedAndWhereCondition\n map.subQuery = this.subQuery\n map.aliasNamePrefixingEnabled = this.aliasNamePrefixingEnabled\n map.cache = this.cache\n map.cacheId = this.cacheId\n map.cacheDuration = this.cacheDuration\n map.relationPropertyPath = this.relationPropertyPath\n map.of = this.of\n map.insertColumns = this.insertColumns\n map.whereEntities = this.whereEntities\n map.updateEntity = this.updateEntity\n map.callListeners = this.callListeners\n map.useTransaction = this.useTransaction\n map.timeTravel = this.timeTravel\n map.nativeParameters = Object.assign({}, this.nativeParameters)\n map.comment = this.comment\n map.commonTableExpressions = this.commonTableExpressions.map(\n (cteOptions) => ({\n alias: cteOptions.alias,\n queryBuilder:\n typeof cteOptions.queryBuilder === \"string\"\n ? cteOptions.queryBuilder\n : cteOptions.queryBuilder.clone(),\n options: cteOptions.options,\n }),\n )\n return map\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -14,40 +14,66 @@ export interface SapConnectionOptions extends BaseDataSourceOptions, SapConnecti
|
|
|
14
14
|
readonly schema?: string;
|
|
15
15
|
/**
|
|
16
16
|
* The driver objects
|
|
17
|
-
* This defaults to require("
|
|
17
|
+
* This defaults to require("@sap/hana-client")
|
|
18
18
|
*/
|
|
19
19
|
readonly driver?: any;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
* This defaults to require("@sap/hana-client")
|
|
21
|
+
* @deprecated Use {@link driver} instead.
|
|
23
22
|
*/
|
|
24
23
|
readonly hanaClientDriver?: any;
|
|
25
24
|
/**
|
|
26
25
|
* Pool options.
|
|
27
26
|
*/
|
|
28
27
|
readonly pool?: {
|
|
28
|
+
/**
|
|
29
|
+
* Maximum number of open connections created by the pool, each of which
|
|
30
|
+
* may be in the pool waiting to be reused or may no longer be in the
|
|
31
|
+
* pool and actively being used (default: 10).
|
|
32
|
+
*/
|
|
33
|
+
readonly maxConnectedOrPooled?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Defines the maximum time, in seconds, that connections are allowed to
|
|
36
|
+
* remain in the pool before being marked for eviction (default: 30).
|
|
37
|
+
*/
|
|
38
|
+
readonly maxPooledIdleTime?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Determines whether or not the pooled connection should be tested for
|
|
41
|
+
* viability before being reused (default: false).
|
|
42
|
+
*/
|
|
43
|
+
readonly pingCheck?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Maximum number of connections allowed to be in the pool, waiting to
|
|
46
|
+
* be reused (default: 0, no limit).
|
|
47
|
+
*/
|
|
48
|
+
readonly poolCapacity?: number;
|
|
29
49
|
/**
|
|
30
50
|
* Max number of connections.
|
|
51
|
+
* @deprecated Use {@link maxConnectedOrPooled} instead.
|
|
31
52
|
*/
|
|
32
53
|
readonly max?: number;
|
|
33
54
|
/**
|
|
34
55
|
* Minimum number of connections.
|
|
56
|
+
* @deprecated Obsolete, no alternative exists.
|
|
35
57
|
*/
|
|
36
58
|
readonly min?: number;
|
|
37
59
|
/**
|
|
38
|
-
* Maximum number of waiting requests allowed.
|
|
60
|
+
* Maximum number of waiting requests allowed.
|
|
61
|
+
* @deprecated Obsolete, no alternative exists.
|
|
39
62
|
*/
|
|
40
63
|
readonly maxWaitingRequests?: number;
|
|
41
64
|
/**
|
|
42
|
-
* Max milliseconds a request will wait for a resource before timing out.
|
|
65
|
+
* Max milliseconds a request will wait for a resource before timing out.
|
|
66
|
+
* @deprecated Obsolete, no alternative exists.
|
|
43
67
|
*/
|
|
44
68
|
readonly requestTimeout?: number;
|
|
45
69
|
/**
|
|
46
|
-
* How often to run resource timeout checks.
|
|
70
|
+
* How often to run resource timeout checks.
|
|
71
|
+
* @deprecated Obsolete, no alternative exists.
|
|
47
72
|
*/
|
|
48
73
|
readonly checkInterval?: number;
|
|
49
74
|
/**
|
|
50
|
-
* Idle timeout
|
|
75
|
+
* Idle timeout (in milliseconds).
|
|
76
|
+
* @deprecated Use {@link maxPooledIdleTime} (in seconds) instead .
|
|
51
77
|
*/
|
|
52
78
|
readonly idleTimeout?: number;
|
|
53
79
|
/**
|
|
@@ -56,5 +82,4 @@ export interface SapConnectionOptions extends BaseDataSourceOptions, SapConnecti
|
|
|
56
82
|
*/
|
|
57
83
|
readonly poolErrorHandler?: (err: any) => any;
|
|
58
84
|
};
|
|
59
|
-
readonly poolSize?: never;
|
|
60
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/driver/sap/SapConnectionOptions.ts"],"names":[],"mappings":"","file":"SapConnectionOptions.js","sourcesContent":["import { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\nimport { SapConnectionCredentialsOptions } from \"./SapConnectionCredentialsOptions\"\n\n/**\n * SAP Hana specific connection options.\n */\nexport interface SapConnectionOptions\n extends BaseDataSourceOptions,\n SapConnectionCredentialsOptions {\n /**\n * Database type.\n */\n readonly type: \"sap\"\n\n /**\n * Database schema.\n */\n readonly schema?: string\n\n /**\n * The driver objects\n * This defaults to require(\"
|
|
1
|
+
{"version":3,"sources":["../../src/driver/sap/SapConnectionOptions.ts"],"names":[],"mappings":"","file":"SapConnectionOptions.js","sourcesContent":["import { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\nimport { SapConnectionCredentialsOptions } from \"./SapConnectionCredentialsOptions\"\n\n/**\n * SAP Hana specific connection options.\n */\nexport interface SapConnectionOptions\n extends BaseDataSourceOptions,\n SapConnectionCredentialsOptions {\n /**\n * Database type.\n */\n readonly type: \"sap\"\n\n /**\n * Database schema.\n */\n readonly schema?: string\n\n /**\n * The driver objects\n * This defaults to require(\"@sap/hana-client\")\n */\n readonly driver?: any\n\n /**\n * @deprecated Use {@link driver} instead.\n */\n readonly hanaClientDriver?: any\n\n /**\n * Pool options.\n */\n readonly pool?: {\n /**\n * Maximum number of open connections created by the pool, each of which\n * may be in the pool waiting to be reused or may no longer be in the\n * pool and actively being used (default: 10).\n */\n readonly maxConnectedOrPooled?: number\n\n /**\n * Defines the maximum time, in seconds, that connections are allowed to\n * remain in the pool before being marked for eviction (default: 30).\n */\n readonly maxPooledIdleTime?: number\n\n /**\n * Determines whether or not the pooled connection should be tested for\n * viability before being reused (default: false).\n */\n readonly pingCheck?: boolean\n\n /**\n * Maximum number of connections allowed to be in the pool, waiting to\n * be reused (default: 0, no limit).\n */\n readonly poolCapacity?: number\n\n /**\n * Max number of connections.\n * @deprecated Use {@link maxConnectedOrPooled} instead.\n */\n readonly max?: number\n\n /**\n * Minimum number of connections.\n * @deprecated Obsolete, no alternative exists.\n */\n readonly min?: number\n\n /**\n * Maximum number of waiting requests allowed.\n * @deprecated Obsolete, no alternative exists.\n */\n readonly maxWaitingRequests?: number\n\n /**\n * Max milliseconds a request will wait for a resource before timing out.\n * @deprecated Obsolete, no alternative exists.\n */\n readonly requestTimeout?: number\n\n /**\n * How often to run resource timeout checks.\n * @deprecated Obsolete, no alternative exists.\n */\n readonly checkInterval?: number\n\n /**\n * Idle timeout (in milliseconds).\n * @deprecated Use {@link maxPooledIdleTime} (in seconds) instead .\n */\n readonly idleTimeout?: number\n\n /**\n * Function handling errors thrown by drivers pool.\n * Defaults to logging error with `warn` level.\n */\n readonly poolErrorHandler?: (err: any) => any\n }\n}\n"],"sourceRoot":"../.."}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { ColumnType, DataSource, EntityMetadata, ObjectLiteral, Table, TableColumn, TableForeignKey } from "../..";
|
|
2
2
|
import { ColumnMetadata } from "../../metadata/ColumnMetadata";
|
|
3
3
|
import { RdbmsSchemaBuilder } from "../../schema-builder/RdbmsSchemaBuilder";
|
|
4
|
+
import { View } from "../../schema-builder/view/View";
|
|
4
5
|
import { Driver } from "../Driver";
|
|
5
6
|
import { CteCapabilities } from "../types/CteCapabilities";
|
|
6
7
|
import { DataTypeDefaults } from "../types/DataTypeDefaults";
|
|
7
8
|
import { MappedColumnTypes } from "../types/MappedColumnTypes";
|
|
8
|
-
import { SapConnectionOptions } from "./SapConnectionOptions";
|
|
9
|
-
import { SapQueryRunner } from "./SapQueryRunner";
|
|
10
9
|
import { ReplicationMode } from "../types/ReplicationMode";
|
|
11
|
-
import { View } from "../../schema-builder/view/View";
|
|
12
10
|
import { UpsertType } from "../types/UpsertType";
|
|
11
|
+
import { SapConnectionOptions } from "./SapConnectionOptions";
|
|
12
|
+
import { SapQueryRunner } from "./SapQueryRunner";
|
|
13
13
|
/**
|
|
14
14
|
* Organizes communication with SAP Hana DBMS.
|
|
15
15
|
*
|
|
@@ -21,11 +21,11 @@ export declare class SapDriver implements Driver {
|
|
|
21
21
|
*/
|
|
22
22
|
connection: DataSource;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* SAP HANA Client Pool instance.
|
|
25
25
|
*/
|
|
26
26
|
client: any;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* SAP HANA Client streaming extension.
|
|
29
29
|
*/
|
|
30
30
|
streamClient: any;
|
|
31
31
|
/**
|
|
@@ -33,10 +33,9 @@ export declare class SapDriver implements Driver {
|
|
|
33
33
|
*/
|
|
34
34
|
master: any;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
* Used in replication.
|
|
36
|
+
* Function handling errors thrown by drivers pool.
|
|
38
37
|
*/
|
|
39
|
-
|
|
38
|
+
poolErrorHandler: (error: any) => void;
|
|
40
39
|
/**
|
|
41
40
|
* Connection options.
|
|
42
41
|
*/
|
|
@@ -104,7 +103,7 @@ export declare class SapDriver implements Driver {
|
|
|
104
103
|
dataTypeDefaults: DataTypeDefaults;
|
|
105
104
|
/**
|
|
106
105
|
* Max length allowed by SAP HANA for aliases (identifiers).
|
|
107
|
-
* @see https://help.sap.com/
|
|
106
|
+
* @see https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-sql-reference-guide/system-limitations
|
|
108
107
|
*/
|
|
109
108
|
maxAliasLength: number;
|
|
110
109
|
cteCapabilities: CteCapabilities;
|
|
@@ -124,6 +123,18 @@ export declare class SapDriver implements Driver {
|
|
|
124
123
|
* Closes connection with the database.
|
|
125
124
|
*/
|
|
126
125
|
disconnect(): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Obtains a new database connection to a master server.
|
|
128
|
+
* Used for replication.
|
|
129
|
+
* If replication is not setup then returns default connection's database connection.
|
|
130
|
+
*/
|
|
131
|
+
obtainMasterConnection(): Promise<any>;
|
|
132
|
+
/**
|
|
133
|
+
* Obtains a new database connection to a slave server.
|
|
134
|
+
* Used for replication.
|
|
135
|
+
* If replication is not setup then returns master (default) connection's database connection.
|
|
136
|
+
*/
|
|
137
|
+
obtainSlaveConnection(): Promise<any>;
|
|
127
138
|
/**
|
|
128
139
|
* Creates a schema builder used to build and sync a schema.
|
|
129
140
|
*/
|
|
@@ -187,18 +198,6 @@ export declare class SapDriver implements Driver {
|
|
|
187
198
|
* Creates column type definition including length, precision and scale
|
|
188
199
|
*/
|
|
189
200
|
createFullType(column: TableColumn): string;
|
|
190
|
-
/**
|
|
191
|
-
* Obtains a new database connection to a master server.
|
|
192
|
-
* Used for replication.
|
|
193
|
-
* If replication is not setup then returns default connection's database connection.
|
|
194
|
-
*/
|
|
195
|
-
obtainMasterConnection(): Promise<any>;
|
|
196
|
-
/**
|
|
197
|
-
* Obtains a new database connection to a slave server.
|
|
198
|
-
* Used for replication.
|
|
199
|
-
* If replication is not setup then returns master (default) connection's database connection.
|
|
200
|
-
*/
|
|
201
|
-
obtainSlaveConnection(): Promise<any>;
|
|
202
201
|
/**
|
|
203
202
|
* Creates generated map of values generated or returned by database after INSERT query.
|
|
204
203
|
*/
|
package/driver/sap/SapDriver.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SapDriver = void 0;
|
|
4
|
+
const node_util_1 = require("node:util");
|
|
4
5
|
const __1 = require("../..");
|
|
5
6
|
const DriverPackageNotInstalledError_1 = require("../../error/DriverPackageNotInstalledError");
|
|
6
7
|
const TypeORMError_1 = require("../../error/TypeORMError");
|
|
@@ -8,10 +9,10 @@ const PlatformTools_1 = require("../../platform/PlatformTools");
|
|
|
8
9
|
const RdbmsSchemaBuilder_1 = require("../../schema-builder/RdbmsSchemaBuilder");
|
|
9
10
|
const ApplyValueTransformers_1 = require("../../util/ApplyValueTransformers");
|
|
10
11
|
const DateUtils_1 = require("../../util/DateUtils");
|
|
12
|
+
const InstanceChecker_1 = require("../../util/InstanceChecker");
|
|
11
13
|
const OrmUtils_1 = require("../../util/OrmUtils");
|
|
12
|
-
const SapQueryRunner_1 = require("./SapQueryRunner");
|
|
13
14
|
const DriverUtils_1 = require("../DriverUtils");
|
|
14
|
-
const
|
|
15
|
+
const SapQueryRunner_1 = require("./SapQueryRunner");
|
|
15
16
|
/**
|
|
16
17
|
* Organizes communication with SAP Hana DBMS.
|
|
17
18
|
*
|
|
@@ -22,11 +23,6 @@ class SapDriver {
|
|
|
22
23
|
// Constructor
|
|
23
24
|
// -------------------------------------------------------------------------
|
|
24
25
|
constructor(connection) {
|
|
25
|
-
/**
|
|
26
|
-
* Pool for slave databases.
|
|
27
|
-
* Used in replication.
|
|
28
|
-
*/
|
|
29
|
-
this.slaves = [];
|
|
30
26
|
/**
|
|
31
27
|
* Indicates if replication is enabled.
|
|
32
28
|
*/
|
|
@@ -154,7 +150,7 @@ class SapDriver {
|
|
|
154
150
|
};
|
|
155
151
|
/**
|
|
156
152
|
* Max length allowed by SAP HANA for aliases (identifiers).
|
|
157
|
-
* @see https://help.sap.com/
|
|
153
|
+
* @see https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-sql-reference-guide/system-limitations
|
|
158
154
|
*/
|
|
159
155
|
this.maxAliasLength = 128;
|
|
160
156
|
this.cteCapabilities = {
|
|
@@ -177,50 +173,55 @@ class SapDriver {
|
|
|
177
173
|
*/
|
|
178
174
|
async connect() {
|
|
179
175
|
// HANA connection info
|
|
180
|
-
const
|
|
181
|
-
|
|
176
|
+
const connectionOptions = {
|
|
177
|
+
host: this.options.host,
|
|
182
178
|
port: this.options.port,
|
|
183
|
-
|
|
179
|
+
user: this.options.username,
|
|
184
180
|
password: this.options.password,
|
|
185
|
-
|
|
181
|
+
database: this.options.database,
|
|
182
|
+
currentSchema: this.options.schema,
|
|
183
|
+
encrypt: this.options.encrypt,
|
|
184
|
+
sslValidateCertificate: this.options.sslValidateCertificate,
|
|
185
|
+
key: this.options.key,
|
|
186
|
+
cert: this.options.cert,
|
|
187
|
+
ca: this.options.ca,
|
|
186
188
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (this.options.sslValidateCertificate)
|
|
194
|
-
dbParams.validateCertificate = this.options.sslValidateCertificate;
|
|
195
|
-
if (this.options.key)
|
|
196
|
-
dbParams.key = this.options.key;
|
|
197
|
-
if (this.options.cert)
|
|
198
|
-
dbParams.cert = this.options.cert;
|
|
199
|
-
if (this.options.ca)
|
|
200
|
-
dbParams.ca = this.options.ca;
|
|
189
|
+
Object.keys(connectionOptions).forEach((key) => {
|
|
190
|
+
if (connectionOptions[key] === undefined) {
|
|
191
|
+
delete connectionOptions[key];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
Object.assign(connectionOptions, this.options.extra ?? {});
|
|
201
195
|
// pool options
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
196
|
+
const poolOptions = {
|
|
197
|
+
maxConnectedOrPooled: this.options.pool?.maxConnectedOrPooled ??
|
|
198
|
+
this.options.pool?.max ??
|
|
199
|
+
this.options.poolSize ??
|
|
200
|
+
10,
|
|
201
|
+
maxPooledIdleTime: this.options.pool?.maxPooledIdleTime ??
|
|
202
|
+
(this.options.pool?.idleTimeout
|
|
203
|
+
? this.options.pool.idleTimeout / 1000
|
|
204
|
+
: 30),
|
|
209
205
|
};
|
|
210
|
-
if (this.options.pool
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
this.client.eventEmitter.on("poolError", poolErrorHandler);
|
|
206
|
+
if (this.options.pool?.pingCheck) {
|
|
207
|
+
poolOptions.pingCheck = this.options.pool.pingCheck;
|
|
208
|
+
}
|
|
209
|
+
if (this.options.pool?.poolCapacity) {
|
|
210
|
+
poolOptions.poolCapacity = this.options.pool.poolCapacity;
|
|
211
|
+
}
|
|
212
|
+
this.poolErrorHandler =
|
|
213
|
+
this.options.pool?.poolErrorHandler ??
|
|
214
|
+
((error) => {
|
|
215
|
+
this.connection.logger.log("warn", `SAP HANA pool raised an error: ${error}`);
|
|
216
|
+
});
|
|
222
217
|
// create the pool
|
|
223
|
-
|
|
218
|
+
try {
|
|
219
|
+
this.master = this.client.createPool(connectionOptions, poolOptions);
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
this.poolErrorHandler(error);
|
|
223
|
+
throw error;
|
|
224
|
+
}
|
|
224
225
|
const queryRunner = this.createQueryRunner("master");
|
|
225
226
|
const { version, database } = await queryRunner.getDatabaseAndVersion();
|
|
226
227
|
this.version = version;
|
|
@@ -245,7 +246,39 @@ class SapDriver {
|
|
|
245
246
|
throw new __1.ConnectionIsNotSetError("sap");
|
|
246
247
|
}
|
|
247
248
|
this.master = undefined;
|
|
248
|
-
|
|
249
|
+
try {
|
|
250
|
+
await (0, node_util_1.promisify)(pool.clear).call(pool);
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
this.poolErrorHandler(error);
|
|
254
|
+
throw error;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Obtains a new database connection to a master server.
|
|
259
|
+
* Used for replication.
|
|
260
|
+
* If replication is not setup then returns default connection's database connection.
|
|
261
|
+
*/
|
|
262
|
+
async obtainMasterConnection() {
|
|
263
|
+
const pool = this.master;
|
|
264
|
+
if (!pool) {
|
|
265
|
+
throw new TypeORMError_1.TypeORMError("Driver not Connected");
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
return await (0, node_util_1.promisify)(pool.getConnection).call(pool);
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
this.poolErrorHandler(error);
|
|
272
|
+
throw error;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Obtains a new database connection to a slave server.
|
|
277
|
+
* Used for replication.
|
|
278
|
+
* If replication is not setup then returns master (default) connection's database connection.
|
|
279
|
+
*/
|
|
280
|
+
async obtainSlaveConnection() {
|
|
281
|
+
return this.obtainMasterConnection();
|
|
249
282
|
}
|
|
250
283
|
/**
|
|
251
284
|
* Creates a schema builder used to build and sync a schema.
|
|
@@ -556,25 +589,6 @@ class SapDriver {
|
|
|
556
589
|
type += " array";
|
|
557
590
|
return type;
|
|
558
591
|
}
|
|
559
|
-
/**
|
|
560
|
-
* Obtains a new database connection to a master server.
|
|
561
|
-
* Used for replication.
|
|
562
|
-
* If replication is not setup then returns default connection's database connection.
|
|
563
|
-
*/
|
|
564
|
-
obtainMasterConnection() {
|
|
565
|
-
if (!this.master) {
|
|
566
|
-
throw new TypeORMError_1.TypeORMError("Driver not Connected");
|
|
567
|
-
}
|
|
568
|
-
return this.master.getConnection();
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
* Obtains a new database connection to a slave server.
|
|
572
|
-
* Used for replication.
|
|
573
|
-
* If replication is not setup then returns master (default) connection's database connection.
|
|
574
|
-
*/
|
|
575
|
-
obtainSlaveConnection() {
|
|
576
|
-
return this.obtainMasterConnection();
|
|
577
|
-
}
|
|
578
592
|
/**
|
|
579
593
|
* Creates generated map of values generated or returned by database after INSERT query.
|
|
580
594
|
*/
|
|
@@ -654,21 +668,16 @@ class SapDriver {
|
|
|
654
668
|
* If driver dependency is not given explicitly, then try to load it via "require".
|
|
655
669
|
*/
|
|
656
670
|
loadDependencies() {
|
|
657
|
-
|
|
658
|
-
|
|
671
|
+
const client = this.options.driver ?? this.options.hanaClientDriver;
|
|
672
|
+
if (client) {
|
|
659
673
|
this.client = client;
|
|
660
|
-
|
|
661
|
-
catch (e) {
|
|
662
|
-
// todo: better error for browser env
|
|
663
|
-
throw new DriverPackageNotInstalledError_1.DriverPackageNotInstalledError("SAP Hana", "hdb-pool");
|
|
674
|
+
return;
|
|
664
675
|
}
|
|
665
676
|
try {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
this.streamClient = PlatformTools_1.PlatformTools.load("@sap/hana-client/extension/Stream");
|
|
669
|
-
}
|
|
677
|
+
this.client = PlatformTools_1.PlatformTools.load("@sap/hana-client");
|
|
678
|
+
this.streamClient = PlatformTools_1.PlatformTools.load("@sap/hana-client/extension/Stream");
|
|
670
679
|
}
|
|
671
|
-
catch
|
|
680
|
+
catch {
|
|
672
681
|
// todo: better error for browser env
|
|
673
682
|
throw new DriverPackageNotInstalledError_1.DriverPackageNotInstalledError("SAP Hana", "@sap/hana-client");
|
|
674
683
|
}
|