typeorm 0.3.26-dev.01dddfe → 0.3.26-dev.1698313

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.
Files changed (94) hide show
  1. package/README.md +16 -1113
  2. package/browser/cache/RedisQueryResultCache.d.ts +13 -0
  3. package/browser/cache/RedisQueryResultCache.js +105 -38
  4. package/browser/cache/RedisQueryResultCache.js.map +1 -1
  5. package/browser/driver/aurora-mysql/AuroraMysqlQueryRunner.js +1 -1
  6. package/browser/driver/aurora-mysql/AuroraMysqlQueryRunner.js.map +1 -1
  7. package/browser/driver/cockroachdb/CockroachDriver.js +2 -2
  8. package/browser/driver/cockroachdb/CockroachDriver.js.map +1 -1
  9. package/browser/driver/cockroachdb/CockroachQueryRunner.js +4 -4
  10. package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
  11. package/browser/driver/mongodb/MongoConnectionOptions.d.ts +9 -9
  12. package/browser/driver/mongodb/MongoConnectionOptions.js.map +1 -1
  13. package/browser/driver/mysql/MysqlDriver.js +3 -1
  14. package/browser/driver/mysql/MysqlDriver.js.map +1 -1
  15. package/browser/driver/mysql/MysqlQueryRunner.js +3 -3
  16. package/browser/driver/mysql/MysqlQueryRunner.js.map +1 -1
  17. package/browser/driver/oracle/OracleQueryRunner.js +1 -1
  18. package/browser/driver/oracle/OracleQueryRunner.js.map +1 -1
  19. package/browser/driver/postgres/PostgresDriver.js +2 -2
  20. package/browser/driver/postgres/PostgresDriver.js.map +1 -1
  21. package/browser/driver/postgres/PostgresQueryRunner.js +5 -5
  22. package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
  23. package/browser/driver/sap/SapConnectionOptions.d.ts +33 -8
  24. package/browser/driver/sap/SapConnectionOptions.js.map +1 -1
  25. package/browser/driver/sap/SapDriver.d.ts +20 -21
  26. package/browser/driver/sap/SapDriver.js +86 -77
  27. package/browser/driver/sap/SapDriver.js.map +1 -1
  28. package/browser/driver/sap/SapQueryRunner.js +37 -26
  29. package/browser/driver/sap/SapQueryRunner.js.map +1 -1
  30. package/browser/driver/spanner/SpannerQueryRunner.js +3 -3
  31. package/browser/driver/spanner/SpannerQueryRunner.js.map +1 -1
  32. package/browser/driver/sqlserver/SqlServerQueryRunner.js +1 -1
  33. package/browser/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
  34. package/browser/error/DriverPackageNotInstalledError.js +1 -2
  35. package/browser/error/DriverPackageNotInstalledError.js.map +1 -1
  36. package/browser/metadata-builder/EntityMetadataBuilder.js +8 -1
  37. package/browser/metadata-builder/EntityMetadataBuilder.js.map +1 -1
  38. package/browser/platform/BrowserPlatformTools.js +7 -3
  39. package/browser/platform/BrowserPlatformTools.js.map +1 -1
  40. package/browser/platform/PlatformTools.js +0 -2
  41. package/browser/platform/PlatformTools.js.map +1 -1
  42. package/browser/query-builder/QueryExpressionMap.js +1 -0
  43. package/browser/query-builder/QueryExpressionMap.js.map +1 -1
  44. package/browser/query-builder/SelectQueryBuilder.d.ts +1 -0
  45. package/browser/query-builder/SelectQueryBuilder.js +43 -5
  46. package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
  47. package/browser/repository/SaveOptions.d.ts +1 -1
  48. package/browser/repository/SaveOptions.js.map +1 -1
  49. package/cache/RedisQueryResultCache.d.ts +13 -0
  50. package/cache/RedisQueryResultCache.js +105 -38
  51. package/cache/RedisQueryResultCache.js.map +1 -1
  52. package/driver/aurora-mysql/AuroraMysqlQueryRunner.js +1 -1
  53. package/driver/aurora-mysql/AuroraMysqlQueryRunner.js.map +1 -1
  54. package/driver/cockroachdb/CockroachDriver.js +2 -2
  55. package/driver/cockroachdb/CockroachDriver.js.map +1 -1
  56. package/driver/cockroachdb/CockroachQueryRunner.js +4 -4
  57. package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
  58. package/driver/mongodb/MongoConnectionOptions.d.ts +9 -9
  59. package/driver/mongodb/MongoConnectionOptions.js.map +1 -1
  60. package/driver/mysql/MysqlDriver.js +3 -1
  61. package/driver/mysql/MysqlDriver.js.map +1 -1
  62. package/driver/mysql/MysqlQueryRunner.js +3 -3
  63. package/driver/mysql/MysqlQueryRunner.js.map +1 -1
  64. package/driver/oracle/OracleQueryRunner.js +1 -1
  65. package/driver/oracle/OracleQueryRunner.js.map +1 -1
  66. package/driver/postgres/PostgresDriver.js +2 -2
  67. package/driver/postgres/PostgresDriver.js.map +1 -1
  68. package/driver/postgres/PostgresQueryRunner.js +5 -5
  69. package/driver/postgres/PostgresQueryRunner.js.map +1 -1
  70. package/driver/sap/SapConnectionOptions.d.ts +33 -8
  71. package/driver/sap/SapConnectionOptions.js.map +1 -1
  72. package/driver/sap/SapDriver.d.ts +20 -21
  73. package/driver/sap/SapDriver.js +86 -77
  74. package/driver/sap/SapDriver.js.map +1 -1
  75. package/driver/sap/SapQueryRunner.js +42 -31
  76. package/driver/sap/SapQueryRunner.js.map +1 -1
  77. package/driver/spanner/SpannerQueryRunner.js +3 -3
  78. package/driver/spanner/SpannerQueryRunner.js.map +1 -1
  79. package/driver/sqlserver/SqlServerQueryRunner.js +1 -1
  80. package/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
  81. package/error/DriverPackageNotInstalledError.js +1 -2
  82. package/error/DriverPackageNotInstalledError.js.map +1 -1
  83. package/metadata-builder/EntityMetadataBuilder.js +8 -1
  84. package/metadata-builder/EntityMetadataBuilder.js.map +1 -1
  85. package/package.json +1 -1
  86. package/platform/PlatformTools.js +0 -2
  87. package/platform/PlatformTools.js.map +1 -1
  88. package/query-builder/QueryExpressionMap.js +1 -0
  89. package/query-builder/QueryExpressionMap.js.map +1 -1
  90. package/query-builder/SelectQueryBuilder.d.ts +1 -0
  91. package/query-builder/SelectQueryBuilder.js +43 -5
  92. package/query-builder/SelectQueryBuilder.js.map +1 -1
  93. package/repository/SaveOptions.d.ts +1 -1
  94. package/repository/SaveOptions.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/platform/PlatformTools.ts"],"names":[],"mappings":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AM,CAAC,GAAG,CAAC,OAAe;QACtB,OAAO,CAAC,GAAG,CAAC,eAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IACxC,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,IAAS;QACjB,OAAO,eAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAU;QACnB,OAAO,eAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAC1B,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,OAAe;QACvB,OAAO,eAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC/B,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,MAAc,EAAE,GAAS;QACtC,OAAO,CAAC,GAAG,CAAC,eAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;QACrC,IAAI,GAAG;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC;;AAxQL,sCAyQC;AAxQG;;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":["../../src/platform/PlatformTools.ts"],"names":[],"mappings":";;;;AAAA,0DAAwB;AACxB,4DAA2B;AAC3B,oDAAmB;AACnB,wDAAuB;AACvB,iDAAyC;AACzC,mDAAyD;AAIzD,iCAAqC;AAA5B,sGAAA,YAAY,OAAA;AACrB,yBAA+B;AAAtB,gGAAA,UAAU,OAAA;AACnB,iCAA2C;AAAlC,kGAAA,QAAQ,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAE3B;;GAEG;AACH,MAAa,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,kBAAkB;oBACnB,OAAO,OAAO,CAAC,kBAAkB,CAAC,C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C,GAAG,CAAC,eAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAA;IAClD,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,MAAc,EAAE,KAAU;QACtC,OAAO,CAAC,GAAG,CAAC,eAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAA;IAClD,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,MAAc,EAAE,OAAY;QACvC,OAAO,CAAC,GAAG,CAAC,eAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAA;IACvD,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,OAAe;QACtB,OAAO,CAAC,GAAG,CAAC,eAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IACxC,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,IAAS;QACjB,OAAO,eAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAU;QACnB,OAAO,eAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAC1B,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,OAAe;QACvB,OAAO,eAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC/B,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,MAAc,EAAE,GAAS;QACtC,OAAO,CAAC,GAAG,CAAC,eAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;QACrC,IAAI,GAAG;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC;;AArQL,sCAsQC;AArQG;;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 /**\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":".."}
@@ -289,6 +289,7 @@ class QueryExpressionMap {
289
289
  map.offset = this.offset;
290
290
  map.skip = this.skip;
291
291
  map.take = this.take;
292
+ map.useIndex = this.useIndex;
292
293
  map.lockMode = this.lockMode;
293
294
  map.onLocked = this.onLocked;
294
295
  map.lockVersion = this.lockVersion;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/query-builder/QueryExpressionMap.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAG/B,mDAA+C;AAG/C,2EAAuE;AACvE,oFAAgF;AAOhF,oCAAuC;AAKvC;;GAEG;AACH,MAAa,kBAAkB;IA4U3B,4EAA4E;IAC5E,cAAc;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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;AAthBD,gDAshBC","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":["../../src/query-builder/QueryExpressionMap.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAG/B,mDAA+C;AAG/C,2EAAuE;AACvE,oFAAgF;AAOhF,oCAAuC;AAKvC;;GAEG;AACH,MAAa,kBAAkB;IA4U3B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAsB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QA/U5C,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,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;AAvhBD,gDAuhBC","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":".."}
@@ -588,6 +588,7 @@ export declare class SelectQueryBuilder<Entity extends ObjectLiteral> extends Qu
588
588
  * This method is useful to build pagination.
589
589
  */
590
590
  getManyAndCount(): Promise<[Entity[], number]>;
591
+ private lazyCount;
591
592
  /**
592
593
  * Executes built SQL query and returns raw data stream.
593
594
  */
@@ -849,11 +849,16 @@ class SelectQueryBuilder extends QueryBuilder_1.QueryBuilder {
849
849
  this.expressionMap.queryEntity = true;
850
850
  const entitiesAndRaw = await this.executeEntitiesAndRawResults(queryRunner);
851
851
  this.expressionMap.queryEntity = false;
852
- const cacheId = this.expressionMap.cacheId;
853
- // Creates a new cacheId for the count query, or it will retreive the above query results
854
- // and count will return 0.
855
- this.expressionMap.cacheId = cacheId ? `${cacheId}-count` : cacheId;
856
- const count = await this.executeCountQuery(queryRunner);
852
+ let count = this.lazyCount(entitiesAndRaw);
853
+ if (count === undefined) {
854
+ const cacheId = this.expressionMap.cacheId;
855
+ // Creates a new cacheId for the count query, or it will retrieve the above query results
856
+ // and count will return 0.
857
+ if (cacheId) {
858
+ this.expressionMap.cacheId = `${cacheId}-count`;
859
+ }
860
+ count = await this.executeCountQuery(queryRunner);
861
+ }
857
862
  const results = [entitiesAndRaw.entities, count];
858
863
  // close transaction if we started it
859
864
  if (transactionStartedByUs) {
@@ -877,6 +882,39 @@ class SelectQueryBuilder extends QueryBuilder_1.QueryBuilder {
877
882
  await queryRunner.release();
878
883
  }
879
884
  }
885
+ lazyCount(entitiesAndRaw) {
886
+ const hasLimit = this.expressionMap.limit !== undefined &&
887
+ this.expressionMap.limit !== null;
888
+ if (this.expressionMap.joinAttributes.length > 0 && hasLimit) {
889
+ return undefined;
890
+ }
891
+ const hasTake = this.expressionMap.take !== undefined &&
892
+ this.expressionMap.take !== null;
893
+ // limit overrides take when no join is defined
894
+ const maxResults = hasLimit
895
+ ? this.expressionMap.limit
896
+ : hasTake
897
+ ? this.expressionMap.take
898
+ : undefined;
899
+ if (maxResults !== undefined &&
900
+ entitiesAndRaw.entities.length === maxResults) {
901
+ // stop here when the result set contains the max number of rows; we need to execute a full count
902
+ return undefined;
903
+ }
904
+ const hasSkip = this.expressionMap.skip !== undefined &&
905
+ this.expressionMap.skip !== null &&
906
+ this.expressionMap.skip > 0;
907
+ const hasOffset = this.expressionMap.offset !== undefined &&
908
+ this.expressionMap.offset !== null &&
909
+ this.expressionMap.offset > 0;
910
+ // offset overrides skip when no join is defined
911
+ const previousResults = hasOffset
912
+ ? this.expressionMap.offset
913
+ : hasSkip
914
+ ? this.expressionMap.skip
915
+ : 0;
916
+ return entitiesAndRaw.entities.length + previousResults;
917
+ }
880
918
  /**
881
919
  * Executes built SQL query and returns raw data stream.
882
920
  */