typeorm 0.3.7-dev.ec05f1d → 0.3.8-dev.0b54222

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 (33) hide show
  1. package/browser/driver/better-sqlite3/BetterSqlite3ConnectionOptions.d.ts +4 -0
  2. package/browser/driver/better-sqlite3/BetterSqlite3ConnectionOptions.js.map +1 -1
  3. package/browser/driver/better-sqlite3/BetterSqlite3Driver.d.ts +1 -1
  4. package/browser/driver/better-sqlite3/BetterSqlite3Driver.js +4 -3
  5. package/browser/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
  6. package/browser/driver/oracle/OracleConnectionOptions.d.ts +1 -1
  7. package/browser/driver/oracle/OracleConnectionOptions.js.map +1 -1
  8. package/browser/driver/postgres/PostgresConnectionOptions.d.ts +1 -1
  9. package/browser/driver/postgres/PostgresConnectionOptions.js.map +1 -1
  10. package/browser/driver/sap/SapQueryRunner.d.ts +7 -0
  11. package/browser/driver/sap/SapQueryRunner.js +24 -2
  12. package/browser/driver/sap/SapQueryRunner.js.map +1 -1
  13. package/browser/driver/sqlserver/SqlServerConnectionOptions.d.ts +1 -1
  14. package/browser/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -1
  15. package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.js +2 -1
  16. package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
  17. package/driver/better-sqlite3/BetterSqlite3ConnectionOptions.d.ts +4 -0
  18. package/driver/better-sqlite3/BetterSqlite3ConnectionOptions.js.map +1 -1
  19. package/driver/better-sqlite3/BetterSqlite3Driver.d.ts +1 -1
  20. package/driver/better-sqlite3/BetterSqlite3Driver.js +6 -5
  21. package/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
  22. package/driver/oracle/OracleConnectionOptions.d.ts +1 -1
  23. package/driver/oracle/OracleConnectionOptions.js.map +1 -1
  24. package/driver/postgres/PostgresConnectionOptions.d.ts +1 -1
  25. package/driver/postgres/PostgresConnectionOptions.js.map +1 -1
  26. package/driver/sap/SapQueryRunner.d.ts +7 -0
  27. package/driver/sap/SapQueryRunner.js +24 -2
  28. package/driver/sap/SapQueryRunner.js.map +1 -1
  29. package/driver/sqlserver/SqlServerConnectionOptions.d.ts +1 -1
  30. package/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -1
  31. package/package.json +1 -1
  32. package/query-builder/transformer/RawSqlResultsToEntityTransformer.js +2 -1
  33. package/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
@@ -118,7 +118,7 @@ export interface SqlServerConnectionOptions extends BaseDataSourceOptions, SqlSe
118
118
  */
119
119
  readonly packetSize?: number;
120
120
  /**
121
- * A boolean determining whether to pass time values in UTC or local time. (default: true).
121
+ * A boolean determining whether to pass time values in UTC or local time. (default: false).
122
122
  */
123
123
  readonly useUTC?: boolean;
124
124
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/driver/sqlserver/SqlServerConnectionOptions.ts"],"names":[],"mappings":"","file":"SqlServerConnectionOptions.js","sourcesContent":["import { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\nimport { SqlServerConnectionCredentialsOptions } from \"./SqlServerConnectionCredentialsOptions\"\n\n/**\n * Microsoft Sql Server specific connection options.\n */\nexport interface SqlServerConnectionOptions\n extends BaseDataSourceOptions,\n SqlServerConnectionCredentialsOptions {\n /**\n * Database type.\n */\n readonly type: \"mssql\"\n\n /**\n * Connection timeout in ms (default: 15000).\n */\n readonly connectionTimeout?: number\n\n /**\n * Request timeout in ms (default: 15000). NOTE: msnodesqlv8 driver doesn't support timeouts < 1 second.\n */\n readonly requestTimeout?: number\n\n /**\n * Stream recordsets/rows instead of returning them all at once as an argument of callback (default: false).\n * You can also enable streaming for each request independently (request.stream = true).\n * Always set to true if you plan to work with large amount of rows.\n */\n readonly stream?: boolean\n\n /**\n * Database schema.\n */\n readonly schema?: string\n\n /**\n * The driver object\n * This defaults to `require(\"mssql\")`\n */\n readonly driver?: any\n\n /**\n * An optional object/dictionary with the any of the properties\n */\n readonly pool?: {\n /**\n * Maximum number of resources to create at any given time. (default=1)\n */\n readonly max?: number\n\n /**\n * Minimum number of resources to keep in pool at any given time. If this is set >= max, the pool will silently\n * set the min to equal max. (default=0)\n */\n readonly min?: number\n\n /**\n * Maximum number of queued requests allowed, additional acquire calls will be callback with an err in a future\n * cycle of the event loop.\n */\n readonly maxWaitingClients?: number\n\n /**\n * Should the pool validate resources before giving them to clients. Requires that either factory.validate or\n * factory.validateAsync to be specified\n */\n readonly testOnBorrow?: boolean\n\n /**\n * Max milliseconds an acquire call will wait for a resource before timing out. (default no limit), if supplied should non-zero positive integer.\n */\n readonly acquireTimeoutMillis?: number\n\n /**\n * If true the oldest resources will be first to be allocated. If false the most recently released resources will\n * be the first to be allocated. This in effect turns the pool's behaviour from a queue into a stack. boolean,\n * (default true)\n */\n readonly fifo?: boolean\n\n /**\n * Int between 1 and x - if set, borrowers can specify their relative priority in the queue if no resources\n * are available. see example. (default 1)\n */\n readonly priorityRange?: number\n\n /**\n * How often to run eviction checks. Default: 0 (does not run).\n */\n readonly evictionRunIntervalMillis?: number\n\n /**\n * Number of resources to check each eviction run. Default: 3.\n */\n readonly numTestsPerRun?: number\n\n /**\n * Amount of time an object may sit idle in the pool before it is eligible for eviction by the idle object\n * evictor (if any), with the extra condition that at least \"min idle\" object instances remain in the pool.\n * Default -1 (nothing can get evicted)\n */\n readonly softIdleTimeoutMillis?: number\n\n /**\n * The minimum amount of time that an object may sit idle in the pool before it is eligible for eviction due\n * to idle time. Supercedes softIdleTimeoutMillis Default: 30000\n */\n readonly idleTimeoutMillis?: number\n\n /*\n * Function handling errors thrown by drivers pool.\n * Defaults to logging error with `warn` level.\n */\n readonly errorHandler?: (err: any) => any\n }\n\n /**\n * Extra options\n */\n readonly options?: {\n /**\n * By default, if the database requestion by options.database cannot be accessed, the connection will fail with\n * an error. However, if options.fallbackToDefaultDb is set to true, then the user's default database will\n * be used instead (Default: false).\n */\n readonly fallbackToDefaultDb?: boolean\n\n /**\n * If true, SET ANSI_NULL_DFLT_ON ON will be set in the initial sql. This means new columns will be nullable by\n * default. See the T-SQL documentation for more details. (Default: true).\n */\n readonly enableAnsiNullDefault?: boolean\n\n /**\n * The number of milliseconds before the attempt to connect is considered failed (default: 15000).\n */\n readonly connectTimeout?: number\n\n /**\n * The number of milliseconds before the cancel (abort) of a request is considered failed (default: 5000).\n */\n readonly cancelTimeout?: number\n\n /**\n * The size of TDS packets (subject to negotiation with the server). Should be a power of 2. (default: 4096).\n */\n readonly packetSize?: number\n\n /**\n * A boolean determining whether to pass time values in UTC or local time. (default: true).\n */\n readonly useUTC?: boolean\n\n /**\n * A boolean determining whether to rollback a transaction automatically if any error is encountered during\n * the given transaction's execution. This sets the value for SET XACT_ABORT during the initial SQL phase\n * of a connection (documentation).\n */\n readonly abortTransactionOnError?: boolean\n\n /**\n * A string indicating which network interface (ip address) to use when connecting to SQL Server.\n */\n readonly localAddress?: string\n\n /**\n * A boolean determining whether to return rows as arrays or key-value collections. (default: false).\n */\n readonly useColumnNames?: boolean\n\n /**\n * A boolean, controlling whether the column names returned will have the first letter converted to lower case\n * (true) or not. This value is ignored if you provide a columnNameReplacer. (default: false).\n */\n readonly camelCaseColumns?: boolean\n\n /**\n * A boolean, controlling whatever to disable RETURNING / OUTPUT statements.\n */\n readonly disableOutputReturning?: boolean\n\n /**\n * Debug options\n */\n readonly debug?: {\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet details\n * (default: false).\n */\n readonly packet?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet data details\n * (default: false).\n */\n readonly data?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet payload details\n * (default: false).\n */\n readonly payload?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing token stream tokens\n * (default: false).\n */\n readonly token?: boolean\n }\n\n /**\n * The default isolation level that transactions will be run with. The isolation levels are available\n * from require('tedious').ISOLATION_LEVEL. (default: READ_COMMITTED).\n */\n readonly isolation?:\n | \"READ_UNCOMMITTED\"\n | \"READ_COMMITTED\"\n | \"REPEATABLE_READ\"\n | \"SERIALIZABLE\"\n | \"SNAPSHOT\"\n\n /**\n * The default isolation level for new connections. All out-of-transaction queries are executed with this\n * setting. The isolation levels are available from require('tedious').ISOLATION_LEVEL .\n */\n readonly connectionIsolationLevel?:\n | \"READ_UNCOMMITTED\"\n | \"READ_COMMITTED\"\n | \"REPEATABLE_READ\"\n | \"SERIALIZABLE\"\n | \"SNAPSHOT\"\n\n /**\n * A boolean, determining whether the connection will request read only access from a SQL Server\n * Availability Group. For more information, see here. (default: false).\n */\n readonly readOnlyIntent?: boolean\n\n /**\n * A boolean determining whether or not the connection will be encrypted. Set to true if you're on\n * Windows Azure. (default: false).\n */\n readonly encrypt?: boolean\n\n /**\n * When encryption is used, an object may be supplied that will be used for the first argument when calling\n * tls.createSecurePair (default: {}).\n */\n readonly cryptoCredentialsDetails?: any\n\n /**\n * A boolean, that when true will expose received rows in Requests' done* events. See done, doneInProc and\n * doneProc. (default: false)\n * Caution: If many row are received, enabling this option could result in excessive memory usage.\n */\n readonly rowCollectionOnDone?: boolean\n\n /**\n * A boolean, that when true will expose received rows in Requests' completion callback. See new Request. (default: false)\n * Caution: If many row are received, enabling this option could result in excessive memory usage.\n */\n readonly rowCollectionOnRequestCompletion?: boolean\n\n /**\n * The version of TDS to use. If server doesn't support specified version, negotiated version is used instead.\n * The versions are available from require('tedious').TDS_VERSION. (default: 7_4).\n */\n readonly tdsVersion?: string\n\n /**\n * A boolean, that when true will abort a query when an overflow or divide-by-zero error occurs during query execution.\n */\n readonly enableArithAbort?: boolean\n }\n\n /**\n * Replication setup.\n */\n readonly replication?: {\n /**\n * Master server used by orm to perform writes.\n */\n readonly master: SqlServerConnectionCredentialsOptions\n\n /**\n * List of read-from severs (slaves).\n */\n readonly slaves: SqlServerConnectionCredentialsOptions[]\n }\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../browser/src/driver/sqlserver/SqlServerConnectionOptions.ts"],"names":[],"mappings":"","file":"SqlServerConnectionOptions.js","sourcesContent":["import { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\nimport { SqlServerConnectionCredentialsOptions } from \"./SqlServerConnectionCredentialsOptions\"\n\n/**\n * Microsoft Sql Server specific connection options.\n */\nexport interface SqlServerConnectionOptions\n extends BaseDataSourceOptions,\n SqlServerConnectionCredentialsOptions {\n /**\n * Database type.\n */\n readonly type: \"mssql\"\n\n /**\n * Connection timeout in ms (default: 15000).\n */\n readonly connectionTimeout?: number\n\n /**\n * Request timeout in ms (default: 15000). NOTE: msnodesqlv8 driver doesn't support timeouts < 1 second.\n */\n readonly requestTimeout?: number\n\n /**\n * Stream recordsets/rows instead of returning them all at once as an argument of callback (default: false).\n * You can also enable streaming for each request independently (request.stream = true).\n * Always set to true if you plan to work with large amount of rows.\n */\n readonly stream?: boolean\n\n /**\n * Database schema.\n */\n readonly schema?: string\n\n /**\n * The driver object\n * This defaults to `require(\"mssql\")`\n */\n readonly driver?: any\n\n /**\n * An optional object/dictionary with the any of the properties\n */\n readonly pool?: {\n /**\n * Maximum number of resources to create at any given time. (default=1)\n */\n readonly max?: number\n\n /**\n * Minimum number of resources to keep in pool at any given time. If this is set >= max, the pool will silently\n * set the min to equal max. (default=0)\n */\n readonly min?: number\n\n /**\n * Maximum number of queued requests allowed, additional acquire calls will be callback with an err in a future\n * cycle of the event loop.\n */\n readonly maxWaitingClients?: number\n\n /**\n * Should the pool validate resources before giving them to clients. Requires that either factory.validate or\n * factory.validateAsync to be specified\n */\n readonly testOnBorrow?: boolean\n\n /**\n * Max milliseconds an acquire call will wait for a resource before timing out. (default no limit), if supplied should non-zero positive integer.\n */\n readonly acquireTimeoutMillis?: number\n\n /**\n * If true the oldest resources will be first to be allocated. If false the most recently released resources will\n * be the first to be allocated. This in effect turns the pool's behaviour from a queue into a stack. boolean,\n * (default true)\n */\n readonly fifo?: boolean\n\n /**\n * Int between 1 and x - if set, borrowers can specify their relative priority in the queue if no resources\n * are available. see example. (default 1)\n */\n readonly priorityRange?: number\n\n /**\n * How often to run eviction checks. Default: 0 (does not run).\n */\n readonly evictionRunIntervalMillis?: number\n\n /**\n * Number of resources to check each eviction run. Default: 3.\n */\n readonly numTestsPerRun?: number\n\n /**\n * Amount of time an object may sit idle in the pool before it is eligible for eviction by the idle object\n * evictor (if any), with the extra condition that at least \"min idle\" object instances remain in the pool.\n * Default -1 (nothing can get evicted)\n */\n readonly softIdleTimeoutMillis?: number\n\n /**\n * The minimum amount of time that an object may sit idle in the pool before it is eligible for eviction due\n * to idle time. Supercedes softIdleTimeoutMillis Default: 30000\n */\n readonly idleTimeoutMillis?: number\n\n /*\n * Function handling errors thrown by drivers pool.\n * Defaults to logging error with `warn` level.\n */\n readonly errorHandler?: (err: any) => any\n }\n\n /**\n * Extra options\n */\n readonly options?: {\n /**\n * By default, if the database requestion by options.database cannot be accessed, the connection will fail with\n * an error. However, if options.fallbackToDefaultDb is set to true, then the user's default database will\n * be used instead (Default: false).\n */\n readonly fallbackToDefaultDb?: boolean\n\n /**\n * If true, SET ANSI_NULL_DFLT_ON ON will be set in the initial sql. This means new columns will be nullable by\n * default. See the T-SQL documentation for more details. (Default: true).\n */\n readonly enableAnsiNullDefault?: boolean\n\n /**\n * The number of milliseconds before the attempt to connect is considered failed (default: 15000).\n */\n readonly connectTimeout?: number\n\n /**\n * The number of milliseconds before the cancel (abort) of a request is considered failed (default: 5000).\n */\n readonly cancelTimeout?: number\n\n /**\n * The size of TDS packets (subject to negotiation with the server). Should be a power of 2. (default: 4096).\n */\n readonly packetSize?: number\n\n /**\n * A boolean determining whether to pass time values in UTC or local time. (default: false).\n */\n readonly useUTC?: boolean\n\n /**\n * A boolean determining whether to rollback a transaction automatically if any error is encountered during\n * the given transaction's execution. This sets the value for SET XACT_ABORT during the initial SQL phase\n * of a connection (documentation).\n */\n readonly abortTransactionOnError?: boolean\n\n /**\n * A string indicating which network interface (ip address) to use when connecting to SQL Server.\n */\n readonly localAddress?: string\n\n /**\n * A boolean determining whether to return rows as arrays or key-value collections. (default: false).\n */\n readonly useColumnNames?: boolean\n\n /**\n * A boolean, controlling whether the column names returned will have the first letter converted to lower case\n * (true) or not. This value is ignored if you provide a columnNameReplacer. (default: false).\n */\n readonly camelCaseColumns?: boolean\n\n /**\n * A boolean, controlling whatever to disable RETURNING / OUTPUT statements.\n */\n readonly disableOutputReturning?: boolean\n\n /**\n * Debug options\n */\n readonly debug?: {\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet details\n * (default: false).\n */\n readonly packet?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet data details\n * (default: false).\n */\n readonly data?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet payload details\n * (default: false).\n */\n readonly payload?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing token stream tokens\n * (default: false).\n */\n readonly token?: boolean\n }\n\n /**\n * The default isolation level that transactions will be run with. The isolation levels are available\n * from require('tedious').ISOLATION_LEVEL. (default: READ_COMMITTED).\n */\n readonly isolation?:\n | \"READ_UNCOMMITTED\"\n | \"READ_COMMITTED\"\n | \"REPEATABLE_READ\"\n | \"SERIALIZABLE\"\n | \"SNAPSHOT\"\n\n /**\n * The default isolation level for new connections. All out-of-transaction queries are executed with this\n * setting. The isolation levels are available from require('tedious').ISOLATION_LEVEL .\n */\n readonly connectionIsolationLevel?:\n | \"READ_UNCOMMITTED\"\n | \"READ_COMMITTED\"\n | \"REPEATABLE_READ\"\n | \"SERIALIZABLE\"\n | \"SNAPSHOT\"\n\n /**\n * A boolean, determining whether the connection will request read only access from a SQL Server\n * Availability Group. For more information, see here. (default: false).\n */\n readonly readOnlyIntent?: boolean\n\n /**\n * A boolean determining whether or not the connection will be encrypted. Set to true if you're on\n * Windows Azure. (default: false).\n */\n readonly encrypt?: boolean\n\n /**\n * When encryption is used, an object may be supplied that will be used for the first argument when calling\n * tls.createSecurePair (default: {}).\n */\n readonly cryptoCredentialsDetails?: any\n\n /**\n * A boolean, that when true will expose received rows in Requests' done* events. See done, doneInProc and\n * doneProc. (default: false)\n * Caution: If many row are received, enabling this option could result in excessive memory usage.\n */\n readonly rowCollectionOnDone?: boolean\n\n /**\n * A boolean, that when true will expose received rows in Requests' completion callback. See new Request. (default: false)\n * Caution: If many row are received, enabling this option could result in excessive memory usage.\n */\n readonly rowCollectionOnRequestCompletion?: boolean\n\n /**\n * The version of TDS to use. If server doesn't support specified version, negotiated version is used instead.\n * The versions are available from require('tedious').TDS_VERSION. (default: 7_4).\n */\n readonly tdsVersion?: string\n\n /**\n * A boolean, that when true will abort a query when an overflow or divide-by-zero error occurs during query execution.\n */\n readonly enableArithAbort?: boolean\n }\n\n /**\n * Replication setup.\n */\n readonly replication?: {\n /**\n * Master server used by orm to perform writes.\n */\n readonly master: SqlServerConnectionCredentialsOptions\n\n /**\n * List of read-from severs (slaves).\n */\n readonly slaves: SqlServerConnectionCredentialsOptions[]\n }\n}\n"],"sourceRoot":"../.."}
@@ -362,7 +362,8 @@ export class RawSqlResultsToEntityTransformer {
362
362
  }
363
363
  return OrmUtils.mergeDeep(idMap, column.createValueMap(value));
364
364
  }
365
- if (column.referencedColumn.referencedColumn) {
365
+ if (!column.isPrimary &&
366
+ column.referencedColumn.referencedColumn) {
366
367
  // if column is a relation
367
368
  value =
368
369
  column.referencedColumn.referencedColumn.createValueMap(value);
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/query-builder/transformer/RawSqlResultsToEntityTransformer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAI9C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;;GAGG;AACH,MAAM,OAAO,gCAAgC;IAOzC,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;I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R,CAAA;qBACR;iBACJ;gBAED,wEAAwE;gBACxE,IAAI,KAAK,KAAK,SAAS,EAAE;oBACrB,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;oBAEjD,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE;wBACX,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;qBACxB;yBAAM;wBACH,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;qBACtB;iBACJ;gBAED,OAAO,GAAG,CAAA;YACd,CAAC,EAAE,EAAE,CAAC,CAAA;QACV,CAAC,CACJ,CAAA;IACL,CAAC;IAED;;;;OAIG;IACK,aAAa,CAAC,QAA0B,EAAE,IAAmB;QACjE,MAAM,gBAAgB,GAAG,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;QACrE,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAA;IAC3C,CAAC;CACJ","file":"RawSqlResultsToEntityTransformer.js","sourcesContent":["import { Driver } from \"../../driver/Driver\"\nimport { RelationIdLoadResult } from \"../relation-id/RelationIdLoadResult\"\nimport { ObjectLiteral } from \"../../common/ObjectLiteral\"\nimport { ColumnMetadata } from \"../../metadata/ColumnMetadata\"\nimport { Alias } from \"../Alias\"\nimport { RelationCountLoadResult } from \"../relation-count/RelationCountLoadResult\"\nimport { RelationMetadata } from \"../../metadata/RelationMetadata\"\nimport { OrmUtils } from \"../../util/OrmUtils\"\nimport { QueryExpressionMap } from \"../QueryExpressionMap\"\nimport { EntityMetadata } from \"../../metadata/EntityMetadata\"\nimport { QueryRunner } from \"../..\"\nimport { DriverUtils } from \"../../driver/DriverUtils\"\nimport { ObjectUtils } from \"../../util/ObjectUtils\"\n\n/**\n * Transforms raw sql results returned from the database into entity object.\n * Entity is constructed based on its entity metadata.\n */\nexport class RawSqlResultsToEntityTransformer {\n /**\n * Contains a hashmap for every rawRelationIdResults given.\n * In the hashmap you will find the idMaps of a result under the hash of this.hashEntityIds for the result.\n */\n private relationIdMaps: Array<{ [idHash: string]: any[] }>\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n protected expressionMap: QueryExpressionMap,\n protected driver: Driver,\n protected rawRelationIdResults: RelationIdLoadResult[],\n protected rawRelationCountResults: RelationCountLoadResult[],\n protected queryRunner?: QueryRunner,\n ) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Since db returns a duplicated rows of the data where accuracies of the same object can be duplicated\n * we need to group our result and we must have some unique id (primary key in our case)\n */\n transform(rawResults: any[], alias: Alias): any[] {\n const group = this.group(rawResults, alias)\n const entities: any[] = []\n group.forEach((results) => {\n const entity = this.transformRawResultsGroup(results, alias)\n if (\n entity !== undefined &&\n !Object.values(entity).every((value) => value === null)\n )\n entities.push(entity)\n })\n return entities\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Groups given raw results by ids of given alias.\n */\n protected group(rawResults: any[], alias: Alias): Map<string, any[]> {\n const map = new Map()\n const keys: string[] = []\n if (alias.metadata.tableType === \"view\") {\n keys.push(\n ...alias.metadata.columns.map((column) =>\n DriverUtils.buildAlias(\n this.driver,\n alias.name,\n column.databaseName,\n ),\n ),\n )\n } else {\n keys.push(\n ...alias.metadata.primaryColumns.map((column) =>\n DriverUtils.buildAlias(\n this.driver,\n alias.name,\n column.databaseName,\n ),\n ),\n )\n }\n rawResults.forEach((rawResult) => {\n const id = keys\n .map((key) => {\n const keyValue = rawResult[key]\n\n if (Buffer.isBuffer(keyValue)) {\n return keyValue.toString(\"hex\")\n }\n\n if (ObjectUtils.isObject(keyValue)) {\n return JSON.stringify(keyValue)\n }\n\n return keyValue\n })\n .join(\"_\") // todo: check partial\n\n const items = map.get(id)\n if (!items) {\n map.set(id, [rawResult])\n } else {\n items.push(rawResult)\n }\n })\n return map\n }\n\n /**\n * Transforms set of data results into single entity.\n */\n protected transformRawResultsGroup(\n rawResults: any[],\n alias: Alias,\n ): ObjectLiteral | undefined {\n // let hasColumns = false; // , hasEmbeddedColumns = false, hasParentColumns = false, hasParentEmbeddedColumns = false;\n let metadata = alias.metadata\n\n if (metadata.discriminatorColumn) {\n const discriminatorValues = rawResults.map(\n (result) =>\n result[\n DriverUtils.buildAlias(\n this.driver,\n alias.name,\n alias.metadata.discriminatorColumn!.databaseName,\n )\n ],\n )\n const discriminatorMetadata = metadata.childEntityMetadatas.find(\n (childEntityMetadata) => {\n return (\n typeof discriminatorValues.find(\n (value) =>\n value ===\n childEntityMetadata.discriminatorValue,\n ) !== \"undefined\"\n )\n },\n )\n if (discriminatorMetadata) metadata = discriminatorMetadata\n }\n let entity: any = metadata.create(this.queryRunner, {\n fromDeserializer: true,\n pojo: this.expressionMap.options.indexOf(\"create-pojo\") !== -1,\n })\n\n // get value from columns selections and put them into newly created entity\n const hasColumns = this.transformColumns(\n rawResults,\n alias,\n entity,\n metadata,\n )\n const hasRelations = this.transformJoins(\n rawResults,\n entity,\n alias,\n metadata,\n )\n const hasRelationIds = this.transformRelationIds(\n rawResults,\n alias,\n entity,\n metadata,\n )\n const hasRelationCounts = this.transformRelationCounts(\n rawResults,\n alias,\n entity,\n )\n\n // if we have at least one selected column then return this entity\n // since entity must have at least primary columns to be really selected and transformed into entity\n if (hasColumns) return entity\n\n // if we don't have any selected column we should not return entity,\n // except for the case when entity only contain a primary column as a relation to another entity\n // in this case its absolutely possible our entity to not have any columns except a single relation\n const hasOnlyVirtualPrimaryColumns =\n metadata.primaryColumns.filter(\n (column) => column.isVirtual === false,\n ).length === 0 // todo: create metadata.hasOnlyVirtualPrimaryColumns\n if (\n hasOnlyVirtualPrimaryColumns &&\n (hasRelations || hasRelationIds || hasRelationCounts)\n )\n return entity\n\n return undefined\n }\n\n // get value from columns selections and put them into object\n protected transformColumns(\n rawResults: any[],\n alias: Alias,\n entity: ObjectLiteral,\n metadata: EntityMetadata,\n ): boolean {\n let hasData = false\n metadata.columns.forEach((column) => {\n // if table inheritance is used make sure this column is not child's column\n if (\n metadata.childEntityMetadatas.length > 0 &&\n metadata.childEntityMetadatas.findIndex(\n (childMetadata) => childMetadata.target === column.target,\n ) !== -1\n )\n return\n\n const value =\n rawResults[0][\n DriverUtils.buildAlias(\n this.driver,\n alias.name,\n column.databaseName,\n )\n ]\n if (value === undefined || column.isVirtual) return\n\n // if user does not selected the whole entity or he used partial selection and does not select this particular column\n // then we don't add this column and its value into the entity\n if (\n !this.expressionMap.selects.find(\n (select) =>\n select.selection === alias.name ||\n select.selection ===\n alias.name + \".\" + column.propertyPath,\n )\n )\n return\n\n column.setEntityValue(\n entity,\n this.driver.prepareHydratedValue(value, column),\n )\n if (value !== null)\n // we don't mark it as has data because if we will have all nulls in our object - we don't need such object\n hasData = true\n })\n return hasData\n }\n\n /**\n * Transforms joined entities in the given raw results by a given alias and stores to the given (parent) entity\n */\n protected transformJoins(\n rawResults: any[],\n entity: ObjectLiteral,\n alias: Alias,\n metadata: EntityMetadata,\n ) {\n let hasData = false\n\n // let discriminatorValue: string = \"\";\n // if (metadata.discriminatorColumn)\n // discriminatorValue = rawResults[0][DriverUtils.buildAlias(this.connection.driver, alias.name, alias.metadata.discriminatorColumn!.databaseName)];\n\n this.expressionMap.joinAttributes.forEach((join) => {\n // todo: we have problem here - when inner joins are used without selects it still create empty array\n\n // skip joins without metadata\n if (!join.metadata) return\n\n // if simple left or inner join was performed without selection then we don't need to do anything\n if (!join.isSelected) return\n\n // this check need to avoid setting properties than not belong to entity when single table inheritance used. (todo: check if we still need it)\n // const metadata = metadata.childEntityMetadatas.find(childEntityMetadata => discriminatorValue === childEntityMetadata.discriminatorValue);\n if (\n join.relation &&\n !metadata.relations.find(\n (relation) => relation === join.relation,\n )\n )\n return\n\n // some checks to make sure this join is for current alias\n if (join.mapToProperty) {\n if (join.mapToPropertyParentAlias !== alias.name) return\n } else {\n if (\n !join.relation ||\n join.parentAlias !== alias.name ||\n join.relationPropertyPath !== join.relation!.propertyPath\n )\n return\n }\n\n // transform joined data into entities\n let result: any = this.transform(rawResults, join.alias)\n result = !join.isMany ? result[0] : result\n result = !join.isMany && result === undefined ? null : result // this is needed to make relations to return null when its joined but nothing was found in the database\n if (result === undefined)\n // if nothing was joined then simply return\n return\n\n // if join was mapped to some property then save result to that property\n if (join.mapToPropertyPropertyName) {\n entity[join.mapToPropertyPropertyName] = result // todo: fix embeds\n } else {\n // otherwise set to relation\n join.relation!.setEntityValue(entity, result)\n }\n\n hasData = true\n })\n return hasData\n }\n\n protected transformRelationIds(\n rawSqlResults: any[],\n alias: Alias,\n entity: ObjectLiteral,\n metadata: EntityMetadata,\n ): boolean {\n let hasData = false\n this.rawRelationIdResults.forEach((rawRelationIdResult, index) => {\n if (\n rawRelationIdResult.relationIdAttribute.parentAlias !==\n alias.name\n )\n return\n\n const relation = rawRelationIdResult.relationIdAttribute.relation\n const valueMap = this.createValueMapFromJoinColumns(\n relation,\n rawRelationIdResult.relationIdAttribute.parentAlias,\n rawSqlResults,\n )\n if (valueMap === undefined || valueMap === null) {\n return\n }\n\n // prepare common data for this call\n this.prepareDataForTransformRelationIds()\n\n // Extract idMaps from prepared data by hash\n const hash = this.hashEntityIds(relation, valueMap)\n const idMaps = this.relationIdMaps[index][hash] || []\n\n // Map data to properties\n const properties =\n rawRelationIdResult.relationIdAttribute.mapToPropertyPropertyPath.split(\n \".\",\n )\n const mapToProperty = (\n properties: string[],\n map: ObjectLiteral,\n value: any,\n ): any => {\n const property = properties.shift()\n if (property && properties.length === 0) {\n map[property] = value\n return map\n }\n if (property && properties.length > 0) {\n mapToProperty(properties, map[property], value)\n } else {\n return map\n }\n }\n if (relation.isOneToOne || relation.isManyToOne) {\n if (idMaps[0] !== undefined) {\n mapToProperty(properties, entity, idMaps[0])\n hasData = true\n }\n } else {\n mapToProperty(properties, entity, idMaps)\n hasData = hasData || idMaps.length > 0\n }\n })\n\n return hasData\n }\n\n protected transformRelationCounts(\n rawSqlResults: any[],\n alias: Alias,\n entity: ObjectLiteral,\n ): boolean {\n let hasData = false\n this.rawRelationCountResults\n .filter(\n (rawRelationCountResult) =>\n rawRelationCountResult.relationCountAttribute\n .parentAlias === alias.name,\n )\n .forEach((rawRelationCountResult) => {\n const relation =\n rawRelationCountResult.relationCountAttribute.relation\n let referenceColumnName: string\n\n if (relation.isOneToMany) {\n referenceColumnName =\n relation.inverseRelation!.joinColumns[0]\n .referencedColumn!.databaseName // todo: fix joinColumns[0]\n } else {\n referenceColumnName = relation.isOwning\n ? relation.joinColumns[0].referencedColumn!.databaseName\n : relation.inverseRelation!.joinColumns[0]\n .referencedColumn!.databaseName\n }\n\n const referenceColumnValue =\n rawSqlResults[0][\n DriverUtils.buildAlias(\n this.driver,\n alias.name,\n referenceColumnName,\n )\n ] // we use zero index since its grouped data // todo: selection with alias for entity columns wont work\n if (\n referenceColumnValue !== undefined &&\n referenceColumnValue !== null\n ) {\n entity[\n rawRelationCountResult.relationCountAttribute.mapToPropertyPropertyName\n ] = 0\n rawRelationCountResult.results\n .filter(\n (result) =>\n result[\"parentId\"] === referenceColumnValue,\n )\n .forEach((result) => {\n entity[\n rawRelationCountResult.relationCountAttribute.mapToPropertyPropertyName\n ] = parseInt(result[\"cnt\"])\n hasData = true\n })\n }\n })\n\n return hasData\n }\n\n private createValueMapFromJoinColumns(\n relation: RelationMetadata,\n parentAlias: string,\n rawSqlResults: any[],\n ): ObjectLiteral {\n let columns: ColumnMetadata[]\n if (relation.isManyToOne || relation.isOneToOneOwner) {\n columns = relation.entityMetadata.primaryColumns.map(\n (joinColumn) => joinColumn,\n )\n } else if (relation.isOneToMany || relation.isOneToOneNotOwner) {\n columns = relation.inverseRelation!.joinColumns.map(\n (joinColumn) => joinColumn,\n )\n } else {\n if (relation.isOwning) {\n columns = relation.joinColumns.map((joinColumn) => joinColumn)\n } else {\n columns = relation.inverseRelation!.inverseJoinColumns.map(\n (joinColumn) => joinColumn,\n )\n }\n }\n return columns.reduce((valueMap, column) => {\n rawSqlResults.forEach((rawSqlResult) => {\n if (relation.isManyToOne || relation.isOneToOneOwner) {\n valueMap[column.databaseName] =\n this.driver.prepareHydratedValue(\n rawSqlResult[\n DriverUtils.buildAlias(\n this.driver,\n parentAlias,\n column.databaseName,\n )\n ],\n column,\n )\n } else {\n valueMap[column.databaseName] =\n this.driver.prepareHydratedValue(\n rawSqlResult[\n DriverUtils.buildAlias(\n this.driver,\n parentAlias,\n column.referencedColumn!.databaseName,\n )\n ],\n column,\n )\n }\n })\n return valueMap\n }, {} as ObjectLiteral)\n }\n\n private extractEntityPrimaryIds(\n relation: RelationMetadata,\n relationIdRawResult: any,\n ) {\n let columns: ColumnMetadata[]\n if (relation.isManyToOne || relation.isOneToOneOwner) {\n columns = relation.entityMetadata.primaryColumns.map(\n (joinColumn) => joinColumn,\n )\n } else if (relation.isOneToMany || relation.isOneToOneNotOwner) {\n columns = relation.inverseRelation!.joinColumns.map(\n (joinColumn) => joinColumn,\n )\n } else {\n if (relation.isOwning) {\n columns = relation.joinColumns.map((joinColumn) => joinColumn)\n } else {\n columns = relation.inverseRelation!.inverseJoinColumns.map(\n (joinColumn) => joinColumn,\n )\n }\n }\n return columns.reduce((data, column) => {\n data[column.databaseName] = relationIdRawResult[column.databaseName]\n return data\n }, {} as ObjectLiteral)\n }\n\n /*private removeVirtualColumns(entity: ObjectLiteral, alias: Alias) {\n const virtualColumns = this.expressionMap.selects\n .filter(select => select.virtual)\n .map(select => select.selection.replace(alias.name + \".\", \"\"));\n\n virtualColumns.forEach(virtualColumn => delete entity[virtualColumn]);\n }*/\n\n /** Prepare data to run #transformRelationIds, as a lot of result independent data is needed in every call */\n private prepareDataForTransformRelationIds() {\n // Return early if the relationIdMaps were already calculated\n if (this.relationIdMaps) {\n return\n }\n\n // Ensure this prepare function is only called once\n this.relationIdMaps = this.rawRelationIdResults.map(\n (rawRelationIdResult) => {\n const relation =\n rawRelationIdResult.relationIdAttribute.relation\n\n // Calculate column metadata\n let columns: ColumnMetadata[]\n if (relation.isManyToOne || relation.isOneToOneOwner) {\n columns = relation.joinColumns\n } else if (\n relation.isOneToMany ||\n relation.isOneToOneNotOwner\n ) {\n columns = relation.inverseEntityMetadata.primaryColumns\n } else {\n // ManyToMany\n if (relation.isOwning) {\n columns = relation.inverseJoinColumns\n } else {\n columns = relation.inverseRelation!.joinColumns\n }\n }\n\n // Calculate the idMaps for the rawRelationIdResult\n return rawRelationIdResult.results.reduce((agg, result) => {\n let idMap = columns.reduce((idMap, column) => {\n let value = result[column.databaseName]\n if (\n relation.isOneToMany ||\n relation.isOneToOneNotOwner\n ) {\n if (\n column.isVirtual &&\n column.referencedColumn &&\n column.referencedColumn.propertyName !==\n column.propertyName\n ) {\n // if column is a relation\n value =\n column.referencedColumn.createValueMap(\n value,\n )\n }\n\n return OrmUtils.mergeDeep(\n idMap,\n column.createValueMap(value),\n )\n }\n if (column.referencedColumn!.referencedColumn) {\n // if column is a relation\n value =\n column.referencedColumn!.referencedColumn!.createValueMap(\n value,\n )\n }\n\n return OrmUtils.mergeDeep(\n idMap,\n column.referencedColumn!.createValueMap(value),\n )\n }, {} as ObjectLiteral)\n\n if (\n columns.length === 1 &&\n !rawRelationIdResult.relationIdAttribute.disableMixedMap\n ) {\n if (\n relation.isOneToMany ||\n relation.isOneToOneNotOwner\n ) {\n idMap = columns[0].getEntityValue(idMap)\n } else {\n idMap =\n columns[0].referencedColumn!.getEntityValue(\n idMap,\n )\n }\n }\n\n // If an idMap is found, set it in the aggregator under the correct hash\n if (idMap !== undefined) {\n const hash = this.hashEntityIds(relation, result)\n\n if (agg[hash]) {\n agg[hash].push(idMap)\n } else {\n agg[hash] = [idMap]\n }\n }\n\n return agg\n }, {})\n },\n )\n }\n\n /**\n * Use a simple JSON.stringify to create a simple hash of the primary ids of an entity.\n * As this.extractEntityPrimaryIds always creates the primary id object in the same order, if the same relation is\n * given, a simple JSON.stringify should be enough to get a unique hash per entity!\n */\n private hashEntityIds(relation: RelationMetadata, data: ObjectLiteral) {\n const entityPrimaryIds = this.extractEntityPrimaryIds(relation, data)\n return JSON.stringify(entityPrimaryIds)\n }\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../browser/src/query-builder/transformer/RawSqlResultsToEntityTransformer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAI9C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;;GAGG;AACH,MAAM,OAAO,gCAAgC;IAOzC,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YACc,aAAiC,EACjC,MAAc,EACd,oBAA4C,EAC5C,uBAAkD,EAClD,WAAyB;QAJzB,kBAAa,GAAb,aAAa,CAAoB;QACjC,WAAM,GAAN,MAAM,CAAQ;QACd,yBAAoB,GAApB,oBAAoB,CAAwB;QAC5C,4BAAuB,GAAvB,uBAAuB,CAA2B;QAClD,gBAAW,GAAX,WAAW,CAAc;IACpC,CAAC;IAEJ,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;;OAGG;IACH,SAAS,CAAC,UAAiB,EAAE,KAAY;QACrC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;QAC3C,MAAM,QAAQ,GAAU,EAAE,CAAA;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACtB,MAAM,MAAM,GAAG,IAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;YAC5D,IACI,MAAM,KAAK,SAAS;gBACpB,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC;gBAEvD,QAAQ,CAAC,IA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AO,QAAQ,CAAC,SAAS,CACrB,KAAK,EACL,MAAM,CAAC,gBAAiB,CAAC,cAAc,CAAC,KAAK,CAAC,CACjD,CAAA;gBACL,CAAC,EAAE,EAAmB,CAAC,CAAA;gBAEvB,IACI,OAAO,CAAC,MAAM,KAAK,CAAC;oBACpB,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,eAAe,EAC1D;oBACE,IACI,QAAQ,CAAC,WAAW;wBACpB,QAAQ,CAAC,kBAAkB,EAC7B;wBACE,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;qBAC3C;yBAAM;wBACH,KAAK;4BACD,OAAO,CAAC,CAAC,CAAC,CAAC,gBAAiB,CAAC,cAAc,CACvC,KAAK,CACR,CAAA;qBACR;iBACJ;gBAED,wEAAwE;gBACxE,IAAI,KAAK,KAAK,SAAS,EAAE;oBACrB,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;oBAEjD,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE;wBACX,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;qBACxB;yBAAM;wBACH,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;qBACtB;iBACJ;gBAED,OAAO,GAAG,CAAA;YACd,CAAC,EAAE,EAAE,CAAC,CAAA;QACV,CAAC,CACJ,CAAA;IACL,CAAC;IAED;;;;OAIG;IACK,aAAa,CAAC,QAA0B,EAAE,IAAmB;QACjE,MAAM,gBAAgB,GAAG,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;QACrE,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAA;IAC3C,CAAC;CACJ","file":"RawSqlResultsToEntityTransformer.js","sourcesContent":["import { Driver } from \"../../driver/Driver\"\nimport { RelationIdLoadResult } from \"../relation-id/RelationIdLoadResult\"\nimport { ObjectLiteral } from \"../../common/ObjectLiteral\"\nimport { ColumnMetadata } from \"../../metadata/ColumnMetadata\"\nimport { Alias } from \"../Alias\"\nimport { RelationCountLoadResult } from \"../relation-count/RelationCountLoadResult\"\nimport { RelationMetadata } from \"../../metadata/RelationMetadata\"\nimport { OrmUtils } from \"../../util/OrmUtils\"\nimport { QueryExpressionMap } from \"../QueryExpressionMap\"\nimport { EntityMetadata } from \"../../metadata/EntityMetadata\"\nimport { QueryRunner } from \"../..\"\nimport { DriverUtils } from \"../../driver/DriverUtils\"\nimport { ObjectUtils } from \"../../util/ObjectUtils\"\n\n/**\n * Transforms raw sql results returned from the database into entity object.\n * Entity is constructed based on its entity metadata.\n */\nexport class RawSqlResultsToEntityTransformer {\n /**\n * Contains a hashmap for every rawRelationIdResults given.\n * In the hashmap you will find the idMaps of a result under the hash of this.hashEntityIds for the result.\n */\n private relationIdMaps: Array<{ [idHash: string]: any[] }>\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n protected expressionMap: QueryExpressionMap,\n protected driver: Driver,\n protected rawRelationIdResults: RelationIdLoadResult[],\n protected rawRelationCountResults: RelationCountLoadResult[],\n protected queryRunner?: QueryRunner,\n ) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Since db returns a duplicated rows of the data where accuracies of the same object can be duplicated\n * we need to group our result and we must have some unique id (primary key in our case)\n */\n transform(rawResults: any[], alias: Alias): any[] {\n const group = this.group(rawResults, alias)\n const entities: any[] = []\n group.forEach((results) => {\n const entity = this.transformRawResultsGroup(results, alias)\n if (\n entity !== undefined &&\n !Object.values(entity).every((value) => value === null)\n )\n entities.push(entity)\n })\n return entities\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Groups given raw results by ids of given alias.\n */\n protected group(rawResults: any[], alias: Alias): Map<string, any[]> {\n const map = new Map()\n const keys: string[] = []\n if (alias.metadata.tableType === \"view\") {\n keys.push(\n ...alias.metadata.columns.map((column) =>\n DriverUtils.buildAlias(\n this.driver,\n alias.name,\n column.databaseName,\n ),\n ),\n )\n } else {\n keys.push(\n ...alias.metadata.primaryColumns.map((column) =>\n DriverUtils.buildAlias(\n this.driver,\n alias.name,\n column.databaseName,\n ),\n ),\n )\n }\n rawResults.forEach((rawResult) => {\n const id = keys\n .map((key) => {\n const keyValue = rawResult[key]\n\n if (Buffer.isBuffer(keyValue)) {\n return keyValue.toString(\"hex\")\n }\n\n if (ObjectUtils.isObject(keyValue)) {\n return JSON.stringify(keyValue)\n }\n\n return keyValue\n })\n .join(\"_\") // todo: check partial\n\n const items = map.get(id)\n if (!items) {\n map.set(id, [rawResult])\n } else {\n items.push(rawResult)\n }\n })\n return map\n }\n\n /**\n * Transforms set of data results into single entity.\n */\n protected transformRawResultsGroup(\n rawResults: any[],\n alias: Alias,\n ): ObjectLiteral | undefined {\n // let hasColumns = false; // , hasEmbeddedColumns = false, hasParentColumns = false, hasParentEmbeddedColumns = false;\n let metadata = alias.metadata\n\n if (metadata.discriminatorColumn) {\n const discriminatorValues = rawResults.map(\n (result) =>\n result[\n DriverUtils.buildAlias(\n this.driver,\n alias.name,\n alias.metadata.discriminatorColumn!.databaseName,\n )\n ],\n )\n const discriminatorMetadata = metadata.childEntityMetadatas.find(\n (childEntityMetadata) => {\n return (\n typeof discriminatorValues.find(\n (value) =>\n value ===\n childEntityMetadata.discriminatorValue,\n ) !== \"undefined\"\n )\n },\n )\n if (discriminatorMetadata) metadata = discriminatorMetadata\n }\n let entity: any = metadata.create(this.queryRunner, {\n fromDeserializer: true,\n pojo: this.expressionMap.options.indexOf(\"create-pojo\") !== -1,\n })\n\n // get value from columns selections and put them into newly created entity\n const hasColumns = this.transformColumns(\n rawResults,\n alias,\n entity,\n metadata,\n )\n const hasRelations = this.transformJoins(\n rawResults,\n entity,\n alias,\n metadata,\n )\n const hasRelationIds = this.transformRelationIds(\n rawResults,\n alias,\n entity,\n metadata,\n )\n const hasRelationCounts = this.transformRelationCounts(\n rawResults,\n alias,\n entity,\n )\n\n // if we have at least one selected column then return this entity\n // since entity must have at least primary columns to be really selected and transformed into entity\n if (hasColumns) return entity\n\n // if we don't have any selected column we should not return entity,\n // except for the case when entity only contain a primary column as a relation to another entity\n // in this case its absolutely possible our entity to not have any columns except a single relation\n const hasOnlyVirtualPrimaryColumns =\n metadata.primaryColumns.filter(\n (column) => column.isVirtual === false,\n ).length === 0 // todo: create metadata.hasOnlyVirtualPrimaryColumns\n if (\n hasOnlyVirtualPrimaryColumns &&\n (hasRelations || hasRelationIds || hasRelationCounts)\n )\n return entity\n\n return undefined\n }\n\n // get value from columns selections and put them into object\n protected transformColumns(\n rawResults: any[],\n alias: Alias,\n entity: ObjectLiteral,\n metadata: EntityMetadata,\n ): boolean {\n let hasData = false\n metadata.columns.forEach((column) => {\n // if table inheritance is used make sure this column is not child's column\n if (\n metadata.childEntityMetadatas.length > 0 &&\n metadata.childEntityMetadatas.findIndex(\n (childMetadata) => childMetadata.target === column.target,\n ) !== -1\n )\n return\n\n const value =\n rawResults[0][\n DriverUtils.buildAlias(\n this.driver,\n alias.name,\n column.databaseName,\n )\n ]\n if (value === undefined || column.isVirtual) return\n\n // if user does not selected the whole entity or he used partial selection and does not select this particular column\n // then we don't add this column and its value into the entity\n if (\n !this.expressionMap.selects.find(\n (select) =>\n select.selection === alias.name ||\n select.selection ===\n alias.name + \".\" + column.propertyPath,\n )\n )\n return\n\n column.setEntityValue(\n entity,\n this.driver.prepareHydratedValue(value, column),\n )\n if (value !== null)\n // we don't mark it as has data because if we will have all nulls in our object - we don't need such object\n hasData = true\n })\n return hasData\n }\n\n /**\n * Transforms joined entities in the given raw results by a given alias and stores to the given (parent) entity\n */\n protected transformJoins(\n rawResults: any[],\n entity: ObjectLiteral,\n alias: Alias,\n metadata: EntityMetadata,\n ) {\n let hasData = false\n\n // let discriminatorValue: string = \"\";\n // if (metadata.discriminatorColumn)\n // discriminatorValue = rawResults[0][DriverUtils.buildAlias(this.connection.driver, alias.name, alias.metadata.discriminatorColumn!.databaseName)];\n\n this.expressionMap.joinAttributes.forEach((join) => {\n // todo: we have problem here - when inner joins are used without selects it still create empty array\n\n // skip joins without metadata\n if (!join.metadata) return\n\n // if simple left or inner join was performed without selection then we don't need to do anything\n if (!join.isSelected) return\n\n // this check need to avoid setting properties than not belong to entity when single table inheritance used. (todo: check if we still need it)\n // const metadata = metadata.childEntityMetadatas.find(childEntityMetadata => discriminatorValue === childEntityMetadata.discriminatorValue);\n if (\n join.relation &&\n !metadata.relations.find(\n (relation) => relation === join.relation,\n )\n )\n return\n\n // some checks to make sure this join is for current alias\n if (join.mapToProperty) {\n if (join.mapToPropertyParentAlias !== alias.name) return\n } else {\n if (\n !join.relation ||\n join.parentAlias !== alias.name ||\n join.relationPropertyPath !== join.relation!.propertyPath\n )\n return\n }\n\n // transform joined data into entities\n let result: any = this.transform(rawResults, join.alias)\n result = !join.isMany ? result[0] : result\n result = !join.isMany && result === undefined ? null : result // this is needed to make relations to return null when its joined but nothing was found in the database\n if (result === undefined)\n // if nothing was joined then simply return\n return\n\n // if join was mapped to some property then save result to that property\n if (join.mapToPropertyPropertyName) {\n entity[join.mapToPropertyPropertyName] = result // todo: fix embeds\n } else {\n // otherwise set to relation\n join.relation!.setEntityValue(entity, result)\n }\n\n hasData = true\n })\n return hasData\n }\n\n protected transformRelationIds(\n rawSqlResults: any[],\n alias: Alias,\n entity: ObjectLiteral,\n metadata: EntityMetadata,\n ): boolean {\n let hasData = false\n this.rawRelationIdResults.forEach((rawRelationIdResult, index) => {\n if (\n rawRelationIdResult.relationIdAttribute.parentAlias !==\n alias.name\n )\n return\n\n const relation = rawRelationIdResult.relationIdAttribute.relation\n const valueMap = this.createValueMapFromJoinColumns(\n relation,\n rawRelationIdResult.relationIdAttribute.parentAlias,\n rawSqlResults,\n )\n if (valueMap === undefined || valueMap === null) {\n return\n }\n\n // prepare common data for this call\n this.prepareDataForTransformRelationIds()\n\n // Extract idMaps from prepared data by hash\n const hash = this.hashEntityIds(relation, valueMap)\n const idMaps = this.relationIdMaps[index][hash] || []\n\n // Map data to properties\n const properties =\n rawRelationIdResult.relationIdAttribute.mapToPropertyPropertyPath.split(\n \".\",\n )\n const mapToProperty = (\n properties: string[],\n map: ObjectLiteral,\n value: any,\n ): any => {\n const property = properties.shift()\n if (property && properties.length === 0) {\n map[property] = value\n return map\n }\n if (property && properties.length > 0) {\n mapToProperty(properties, map[property], value)\n } else {\n return map\n }\n }\n if (relation.isOneToOne || relation.isManyToOne) {\n if (idMaps[0] !== undefined) {\n mapToProperty(properties, entity, idMaps[0])\n hasData = true\n }\n } else {\n mapToProperty(properties, entity, idMaps)\n hasData = hasData || idMaps.length > 0\n }\n })\n\n return hasData\n }\n\n protected transformRelationCounts(\n rawSqlResults: any[],\n alias: Alias,\n entity: ObjectLiteral,\n ): boolean {\n let hasData = false\n this.rawRelationCountResults\n .filter(\n (rawRelationCountResult) =>\n rawRelationCountResult.relationCountAttribute\n .parentAlias === alias.name,\n )\n .forEach((rawRelationCountResult) => {\n const relation =\n rawRelationCountResult.relationCountAttribute.relation\n let referenceColumnName: string\n\n if (relation.isOneToMany) {\n referenceColumnName =\n relation.inverseRelation!.joinColumns[0]\n .referencedColumn!.databaseName // todo: fix joinColumns[0]\n } else {\n referenceColumnName = relation.isOwning\n ? relation.joinColumns[0].referencedColumn!.databaseName\n : relation.inverseRelation!.joinColumns[0]\n .referencedColumn!.databaseName\n }\n\n const referenceColumnValue =\n rawSqlResults[0][\n DriverUtils.buildAlias(\n this.driver,\n alias.name,\n referenceColumnName,\n )\n ] // we use zero index since its grouped data // todo: selection with alias for entity columns wont work\n if (\n referenceColumnValue !== undefined &&\n referenceColumnValue !== null\n ) {\n entity[\n rawRelationCountResult.relationCountAttribute.mapToPropertyPropertyName\n ] = 0\n rawRelationCountResult.results\n .filter(\n (result) =>\n result[\"parentId\"] === referenceColumnValue,\n )\n .forEach((result) => {\n entity[\n rawRelationCountResult.relationCountAttribute.mapToPropertyPropertyName\n ] = parseInt(result[\"cnt\"])\n hasData = true\n })\n }\n })\n\n return hasData\n }\n\n private createValueMapFromJoinColumns(\n relation: RelationMetadata,\n parentAlias: string,\n rawSqlResults: any[],\n ): ObjectLiteral {\n let columns: ColumnMetadata[]\n if (relation.isManyToOne || relation.isOneToOneOwner) {\n columns = relation.entityMetadata.primaryColumns.map(\n (joinColumn) => joinColumn,\n )\n } else if (relation.isOneToMany || relation.isOneToOneNotOwner) {\n columns = relation.inverseRelation!.joinColumns.map(\n (joinColumn) => joinColumn,\n )\n } else {\n if (relation.isOwning) {\n columns = relation.joinColumns.map((joinColumn) => joinColumn)\n } else {\n columns = relation.inverseRelation!.inverseJoinColumns.map(\n (joinColumn) => joinColumn,\n )\n }\n }\n return columns.reduce((valueMap, column) => {\n rawSqlResults.forEach((rawSqlResult) => {\n if (relation.isManyToOne || relation.isOneToOneOwner) {\n valueMap[column.databaseName] =\n this.driver.prepareHydratedValue(\n rawSqlResult[\n DriverUtils.buildAlias(\n this.driver,\n parentAlias,\n column.databaseName,\n )\n ],\n column,\n )\n } else {\n valueMap[column.databaseName] =\n this.driver.prepareHydratedValue(\n rawSqlResult[\n DriverUtils.buildAlias(\n this.driver,\n parentAlias,\n column.referencedColumn!.databaseName,\n )\n ],\n column,\n )\n }\n })\n return valueMap\n }, {} as ObjectLiteral)\n }\n\n private extractEntityPrimaryIds(\n relation: RelationMetadata,\n relationIdRawResult: any,\n ) {\n let columns: ColumnMetadata[]\n if (relation.isManyToOne || relation.isOneToOneOwner) {\n columns = relation.entityMetadata.primaryColumns.map(\n (joinColumn) => joinColumn,\n )\n } else if (relation.isOneToMany || relation.isOneToOneNotOwner) {\n columns = relation.inverseRelation!.joinColumns.map(\n (joinColumn) => joinColumn,\n )\n } else {\n if (relation.isOwning) {\n columns = relation.joinColumns.map((joinColumn) => joinColumn)\n } else {\n columns = relation.inverseRelation!.inverseJoinColumns.map(\n (joinColumn) => joinColumn,\n )\n }\n }\n return columns.reduce((data, column) => {\n data[column.databaseName] = relationIdRawResult[column.databaseName]\n return data\n }, {} as ObjectLiteral)\n }\n\n /*private removeVirtualColumns(entity: ObjectLiteral, alias: Alias) {\n const virtualColumns = this.expressionMap.selects\n .filter(select => select.virtual)\n .map(select => select.selection.replace(alias.name + \".\", \"\"));\n\n virtualColumns.forEach(virtualColumn => delete entity[virtualColumn]);\n }*/\n\n /** Prepare data to run #transformRelationIds, as a lot of result independent data is needed in every call */\n private prepareDataForTransformRelationIds() {\n // Return early if the relationIdMaps were already calculated\n if (this.relationIdMaps) {\n return\n }\n\n // Ensure this prepare function is only called once\n this.relationIdMaps = this.rawRelationIdResults.map(\n (rawRelationIdResult) => {\n const relation =\n rawRelationIdResult.relationIdAttribute.relation\n\n // Calculate column metadata\n let columns: ColumnMetadata[]\n if (relation.isManyToOne || relation.isOneToOneOwner) {\n columns = relation.joinColumns\n } else if (\n relation.isOneToMany ||\n relation.isOneToOneNotOwner\n ) {\n columns = relation.inverseEntityMetadata.primaryColumns\n } else {\n // ManyToMany\n if (relation.isOwning) {\n columns = relation.inverseJoinColumns\n } else {\n columns = relation.inverseRelation!.joinColumns\n }\n }\n\n // Calculate the idMaps for the rawRelationIdResult\n return rawRelationIdResult.results.reduce((agg, result) => {\n let idMap = columns.reduce((idMap, column) => {\n let value = result[column.databaseName]\n if (\n relation.isOneToMany ||\n relation.isOneToOneNotOwner\n ) {\n if (\n column.isVirtual &&\n column.referencedColumn &&\n column.referencedColumn.propertyName !==\n column.propertyName\n ) {\n // if column is a relation\n value =\n column.referencedColumn.createValueMap(\n value,\n )\n }\n\n return OrmUtils.mergeDeep(\n idMap,\n column.createValueMap(value),\n )\n }\n if (\n !column.isPrimary &&\n column.referencedColumn!.referencedColumn\n ) {\n // if column is a relation\n value =\n column.referencedColumn!.referencedColumn!.createValueMap(\n value,\n )\n }\n\n return OrmUtils.mergeDeep(\n idMap,\n column.referencedColumn!.createValueMap(value),\n )\n }, {} as ObjectLiteral)\n\n if (\n columns.length === 1 &&\n !rawRelationIdResult.relationIdAttribute.disableMixedMap\n ) {\n if (\n relation.isOneToMany ||\n relation.isOneToOneNotOwner\n ) {\n idMap = columns[0].getEntityValue(idMap)\n } else {\n idMap =\n columns[0].referencedColumn!.getEntityValue(\n idMap,\n )\n }\n }\n\n // If an idMap is found, set it in the aggregator under the correct hash\n if (idMap !== undefined) {\n const hash = this.hashEntityIds(relation, result)\n\n if (agg[hash]) {\n agg[hash].push(idMap)\n } else {\n agg[hash] = [idMap]\n }\n }\n\n return agg\n }, {})\n },\n )\n }\n\n /**\n * Use a simple JSON.stringify to create a simple hash of the primary ids of an entity.\n * As this.extractEntityPrimaryIds always creates the primary id object in the same order, if the same relation is\n * given, a simple JSON.stringify should be enough to get a unique hash per entity!\n */\n private hashEntityIds(relation: RelationMetadata, data: ObjectLiteral) {\n const entityPrimaryIds = this.extractEntityPrimaryIds(relation, data)\n return JSON.stringify(entityPrimaryIds)\n }\n}\n"],"sourceRoot":"../.."}
@@ -52,4 +52,8 @@ export interface BetterSqlite3ConnectionOptions extends BaseDataSourceOptions {
52
52
  * Provide a function that gets called with every SQL string executed by the database connection.
53
53
  */
54
54
  readonly verbose?: Function;
55
+ /**
56
+ * Relative or absolute path to the native addon (better_sqlite3.node).
57
+ */
58
+ readonly nativeBinding?: string;
55
59
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/driver/better-sqlite3/BetterSqlite3ConnectionOptions.ts"],"names":[],"mappings":"","file":"BetterSqlite3ConnectionOptions.js","sourcesContent":["import { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\n\n/**\n * Sqlite-specific connection options.\n */\nexport interface BetterSqlite3ConnectionOptions extends BaseDataSourceOptions {\n /**\n * Database type.\n */\n readonly type: \"better-sqlite3\"\n\n /**\n * Storage type or path to the storage.\n */\n readonly database: string\n\n /**\n * The driver object\n * This defaults to require(\"better-sqlite3\")\n */\n readonly driver?: any\n\n /**\n * Encryption key for for SQLCipher.\n */\n readonly key?: string\n\n /**\n * Cache size of sqlite statement to speed up queries.\n * Default: 100.\n */\n readonly statementCacheSize?: number\n\n /**\n * Function to run before a database is used in typeorm.\n * You can set pragmas, register plugins or register\n * functions or aggregates in this function.\n */\n readonly prepareDatabase?: (db: any) => void | Promise<void>\n\n /**\n * Open the database connection in readonly mode.\n * Default: false.\n */\n readonly readonly?: boolean\n\n /**\n * If the database does not exist, an Error will be thrown instead of creating a new file.\n * This option does not affect in-memory or readonly database connections.\n * Default: false.\n */\n readonly fileMustExist?: boolean\n\n /**\n * The number of milliseconds to wait when executing queries\n * on a locked database, before throwing a SQLITE_BUSY error.\n * Default: 5000.\n */\n readonly timeout?: number\n\n /**\n * Provide a function that gets called with every SQL string executed by the database connection.\n */\n readonly verbose?: Function\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../../src/driver/better-sqlite3/BetterSqlite3ConnectionOptions.ts"],"names":[],"mappings":"","file":"BetterSqlite3ConnectionOptions.js","sourcesContent":["import { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\n\n/**\n * Sqlite-specific connection options.\n */\nexport interface BetterSqlite3ConnectionOptions extends BaseDataSourceOptions {\n /**\n * Database type.\n */\n readonly type: \"better-sqlite3\"\n\n /**\n * Storage type or path to the storage.\n */\n readonly database: string\n\n /**\n * The driver object\n * This defaults to require(\"better-sqlite3\")\n */\n readonly driver?: any\n\n /**\n * Encryption key for for SQLCipher.\n */\n readonly key?: string\n\n /**\n * Cache size of sqlite statement to speed up queries.\n * Default: 100.\n */\n readonly statementCacheSize?: number\n\n /**\n * Function to run before a database is used in typeorm.\n * You can set pragmas, register plugins or register\n * functions or aggregates in this function.\n */\n readonly prepareDatabase?: (db: any) => void | Promise<void>\n\n /**\n * Open the database connection in readonly mode.\n * Default: false.\n */\n readonly readonly?: boolean\n\n /**\n * If the database does not exist, an Error will be thrown instead of creating a new file.\n * This option does not affect in-memory or readonly database connections.\n * Default: false.\n */\n readonly fileMustExist?: boolean\n\n /**\n * The number of milliseconds to wait when executing queries\n * on a locked database, before throwing a SQLITE_BUSY error.\n * Default: 5000.\n */\n readonly timeout?: number\n\n /**\n * Provide a function that gets called with every SQL string executed by the database connection.\n */\n readonly verbose?: Function\n\n /**\n * Relative or absolute path to the native addon (better_sqlite3.node).\n */\n readonly nativeBinding?: string\n}\n"],"sourceRoot":"../.."}
@@ -1,4 +1,4 @@
1
- import { DataSource } from "../../data-source/DataSource";
1
+ import { DataSource } from "../../data-source";
2
2
  import { ColumnType } from "../types/ColumnTypes";
3
3
  import { QueryRunner } from "../../query-runner/QueryRunner";
4
4
  import { AbstractSqliteDriver } from "../sqlite-abstract/AbstractSqliteDriver";
@@ -4,8 +4,8 @@ exports.BetterSqlite3Driver = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const mkdirp_1 = tslib_1.__importDefault(require("mkdirp"));
6
6
  const path_1 = tslib_1.__importDefault(require("path"));
7
- const DriverPackageNotInstalledError_1 = require("../../error/DriverPackageNotInstalledError");
8
- const DriverOptionNotSetError_1 = require("../../error/DriverOptionNotSetError");
7
+ const error_1 = require("../../error");
8
+ const error_2 = require("../../error");
9
9
  const PlatformTools_1 = require("../../platform/PlatformTools");
10
10
  const AbstractSqliteDriver_1 = require("../sqlite-abstract/AbstractSqliteDriver");
11
11
  const BetterSqlite3QueryRunner_1 = require("./BetterSqlite3QueryRunner");
@@ -24,7 +24,7 @@ class BetterSqlite3Driver extends AbstractSqliteDriver_1.AbstractSqliteDriver {
24
24
  this.database = this.options.database;
25
25
  // validate options to make sure everything is set
26
26
  if (!this.options.database)
27
- throw new DriverOptionNotSetError_1.DriverOptionNotSetError("database");
27
+ throw new error_2.DriverOptionNotSetError("database");
28
28
  // load sqlite package
29
29
  this.loadDependencies();
30
30
  }
@@ -88,12 +88,13 @@ class BetterSqlite3Driver extends AbstractSqliteDriver_1.AbstractSqliteDriver {
88
88
  // not to create database directory if is in memory
89
89
  if (this.options.database !== ":memory:")
90
90
  await this.createDatabaseDirectory(path_1.default.dirname(this.options.database));
91
- const { database, readonly = false, fileMustExist = false, timeout = 5000, verbose = null, prepareDatabase, } = this.options;
91
+ const { database, readonly = false, fileMustExist = false, timeout = 5000, verbose = null, nativeBinding = null, prepareDatabase, } = this.options;
92
92
  const databaseConnection = this.sqlite(database, {
93
93
  readonly,
94
94
  fileMustExist,
95
95
  timeout,
96
96
  verbose,
97
+ nativeBinding,
97
98
  });
98
99
  // in the options, if encryption key for SQLCipher is setted.
99
100
  // Must invoke key pragma before trying to do any other interaction with the database.
@@ -120,7 +121,7 @@ class BetterSqlite3Driver extends AbstractSqliteDriver_1.AbstractSqliteDriver {
120
121
  this.sqlite = sqlite;
121
122
  }
122
123
  catch (e) {
123
- throw new DriverPackageNotInstalledError_1.DriverPackageNotInstalledError("SQLite", "better-sqlite3");
124
+ throw new error_1.DriverPackageNotInstalledError("SQLite", "better-sqlite3");
124
125
  }
125
126
  }
126
127
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/driver/better-sqlite3/BetterSqlite3Driver.ts"],"names":[],"mappings":";;;;AAAA,4DAA2B;AAC3B,wDAAuB;AACvB,+FAA2F;AAC3F,iFAA6E;AAC7E,gEAA4D;AAI5D,kFAA8E;AAE9E,yEAAqE;AAErE,oDAAiE;AAEjE;;GAEG;AACH,MAAa,mBAAoB,SAAQ,2CAAoB;IAezD,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAY,UAAsB;QAC9B,KAAK,CAAC,UAAU,CAAC,CAAA;QAEjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAyC,CAAA;QACnE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAA;QAErC,kDAAkD;QAClD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ;YACtB,MAAM,IAAI,iDAAuB,CAAC,UAAU,CAAC,C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{ DriverPackageNotInstalledError } from \"../../error/DriverPackageNotInstalledError\"\nimport { DriverOptionNotSetError } from \"../../error/DriverOptionNotSetError\"\nimport { PlatformTools } from \"../../platform/PlatformTools\"\nimport { DataSource } from \"../../data-source/DataSource\"\nimport { ColumnType } from \"../types/ColumnTypes\"\nimport { QueryRunner } from \"../../query-runner/QueryRunner\"\nimport { AbstractSqliteDriver } from \"../sqlite-abstract/AbstractSqliteDriver\"\nimport { BetterSqlite3ConnectionOptions } from \"./BetterSqlite3ConnectionOptions\"\nimport { BetterSqlite3QueryRunner } from \"./BetterSqlite3QueryRunner\"\nimport { ReplicationMode } from \"../types/ReplicationMode\"\nimport { filepathToName, isAbsolute } from \"../../util/PathUtils\"\n\n/**\n * Organizes communication with sqlite DBMS.\n */\nexport class BetterSqlite3Driver extends AbstractSqliteDriver {\n // -------------------------------------------------------------------------\n // Public Implemented Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection options.\n */\n options: BetterSqlite3ConnectionOptions\n\n /**\n * SQLite underlying library.\n */\n sqlite: any\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(connection: DataSource) {\n super(connection)\n\n this.connection = connection\n this.options = connection.options as BetterSqlite3ConnectionOptions\n this.database = this.options.database\n\n // validate options to make sure everything is set\n if (!this.options.database)\n throw new DriverOptionNotSetError(\"database\")\n\n // load sqlite package\n this.loadDependencies()\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Closes connection with database.\n */\n async disconnect(): Promise<void> {\n this.queryRunner = undefined\n this.databaseConnection.close()\n }\n\n /**\n * Creates a query runner used to execute database queries.\n */\n createQueryRunner(mode: ReplicationMode): QueryRunner {\n if (!this.queryRunner)\n this.queryRunner = new BetterSqlite3QueryRunner(this)\n\n return this.queryRunner\n }\n\n normalizeType(column: {\n type?: ColumnType\n length?: number | string\n precision?: number | null\n scale?: number\n }): string {\n if ((column.type as any) === Buffer) {\n return \"blob\"\n }\n\n return super.normalizeType(column)\n }\n\n async afterConnect(): Promise<void> {\n return this.attachDatabases()\n }\n\n /**\n * For SQLite, the database may be added in the decorator metadata. It will be a filepath to a database file.\n */\n buildTableName(\n tableName: string,\n _schema?: string,\n database?: string,\n ): string {\n if (!database) return tableName\n if (this.getAttachedDatabaseHandleByRelativePath(database))\n return `${this.getAttachedDatabaseHandleByRelativePath(\n database,\n )}.${tableName}`\n\n if (database === this.options.database) return tableName\n\n // we use the decorated name as supplied when deriving attach handle (ideally without non-portable absolute path)\n const identifierHash = filepathToName(database)\n // decorated name will be assumed relative to main database file when non absolute. Paths supplied as absolute won't be portable\n const absFilepath = isAbsolute(database)\n ? database\n : path.join(this.getMainDatabasePath(), database)\n\n this.attachedDatabases[database] = {\n attachFilepathAbsolute: absFilepath,\n attachFilepathRelative: database,\n attachHandle: identifierHash,\n }\n\n return `${identifierHash}.${tableName}`\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates connection with the database.\n */\n protected async createDatabaseConnection() {\n // not to create database directory if is in memory\n if (this.options.database !== \":memory:\")\n await this.createDatabaseDirectory(\n path.dirname(this.options.database),\n )\n\n const {\n database,\n readonly = false,\n fileMustExist = false,\n timeout = 5000,\n verbose = null,\n prepareDatabase,\n } = this.options\n const databaseConnection = this.sqlite(database, {\n readonly,\n fileMustExist,\n timeout,\n verbose,\n })\n // in the options, if encryption key for SQLCipher is setted.\n // Must invoke key pragma before trying to do any other interaction with the database.\n if (this.options.key) {\n databaseConnection.exec(\n `PRAGMA key = ${JSON.stringify(this.options.key)}`,\n )\n }\n\n // function to run before a database is used in typeorm.\n if (typeof prepareDatabase === \"function\") {\n prepareDatabase(databaseConnection)\n }\n\n // we need to enable foreign keys in sqlite to make sure all foreign key related features\n // working properly. this also makes onDelete to work with sqlite.\n databaseConnection.exec(`PRAGMA foreign_keys = ON`)\n\n // turn on WAL mode to enhance performance\n databaseConnection.exec(`PRAGMA journal_mode = WAL`)\n\n return databaseConnection\n }\n\n /**\n * If driver dependency is not given explicitly, then try to load it via \"require\".\n */\n protected loadDependencies(): void {\n try {\n const sqlite =\n this.options.driver || PlatformTools.load(\"better-sqlite3\")\n this.sqlite = sqlite\n } catch (e) {\n throw new DriverPackageNotInstalledError(\"SQLite\", \"better-sqlite3\")\n }\n }\n\n /**\n * Auto creates database directory if it does not exist.\n */\n protected async createDatabaseDirectory(dbPath: string): Promise<void> {\n await mkdirp(dbPath)\n }\n\n /**\n * Performs the attaching of the database files. The attachedDatabase should have been populated during calls to #buildTableName\n * during EntityMetadata production (see EntityMetadata#buildTablePath)\n *\n * https://sqlite.org/lang_attach.html\n */\n protected async attachDatabases() {\n // @todo - possibly check number of databases (but unqueriable at runtime sadly) - https://www.sqlite.org/limits.html#max_attached\n for await (const {\n attachHandle,\n attachFilepathAbsolute,\n } of Object.values(this.attachedDatabases)) {\n await this.createDatabaseDirectory(\n path.dirname(attachFilepathAbsolute),\n )\n await this.connection.query(\n `ATTACH \"${attachFilepathAbsolute}\" AS \"${attachHandle}\"`,\n )\n }\n }\n\n protected getMainDatabasePath(): string {\n const optionsDb = this.options.database\n return path.dirname(\n isAbsolute(optionsDb)\n ? optionsDb\n : path.join(this.options.baseDirectory!, optionsDb),\n )\n }\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../../src/driver/better-sqlite3/BetterSqlite3Driver.ts"],"names":[],"mappings":";;;;AAAA,4DAA2B;AAC3B,wDAAuB;AACvB,uCAA4D;AAC5D,uCAAqD;AACrD,gEAA4D;AAI5D,kFAA8E;AAE9E,yEAAqE;AAErE,oDAAiE;AAEjE;;GAEG;AACH,MAAa,mBAAoB,SAAQ,2CAAoB;IAezD,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAY,UAAsB;QAC9B,KAAK,CAAC,UAAU,CAAC,CAAA;QAEjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,UA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AAS,CAAC;YACjB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,aAAc,EAAE,SAAS,CAAC,CAC1D,CAAA;IACL,CAAC;CACJ;AA/MD,kDA+MC","file":"BetterSqlite3Driver.js","sourcesContent":["import mkdirp from \"mkdirp\"\nimport path from \"path\"\nimport { DriverPackageNotInstalledError } from \"../../error\"\nimport { DriverOptionNotSetError } from \"../../error\"\nimport { PlatformTools } from \"../../platform/PlatformTools\"\nimport { DataSource } from \"../../data-source\"\nimport { ColumnType } from \"../types/ColumnTypes\"\nimport { QueryRunner } from \"../../query-runner/QueryRunner\"\nimport { AbstractSqliteDriver } from \"../sqlite-abstract/AbstractSqliteDriver\"\nimport { BetterSqlite3ConnectionOptions } from \"./BetterSqlite3ConnectionOptions\"\nimport { BetterSqlite3QueryRunner } from \"./BetterSqlite3QueryRunner\"\nimport { ReplicationMode } from \"../types/ReplicationMode\"\nimport { filepathToName, isAbsolute } from \"../../util/PathUtils\"\n\n/**\n * Organizes communication with sqlite DBMS.\n */\nexport class BetterSqlite3Driver extends AbstractSqliteDriver {\n // -------------------------------------------------------------------------\n // Public Implemented Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection options.\n */\n options: BetterSqlite3ConnectionOptions\n\n /**\n * SQLite underlying library.\n */\n sqlite: any\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(connection: DataSource) {\n super(connection)\n\n this.connection = connection\n this.options = connection.options as BetterSqlite3ConnectionOptions\n this.database = this.options.database\n\n // validate options to make sure everything is set\n if (!this.options.database)\n throw new DriverOptionNotSetError(\"database\")\n\n // load sqlite package\n this.loadDependencies()\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Closes connection with database.\n */\n async disconnect(): Promise<void> {\n this.queryRunner = undefined\n this.databaseConnection.close()\n }\n\n /**\n * Creates a query runner used to execute database queries.\n */\n createQueryRunner(mode: ReplicationMode): QueryRunner {\n if (!this.queryRunner)\n this.queryRunner = new BetterSqlite3QueryRunner(this)\n\n return this.queryRunner\n }\n\n normalizeType(column: {\n type?: ColumnType\n length?: number | string\n precision?: number | null\n scale?: number\n }): string {\n if ((column.type as any) === Buffer) {\n return \"blob\"\n }\n\n return super.normalizeType(column)\n }\n\n async afterConnect(): Promise<void> {\n return this.attachDatabases()\n }\n\n /**\n * For SQLite, the database may be added in the decorator metadata. It will be a filepath to a database file.\n */\n buildTableName(\n tableName: string,\n _schema?: string,\n database?: string,\n ): string {\n if (!database) return tableName\n if (this.getAttachedDatabaseHandleByRelativePath(database))\n return `${this.getAttachedDatabaseHandleByRelativePath(\n database,\n )}.${tableName}`\n\n if (database === this.options.database) return tableName\n\n // we use the decorated name as supplied when deriving attach handle (ideally without non-portable absolute path)\n const identifierHash = filepathToName(database)\n // decorated name will be assumed relative to main database file when non absolute. Paths supplied as absolute won't be portable\n const absFilepath = isAbsolute(database)\n ? database\n : path.join(this.getMainDatabasePath(), database)\n\n this.attachedDatabases[database] = {\n attachFilepathAbsolute: absFilepath,\n attachFilepathRelative: database,\n attachHandle: identifierHash,\n }\n\n return `${identifierHash}.${tableName}`\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates connection with the database.\n */\n protected async createDatabaseConnection() {\n // not to create database directory if is in memory\n if (this.options.database !== \":memory:\")\n await this.createDatabaseDirectory(\n path.dirname(this.options.database),\n )\n\n const {\n database,\n readonly = false,\n fileMustExist = false,\n timeout = 5000,\n verbose = null,\n nativeBinding = null,\n prepareDatabase,\n } = this.options\n const databaseConnection = this.sqlite(database, {\n readonly,\n fileMustExist,\n timeout,\n verbose,\n nativeBinding,\n })\n // in the options, if encryption key for SQLCipher is setted.\n // Must invoke key pragma before trying to do any other interaction with the database.\n if (this.options.key) {\n databaseConnection.exec(\n `PRAGMA key = ${JSON.stringify(this.options.key)}`,\n )\n }\n\n // function to run before a database is used in typeorm.\n if (typeof prepareDatabase === \"function\") {\n prepareDatabase(databaseConnection)\n }\n\n // we need to enable foreign keys in sqlite to make sure all foreign key related features\n // working properly. this also makes onDelete to work with sqlite.\n databaseConnection.exec(`PRAGMA foreign_keys = ON`)\n\n // turn on WAL mode to enhance performance\n databaseConnection.exec(`PRAGMA journal_mode = WAL`)\n\n return databaseConnection\n }\n\n /**\n * If driver dependency is not given explicitly, then try to load it via \"require\".\n */\n protected loadDependencies(): void {\n try {\n const sqlite =\n this.options.driver || PlatformTools.load(\"better-sqlite3\")\n this.sqlite = sqlite\n } catch (e) {\n throw new DriverPackageNotInstalledError(\"SQLite\", \"better-sqlite3\")\n }\n }\n\n /**\n * Auto creates database directory if it does not exist.\n */\n protected async createDatabaseDirectory(dbPath: string): Promise<void> {\n await mkdirp(dbPath)\n }\n\n /**\n * Performs the attaching of the database files. The attachedDatabase should have been populated during calls to #buildTableName\n * during EntityMetadata production (see EntityMetadata#buildTablePath)\n *\n * https://sqlite.org/lang_attach.html\n */\n protected async attachDatabases() {\n // @todo - possibly check number of databases (but unqueriable at runtime sadly) - https://www.sqlite.org/limits.html#max_attached\n for await (const {\n attachHandle,\n attachFilepathAbsolute,\n } of Object.values(this.attachedDatabases)) {\n await this.createDatabaseDirectory(\n path.dirname(attachFilepathAbsolute),\n )\n await this.connection.query(\n `ATTACH \"${attachFilepathAbsolute}\" AS \"${attachHandle}\"`,\n )\n }\n }\n\n protected getMainDatabasePath(): string {\n const optionsDb = this.options.database\n return path.dirname(\n isAbsolute(optionsDb)\n ? optionsDb\n : path.join(this.options.baseDirectory!, optionsDb),\n )\n }\n}\n"],"sourceRoot":"../.."}
@@ -18,7 +18,7 @@ export interface OracleConnectionOptions extends BaseDataSourceOptions, OracleCo
18
18
  */
19
19
  readonly driver?: any;
20
20
  /**
21
- * A boolean determining whether to pass time values in UTC or local time. (default: true).
21
+ * A boolean determining whether to pass time values in UTC or local time. (default: false).
22
22
  */
23
23
  readonly useUTC?: boolean;
24
24
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/driver/oracle/OracleConnectionOptions.ts"],"names":[],"mappings":"","file":"OracleConnectionOptions.js","sourcesContent":["import { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\nimport { OracleConnectionCredentialsOptions } from \"./OracleConnectionCredentialsOptions\"\n\n/**\n * Oracle-specific connection options.\n */\nexport interface OracleConnectionOptions\n extends BaseDataSourceOptions,\n OracleConnectionCredentialsOptions {\n /**\n * Database type.\n */\n readonly type: \"oracle\"\n\n /**\n * Schema name. By default is \"public\".\n */\n readonly schema?: string\n\n /**\n * The driver object\n * This defaults to require(\"oracledb\")\n */\n readonly driver?: any\n\n /**\n * A boolean determining whether to pass time values in UTC or local time. (default: true).\n */\n readonly useUTC?: boolean\n\n /**\n * Replication setup.\n */\n readonly replication?: {\n /**\n * Master server used by orm to perform writes.\n */\n readonly master: OracleConnectionCredentialsOptions\n\n /**\n * List of read-from severs (slaves).\n */\n readonly slaves: OracleConnectionCredentialsOptions[]\n }\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../../src/driver/oracle/OracleConnectionOptions.ts"],"names":[],"mappings":"","file":"OracleConnectionOptions.js","sourcesContent":["import { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\nimport { OracleConnectionCredentialsOptions } from \"./OracleConnectionCredentialsOptions\"\n\n/**\n * Oracle-specific connection options.\n */\nexport interface OracleConnectionOptions\n extends BaseDataSourceOptions,\n OracleConnectionCredentialsOptions {\n /**\n * Database type.\n */\n readonly type: \"oracle\"\n\n /**\n * Schema name. By default is \"public\".\n */\n readonly schema?: string\n\n /**\n * The driver object\n * This defaults to require(\"oracledb\")\n */\n readonly driver?: any\n\n /**\n * A boolean determining whether to pass time values in UTC or local time. (default: false).\n */\n readonly useUTC?: boolean\n\n /**\n * Replication setup.\n */\n readonly replication?: {\n /**\n * Master server used by orm to perform writes.\n */\n readonly master: OracleConnectionCredentialsOptions\n\n /**\n * List of read-from severs (slaves).\n */\n readonly slaves: OracleConnectionCredentialsOptions[]\n }\n}\n"],"sourceRoot":"../.."}
@@ -23,7 +23,7 @@ export interface PostgresConnectionOptions extends BaseDataSourceOptions, Postgr
23
23
  */
24
24
  readonly nativeDriver?: any;
25
25
  /**
26
- * A boolean determining whether to pass time values in UTC or local time. (default: true).
26
+ * A boolean determining whether to pass time values in UTC or local time. (default: false).
27
27
  */
28
28
  readonly useUTC?: boolean;
29
29
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/driver/postgres/PostgresConnectionOptions.ts"],"names":[],"mappings":"","file":"PostgresConnectionOptions.js","sourcesContent":["import { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\nimport { PostgresConnectionCredentialsOptions } from \"./PostgresConnectionCredentialsOptions\"\n\n/**\n * Postgres-specific connection options.\n */\nexport interface PostgresConnectionOptions\n extends BaseDataSourceOptions,\n PostgresConnectionCredentialsOptions {\n /**\n * Database type.\n */\n readonly type: \"postgres\"\n\n /**\n * Schema name.\n */\n readonly schema?: string\n\n /**\n * The driver object\n * This defaults to `require(\"pg\")`.\n */\n readonly driver?: any\n\n /**\n * The driver object\n * This defaults to `require(\"pg-native\")`.\n */\n readonly nativeDriver?: any\n\n /**\n * A boolean determining whether to pass time values in UTC or local time. (default: true).\n */\n readonly useUTC?: boolean\n\n /**\n * Replication setup.\n */\n readonly replication?: {\n /**\n * Master server used by orm to perform writes.\n */\n readonly master: PostgresConnectionCredentialsOptions\n\n /**\n * List of read-from severs (slaves).\n */\n readonly slaves: PostgresConnectionCredentialsOptions[]\n }\n\n /**\n * The milliseconds before a timeout occurs during the initial connection to the postgres\n * server. If undefined, or set to 0, there is no timeout. Defaults to undefined.\n */\n readonly connectTimeoutMS?: number\n\n /**\n * The Postgres extension to use to generate UUID columns. Defaults to uuid-ossp.\n * If pgcrypto is selected, TypeORM will use the gen_random_uuid() function from this extension.\n * If uuid-ossp is selected, TypeORM will use the uuid_generate_v4() function from this extension.\n */\n readonly uuidExtension?: \"pgcrypto\" | \"uuid-ossp\"\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 * Include notification messages from Postgres server in client logs\n */\n readonly logNotifications?: boolean\n\n /**\n * Automatically install postgres extensions\n */\n readonly installExtensions?: boolean\n\n /**\n * sets the application_name var to help db administrators identify\n * the service using this connection. Defaults to 'undefined'\n */\n readonly applicationName?: string\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../../src/driver/postgres/PostgresConnectionOptions.ts"],"names":[],"mappings":"","file":"PostgresConnectionOptions.js","sourcesContent":["import { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\nimport { PostgresConnectionCredentialsOptions } from \"./PostgresConnectionCredentialsOptions\"\n\n/**\n * Postgres-specific connection options.\n */\nexport interface PostgresConnectionOptions\n extends BaseDataSourceOptions,\n PostgresConnectionCredentialsOptions {\n /**\n * Database type.\n */\n readonly type: \"postgres\"\n\n /**\n * Schema name.\n */\n readonly schema?: string\n\n /**\n * The driver object\n * This defaults to `require(\"pg\")`.\n */\n readonly driver?: any\n\n /**\n * The driver object\n * This defaults to `require(\"pg-native\")`.\n */\n readonly nativeDriver?: any\n\n /**\n * A boolean determining whether to pass time values in UTC or local time. (default: false).\n */\n readonly useUTC?: boolean\n\n /**\n * Replication setup.\n */\n readonly replication?: {\n /**\n * Master server used by orm to perform writes.\n */\n readonly master: PostgresConnectionCredentialsOptions\n\n /**\n * List of read-from severs (slaves).\n */\n readonly slaves: PostgresConnectionCredentialsOptions[]\n }\n\n /**\n * The milliseconds before a timeout occurs during the initial connection to the postgres\n * server. If undefined, or set to 0, there is no timeout. Defaults to undefined.\n */\n readonly connectTimeoutMS?: number\n\n /**\n * The Postgres extension to use to generate UUID columns. Defaults to uuid-ossp.\n * If pgcrypto is selected, TypeORM will use the gen_random_uuid() function from this extension.\n * If uuid-ossp is selected, TypeORM will use the uuid_generate_v4() function from this extension.\n */\n readonly uuidExtension?: \"pgcrypto\" | \"uuid-ossp\"\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 * Include notification messages from Postgres server in client logs\n */\n readonly logNotifications?: boolean\n\n /**\n * Automatically install postgres extensions\n */\n readonly installExtensions?: boolean\n\n /**\n * sets the application_name var to help db administrators identify\n * the service using this connection. Defaults to 'undefined'\n */\n readonly applicationName?: string\n}\n"],"sourceRoot":"../.."}
@@ -52,6 +52,13 @@ export declare class SapQueryRunner extends BaseQueryRunner implements QueryRunn
52
52
  * Error will be thrown if transaction was not started.
53
53
  */
54
54
  rollbackTransaction(): Promise<void>;
55
+ /**
56
+ * @description Switches on/off AUTOCOMMIT mode
57
+ * @link https://help.sap.com/docs/HANA_SERVICE_CF/7c78579ce9b14a669c1f3295b0d8ca16/d538d11053bd4f3f847ec5ce817a3d4c.html?locale=en-US
58
+ */
59
+ setAutoCommit(options: {
60
+ status: "on" | "off";
61
+ }): Promise<void>;
55
62
  /**
56
63
  * Executes a given SQL query.
57
64
  */
@@ -20,6 +20,7 @@ const QueryResult_1 = require("../../query-runner/QueryResult");
20
20
  const QueryLock_1 = require("../../query-runner/QueryLock");
21
21
  const MetadataTableType_1 = require("../types/MetadataTableType");
22
22
  const InstanceChecker_1 = require("../../util/InstanceChecker");
23
+ const util_1 = require("util");
23
24
  /**
24
25
  * Runs queries on a single SQL Server database connection.
25
26
  */
@@ -70,6 +71,11 @@ class SapQueryRunner extends BaseQueryRunner_1.BaseQueryRunner {
70
71
  throw new TransactionAlreadyStartedError_1.TransactionAlreadyStartedError();
71
72
  await this.broadcaster.broadcast("BeforeTransactionStart");
72
73
  this.isTransactionActive = true;
74
+ /**
75
+ * Disable AUTOCOMMIT while running transaction.
76
+ * Otherwise, COMMIT/ROLLBACK doesn't work in autocommit mode.
77
+ */
78
+ await this.setAutoCommit({ status: "off" });
73
79
  if (isolationLevel) {
74
80
  await this.query(`SET TRANSACTION ISOLATION LEVEL ${isolationLevel || ""}`);
75
81
  }
@@ -87,6 +93,7 @@ class SapQueryRunner extends BaseQueryRunner_1.BaseQueryRunner {
87
93
  await this.broadcaster.broadcast("BeforeTransactionCommit");
88
94
  await this.query("COMMIT");
89
95
  this.isTransactionActive = false;
96
+ await this.setAutoCommit({ status: "on" });
90
97
  await this.broadcaster.broadcast("AfterTransactionCommit");
91
98
  }
92
99
  /**
@@ -101,8 +108,25 @@ class SapQueryRunner extends BaseQueryRunner_1.BaseQueryRunner {
101
108
  await this.broadcaster.broadcast("BeforeTransactionRollback");
102
109
  await this.query("ROLLBACK");
103
110
  this.isTransactionActive = false;
111
+ await this.setAutoCommit({ status: "on" });
104
112
  await this.broadcaster.broadcast("AfterTransactionRollback");
105
113
  }
114
+ /**
115
+ * @description Switches on/off AUTOCOMMIT mode
116
+ * @link https://help.sap.com/docs/HANA_SERVICE_CF/7c78579ce9b14a669c1f3295b0d8ca16/d538d11053bd4f3f847ec5ce817a3d4c.html?locale=en-US
117
+ */
118
+ async setAutoCommit(options) {
119
+ const connection = await this.connect();
120
+ const execute = (0, util_1.promisify)(connection.exec.bind(connection));
121
+ connection.setAutoCommit(options.status === "on");
122
+ const query = `SET TRANSACTION AUTOCOMMIT DDL ${options.status.toUpperCase()};`;
123
+ try {
124
+ await execute(query);
125
+ }
126
+ catch (error) {
127
+ throw new error_1.QueryFailedError(query, [], error);
128
+ }
129
+ }
106
130
  /**
107
131
  * Executes a given SQL query.
108
132
  */
@@ -114,8 +138,6 @@ class SapQueryRunner extends BaseQueryRunner_1.BaseQueryRunner {
114
138
  const result = new QueryResult_1.QueryResult();
115
139
  try {
116
140
  const databaseConnection = await this.connect();
117
- // we disable autocommit because ROLLBACK does not work in autocommit mode
118
- databaseConnection.setAutoCommit(!this.isTransactionActive);
119
141
  this.driver.connection.logger.logQuery(query, parameters, this);
120
142
  const queryStartTime = +new Date();
121
143
  const isInsertQuery = query.substr(0, 11) === "INSERT INTO";