typeorm 0.3.16-dev.f5b93c1 → 0.3.17-dev.abb9079

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 (99) hide show
  1. package/browser/cli-ts-node-esm.js +4 -2
  2. package/browser/cli-ts-node-esm.js.map +1 -1
  3. package/browser/driver/Driver.d.ts +10 -0
  4. package/browser/driver/Driver.js.map +1 -1
  5. package/browser/driver/cockroachdb/CockroachConnectionOptions.d.ts +8 -0
  6. package/browser/driver/cockroachdb/CockroachConnectionOptions.js.map +1 -1
  7. package/browser/driver/cockroachdb/CockroachQueryRunner.d.ts +4 -0
  8. package/browser/driver/cockroachdb/CockroachQueryRunner.js +35 -18
  9. package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
  10. package/browser/driver/mongodb/MongoDriver.js +1 -1
  11. package/browser/driver/mongodb/MongoDriver.js.map +1 -1
  12. package/browser/driver/mysql/MysqlDriver.d.ts +8 -0
  13. package/browser/driver/mysql/MysqlDriver.js +30 -4
  14. package/browser/driver/mysql/MysqlDriver.js.map +1 -1
  15. package/browser/driver/oracle/OracleDriver.d.ts +13 -0
  16. package/browser/driver/oracle/OracleDriver.js +15 -0
  17. package/browser/driver/oracle/OracleDriver.js.map +1 -1
  18. package/browser/driver/oracle/OracleQueryRunner.js +4 -2
  19. package/browser/driver/oracle/OracleQueryRunner.js.map +1 -1
  20. package/browser/driver/sqlserver/SqlServerConnectionOptions.d.ts +9 -0
  21. package/browser/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -1
  22. package/browser/driver/types/ColumnTypes.d.ts +1 -1
  23. package/browser/driver/types/ColumnTypes.js.map +1 -1
  24. package/browser/metadata/EntityMetadata.d.ts +10 -1
  25. package/browser/metadata/EntityMetadata.js +33 -7
  26. package/browser/metadata/EntityMetadata.js.map +1 -1
  27. package/browser/metadata-builder/EntityMetadataBuilder.js +15 -0
  28. package/browser/metadata-builder/EntityMetadataBuilder.js.map +1 -1
  29. package/browser/metadata-builder/EntityMetadataValidator.js +12 -0
  30. package/browser/metadata-builder/EntityMetadataValidator.js.map +1 -1
  31. package/browser/metadata-builder/JunctionEntityMetadataBuilder.js +4 -0
  32. package/browser/metadata-builder/JunctionEntityMetadataBuilder.js.map +1 -1
  33. package/browser/metadata-builder/RelationJoinColumnBuilder.js +2 -0
  34. package/browser/metadata-builder/RelationJoinColumnBuilder.js.map +1 -1
  35. package/browser/persistence/EntityPersistExecutor.js +3 -11
  36. package/browser/persistence/EntityPersistExecutor.js.map +1 -1
  37. package/browser/query-builder/RelationIdLoader.d.ts +3 -1
  38. package/browser/query-builder/RelationIdLoader.js +6 -5
  39. package/browser/query-builder/RelationIdLoader.js.map +1 -1
  40. package/browser/query-builder/SelectQueryBuilder.js +19 -3
  41. package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
  42. package/browser/query-builder/transformer/PlainObjectToNewEntityTransformer.js +10 -7
  43. package/browser/query-builder/transformer/PlainObjectToNewEntityTransformer.js.map +1 -1
  44. package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.js +1 -1
  45. package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
  46. package/browser/util/DateUtils.d.ts +0 -12
  47. package/browser/util/DateUtils.js +16 -20
  48. package/browser/util/DateUtils.js.map +1 -1
  49. package/cli-ts-node-esm.js +4 -2
  50. package/cli-ts-node-esm.js.map +1 -1
  51. package/commands/InitCommand.js +1 -1
  52. package/commands/InitCommand.js.map +1 -1
  53. package/driver/Driver.d.ts +10 -0
  54. package/driver/Driver.js.map +1 -1
  55. package/driver/cockroachdb/CockroachConnectionOptions.d.ts +8 -0
  56. package/driver/cockroachdb/CockroachConnectionOptions.js.map +1 -1
  57. package/driver/cockroachdb/CockroachQueryRunner.d.ts +4 -0
  58. package/driver/cockroachdb/CockroachQueryRunner.js +35 -18
  59. package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
  60. package/driver/mongodb/MongoDriver.js +1 -1
  61. package/driver/mongodb/MongoDriver.js.map +1 -1
  62. package/driver/mysql/MysqlDriver.d.ts +8 -0
  63. package/driver/mysql/MysqlDriver.js +30 -4
  64. package/driver/mysql/MysqlDriver.js.map +1 -1
  65. package/driver/oracle/OracleDriver.d.ts +13 -0
  66. package/driver/oracle/OracleDriver.js +15 -0
  67. package/driver/oracle/OracleDriver.js.map +1 -1
  68. package/driver/oracle/OracleQueryRunner.js +4 -2
  69. package/driver/oracle/OracleQueryRunner.js.map +1 -1
  70. package/driver/sqlserver/SqlServerConnectionOptions.d.ts +9 -0
  71. package/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -1
  72. package/driver/types/ColumnTypes.d.ts +1 -1
  73. package/driver/types/ColumnTypes.js.map +1 -1
  74. package/metadata/EntityMetadata.d.ts +10 -1
  75. package/metadata/EntityMetadata.js +33 -7
  76. package/metadata/EntityMetadata.js.map +1 -1
  77. package/metadata-builder/EntityMetadataBuilder.js +15 -0
  78. package/metadata-builder/EntityMetadataBuilder.js.map +1 -1
  79. package/metadata-builder/EntityMetadataValidator.js +12 -0
  80. package/metadata-builder/EntityMetadataValidator.js.map +1 -1
  81. package/metadata-builder/JunctionEntityMetadataBuilder.js +4 -0
  82. package/metadata-builder/JunctionEntityMetadataBuilder.js.map +1 -1
  83. package/metadata-builder/RelationJoinColumnBuilder.js +2 -0
  84. package/metadata-builder/RelationJoinColumnBuilder.js.map +1 -1
  85. package/package.json +1 -1
  86. package/persistence/EntityPersistExecutor.js +3 -11
  87. package/persistence/EntityPersistExecutor.js.map +1 -1
  88. package/query-builder/RelationIdLoader.d.ts +3 -1
  89. package/query-builder/RelationIdLoader.js +6 -5
  90. package/query-builder/RelationIdLoader.js.map +1 -1
  91. package/query-builder/SelectQueryBuilder.js +19 -3
  92. package/query-builder/SelectQueryBuilder.js.map +1 -1
  93. package/query-builder/transformer/PlainObjectToNewEntityTransformer.js +10 -7
  94. package/query-builder/transformer/PlainObjectToNewEntityTransformer.js.map +1 -1
  95. package/query-builder/transformer/RawSqlResultsToEntityTransformer.js +1 -1
  96. package/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
  97. package/util/DateUtils.d.ts +0 -12
  98. package/util/DateUtils.js +16 -20
  99. package/util/DateUtils.js.map +1 -1
@@ -94,6 +94,10 @@ export interface SqlServerConnectionOptions extends BaseDataSourceOptions, SqlSe
94
94
  * Extra options
95
95
  */
96
96
  readonly options?: {
97
+ /**
98
+ * The named instance to connect to
99
+ */
100
+ readonly instanceName?: string;
97
101
  /**
98
102
  * By default, if the database requestion by options.database cannot be accessed, the connection will fail with
99
103
  * an error. However, if options.fallbackToDefaultDb is set to true, then the user's default database will
@@ -219,6 +223,11 @@ export interface SqlServerConnectionOptions extends BaseDataSourceOptions, SqlSe
219
223
  * (default: node-mssql)
220
224
  */
221
225
  readonly appName?: string;
226
+ /**
227
+ * A boolean, controlling whether encryption occurs if there is no verifiable server certificate.
228
+ * (default: false)
229
+ */
230
+ readonly trustServerCertificate?: boolean;
222
231
  };
223
232
  /**
224
233
  * Replication setup.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../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: true).\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 * Application name used for identifying a specific application in profiling, logging or tracing tools of SQL Server.\n * (default: node-mssql)\n */\n readonly appName?: string\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 readonly poolSize?: never\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../../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 * The named instance to connect to\n */\n readonly instanceName?: string\n\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: true).\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 * Application name used for identifying a specific application in profiling, logging or tracing tools of SQL Server.\n * (default: node-mssql)\n */\n readonly appName?: string\n\n /**\n * A boolean, controlling whether encryption occurs if there is no verifiable server certificate.\n * (default: false)\n */\n readonly trustServerCertificate?: 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 readonly poolSize?: never\n}\n"],"sourceRoot":"../.."}
@@ -18,7 +18,7 @@ export type WithWidthColumnType = "tinyint" | "smallint" | "mediumint" | "int" |
18
18
  /**
19
19
  * All other regular column types.
20
20
  */
21
- export type SimpleColumnType = "simple-array" | "simple-json" | "simple-enum" | "int2" | "integer" | "int4" | "int8" | "int64" | "unsigned big int" | "float" | "float4" | "float8" | "float64" | "smallmoney" | "money" | "boolean" | "bool" | "tinyblob" | "tinytext" | "mediumblob" | "mediumtext" | "blob" | "text" | "ntext" | "citext" | "hstore" | "longblob" | "longtext" | "alphanum" | "shorttext" | "bytes" | "bytea" | "long" | "raw" | "long raw" | "bfile" | "clob" | "nclob" | "image" | "timetz" | "timestamptz" | "timestamp with local time zone" | "smalldatetime" | "date" | "interval year to month" | "interval day to second" | "interval" | "year" | "seconddate" | "point" | "line" | "lseg" | "box" | "circle" | "path" | "polygon" | "geography" | "geometry" | "linestring" | "multipoint" | "multilinestring" | "multipolygon" | "geometrycollection" | "st_geometry" | "st_point" | "int4range" | "int8range" | "numrange" | "tsrange" | "tstzrange" | "daterange" | "enum" | "set" | "cidr" | "inet" | "macaddr" | "bit" | "bit varying" | "varbit" | "tsvector" | "tsquery" | "uuid" | "xml" | "json" | "jsonb" | "varbinary" | "hierarchyid" | "sql_variant" | "rowid" | "urowid" | "uniqueidentifier" | "rowversion" | "array" | "cube" | "ltree";
21
+ export type SimpleColumnType = "simple-array" | "simple-json" | "simple-enum" | "int2" | "integer" | "int4" | "int8" | "int64" | "unsigned big int" | "float" | "float4" | "float8" | "float64" | "smallmoney" | "money" | "boolean" | "bool" | "tinyblob" | "tinytext" | "mediumblob" | "mediumtext" | "blob" | "text" | "ntext" | "citext" | "hstore" | "longblob" | "longtext" | "alphanum" | "shorttext" | "bytes" | "bytea" | "long" | "raw" | "long raw" | "bfile" | "clob" | "nclob" | "image" | "timetz" | "timestamptz" | "timestamp with local time zone" | "smalldatetime" | "date" | "interval year to month" | "interval day to second" | "interval" | "year" | "seconddate" | "point" | "line" | "lseg" | "box" | "circle" | "path" | "polygon" | "geography" | "geometry" | "linestring" | "multipoint" | "multilinestring" | "multipolygon" | "geometrycollection" | "st_geometry" | "st_point" | "int4range" | "int8range" | "numrange" | "tsrange" | "tstzrange" | "daterange" | "enum" | "set" | "cidr" | "inet" | "inet4" | "inet6" | "macaddr" | "bit" | "bit varying" | "varbit" | "tsvector" | "tsquery" | "uuid" | "xml" | "json" | "jsonb" | "varbinary" | "hierarchyid" | "sql_variant" | "rowid" | "urowid" | "uniqueidentifier" | "rowversion" | "array" | "cube" | "ltree";
22
22
  /**
23
23
  * Any column type column can be.
24
24
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/driver/types/ColumnTypes.ts"],"names":[],"mappings":"","file":"ColumnTypes.js","sourcesContent":["/**\n * Column types used for @PrimaryGeneratedColumn() decorator.\n */\nexport type PrimaryGeneratedColumnType =\n | \"int\" // mysql, mssql, oracle, sqlite, sap\n | \"int2\" // postgres, sqlite, cockroachdb\n | \"int4\" // postgres, cockroachdb\n | \"int8\" // postgres, sqlite, cockroachdb\n | \"integer\" // postgres, oracle, sqlite, mysql, cockroachdb, sap\n | \"tinyint\" // mysql, mssql, sqlite, sap\n | \"smallint\" // mysql, postgres, mssql, oracle, sqlite, cockroachdb, sap\n | \"mediumint\" // mysql, sqlite\n | \"bigint\" // mysql, postgres, mssql, sqlite, cockroachdb, sap\n | \"dec\" // oracle, mssql, sap\n | \"decimal\" // mysql, postgres, mssql, sqlite, sap\n | \"smalldecimal\" // sap\n | \"fixed\" // mysql\n | \"numeric\" // postgres, mssql, sqlite, spanner\n | \"number\" // oracle\n\n/**\n * Column types where spatial properties are used.\n */\nexport type SpatialColumnType =\n | \"geometry\" // postgres\n | \"geography\" // postgres\n | \"st_geometry\" // sap\n | \"st_point\" // sap\n\n/**\n * Column types where precision and scale properties are used.\n */\nexport type WithPrecisionColumnType =\n | \"float\" // mysql, mssql, oracle, sqlite\n | \"double\" // mysql, sqlite\n | \"dec\" // oracle, mssql, mysql\n | \"decimal\" // mysql, postgres, mssql, sqlite\n | \"smalldecimal\" // sap\n | \"fixed\" // mysql\n | \"numeric\" // postgres, mssql, sqlite, mysql\n | \"real\" // mysql, postgres, mssql, oracle, sqlite, cockroachdb, sap\n | \"double precision\" // postgres, oracle, sqlite, mysql, cockroachdb\n | \"number\" // oracle\n | \"datetime\" // mssql, mysql, sqlite\n | \"datetime2\" // mssql\n | \"datetimeoffset\" // mssql\n | \"time\" // mysql, postgres, mssql, cockroachdb\n | \"time with time zone\" // postgres, cockroachdb\n | \"time without time zone\" // postgres\n | \"timestamp\" // mysql, postgres, mssql, oracle, cockroachdb, spanner\n | \"timestamp without time zone\" // postgres, cockroachdb\n | \"timestamp with time zone\" // postgres, oracle, cockroachdb\n | \"timestamp with local time zone\" // oracle\n\n/**\n * Column types where column length is used.\n */\nexport type WithLengthColumnType =\n | \"character varying\" // postgres, cockroachdb\n | \"varying character\" // sqlite\n | \"char varying\" // cockroachdb\n | \"nvarchar\" // mssql, mysql\n | \"national varchar\" // mysql\n | \"character\" // mysql, postgres, sqlite, cockroachdb\n | \"native character\" // sqlite\n | \"varchar\" // mysql, postgres, mssql, sqlite, cockroachdb\n | \"char\" // mysql, postgres, mssql, oracle, cockroachdb, sap\n | \"nchar\" // mssql, oracle, sqlite, mysql, sap\n | \"national char\" // mysql\n | \"varchar2\" // oracle\n | \"nvarchar2\" // oracle, sqlite\n | \"alphanum\" // sap\n | \"shorttext\" // sap\n | \"raw\" // oracle\n | \"binary\" // mssql\n | \"varbinary\" // mssql, sap\n | \"string\" // cockroachdb, spanner\n\nexport type WithWidthColumnType =\n | \"tinyint\" // mysql\n | \"smallint\" // mysql\n | \"mediumint\" // mysql\n | \"int\" // mysql\n | \"bigint\" // mysql\n\n/**\n * All other regular column types.\n */\nexport type SimpleColumnType =\n | \"simple-array\" // typeorm-specific, automatically mapped to string\n // |\"string\" // typeorm-specific, automatically mapped to varchar depend on platform\n | \"simple-json\" // typeorm-specific, automatically mapped to string\n | \"simple-enum\" // typeorm-specific, automatically mapped to string\n\n // numeric types\n | \"int2\" // postgres, sqlite, cockroachdb\n | \"integer\" // postgres, oracle, sqlite, cockroachdb\n | \"int4\" // postgres, cockroachdb\n | \"int8\" // postgres, sqlite, cockroachdb\n | \"int64\" // cockroachdb, spanner\n | \"unsigned big int\" // sqlite\n | \"float\" // mysql, mssql, oracle, sqlite, sap\n | \"float4\" // postgres, cockroachdb\n | \"float8\" // postgres, cockroachdb\n | \"float64\" // spanner\n | \"smallmoney\" // mssql\n | \"money\" // postgres, mssql\n\n // boolean types\n | \"boolean\" // postgres, sqlite, mysql, cockroachdb\n | \"bool\" // postgres, mysql, cockroachdb, spanner\n\n // text/binary types\n | \"tinyblob\" // mysql\n | \"tinytext\" // mysql\n | \"mediumblob\" // mysql\n | \"mediumtext\" // mysql\n | \"blob\" // mysql, oracle, sqlite, cockroachdb, sap\n | \"text\" // mysql, postgres, mssql, sqlite, cockroachdb, sap\n | \"ntext\" // mssql\n | \"citext\" // postgres\n | \"hstore\" // postgres\n | \"longblob\" // mysql\n | \"longtext\" // mysql\n | \"alphanum\" // sap\n | \"shorttext\" // sap\n | \"bytes\" // cockroachdb, spanner\n | \"bytea\" // postgres, cockroachdb\n | \"long\" // oracle\n | \"raw\" // oracle\n | \"long raw\" // oracle\n | \"bfile\" // oracle\n | \"clob\" // oracle, sqlite, sap\n | \"nclob\" // oracle, sap\n | \"image\" // mssql\n\n // date types\n | \"timetz\" // postgres\n | \"timestamptz\" // postgres, cockroachdb\n | \"timestamp with local time zone\" // oracle\n | \"smalldatetime\" // mssql\n | \"date\" // mysql, postgres, mssql, oracle, sqlite, spanner\n | \"interval year to month\" // oracle\n | \"interval day to second\" // oracle\n | \"interval\" // postgres, cockroachdb\n | \"year\" // mysql\n | \"seconddate\" // sap\n\n // geometric types\n | \"point\" // postgres, mysql\n | \"line\" // postgres\n | \"lseg\" // postgres\n | \"box\" // postgres\n | \"circle\" // postgres\n | \"path\" // postgres\n | \"polygon\" // postgres, mysql\n | \"geography\" // mssql\n | \"geometry\" // mysql\n | \"linestring\" // mysql\n | \"multipoint\" // mysql\n | \"multilinestring\" // mysql\n | \"multipolygon\" // mysql\n | \"geometrycollection\" // mysql\n | \"st_geometry\" // sap\n | \"st_point\" // sap\n\n // range types\n | \"int4range\" // postgres\n | \"int8range\" // postgres\n | \"numrange\" // postgres\n | \"tsrange\" // postgres\n | \"tstzrange\" // postgres\n | \"daterange\" // postgres\n\n // other types\n | \"enum\" // mysql, postgres\n | \"set\" // mysql\n | \"cidr\" // postgres\n | \"inet\" // postgres, cockroachdb\n | \"macaddr\" // postgres\n | \"bit\" // postgres, mssql\n | \"bit varying\" // postgres\n | \"varbit\" // postgres\n | \"tsvector\" // postgres\n | \"tsquery\" // postgres\n | \"uuid\" // postgres, cockroachdb\n | \"xml\" // mssql, postgres\n | \"json\" // mysql, postgres, cockroachdb, spanner\n | \"jsonb\" // postgres, cockroachdb\n | \"varbinary\" // mssql, sap\n | \"hierarchyid\" // mssql\n | \"sql_variant\" // mssql\n | \"rowid\" // oracle\n | \"urowid\" // oracle\n | \"uniqueidentifier\" // mssql\n | \"rowversion\" // mssql\n | \"array\" // cockroachdb, sap, spanner\n | \"cube\" // postgres\n | \"ltree\" // postgres\n\n/**\n * Any column type column can be.\n */\nexport type ColumnType =\n | WithPrecisionColumnType\n | WithLengthColumnType\n | WithWidthColumnType\n | SpatialColumnType\n | SimpleColumnType\n | BooleanConstructor\n | DateConstructor\n | NumberConstructor\n | StringConstructor\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../../src/driver/types/ColumnTypes.ts"],"names":[],"mappings":"","file":"ColumnTypes.js","sourcesContent":["/**\n * Column types used for @PrimaryGeneratedColumn() decorator.\n */\nexport type PrimaryGeneratedColumnType =\n | \"int\" // mysql, mssql, oracle, sqlite, sap\n | \"int2\" // postgres, sqlite, cockroachdb\n | \"int4\" // postgres, cockroachdb\n | \"int8\" // postgres, sqlite, cockroachdb\n | \"integer\" // postgres, oracle, sqlite, mysql, cockroachdb, sap\n | \"tinyint\" // mysql, mssql, sqlite, sap\n | \"smallint\" // mysql, postgres, mssql, oracle, sqlite, cockroachdb, sap\n | \"mediumint\" // mysql, sqlite\n | \"bigint\" // mysql, postgres, mssql, sqlite, cockroachdb, sap\n | \"dec\" // oracle, mssql, sap\n | \"decimal\" // mysql, postgres, mssql, sqlite, sap\n | \"smalldecimal\" // sap\n | \"fixed\" // mysql\n | \"numeric\" // postgres, mssql, sqlite, spanner\n | \"number\" // oracle\n\n/**\n * Column types where spatial properties are used.\n */\nexport type SpatialColumnType =\n | \"geometry\" // postgres\n | \"geography\" // postgres\n | \"st_geometry\" // sap\n | \"st_point\" // sap\n\n/**\n * Column types where precision and scale properties are used.\n */\nexport type WithPrecisionColumnType =\n | \"float\" // mysql, mssql, oracle, sqlite\n | \"double\" // mysql, sqlite\n | \"dec\" // oracle, mssql, mysql\n | \"decimal\" // mysql, postgres, mssql, sqlite\n | \"smalldecimal\" // sap\n | \"fixed\" // mysql\n | \"numeric\" // postgres, mssql, sqlite, mysql\n | \"real\" // mysql, postgres, mssql, oracle, sqlite, cockroachdb, sap\n | \"double precision\" // postgres, oracle, sqlite, mysql, cockroachdb\n | \"number\" // oracle\n | \"datetime\" // mssql, mysql, sqlite\n | \"datetime2\" // mssql\n | \"datetimeoffset\" // mssql\n | \"time\" // mysql, postgres, mssql, cockroachdb\n | \"time with time zone\" // postgres, cockroachdb\n | \"time without time zone\" // postgres\n | \"timestamp\" // mysql, postgres, mssql, oracle, cockroachdb, spanner\n | \"timestamp without time zone\" // postgres, cockroachdb\n | \"timestamp with time zone\" // postgres, oracle, cockroachdb\n | \"timestamp with local time zone\" // oracle\n\n/**\n * Column types where column length is used.\n */\nexport type WithLengthColumnType =\n | \"character varying\" // postgres, cockroachdb\n | \"varying character\" // sqlite\n | \"char varying\" // cockroachdb\n | \"nvarchar\" // mssql, mysql\n | \"national varchar\" // mysql\n | \"character\" // mysql, postgres, sqlite, cockroachdb\n | \"native character\" // sqlite\n | \"varchar\" // mysql, postgres, mssql, sqlite, cockroachdb\n | \"char\" // mysql, postgres, mssql, oracle, cockroachdb, sap\n | \"nchar\" // mssql, oracle, sqlite, mysql, sap\n | \"national char\" // mysql\n | \"varchar2\" // oracle\n | \"nvarchar2\" // oracle, sqlite\n | \"alphanum\" // sap\n | \"shorttext\" // sap\n | \"raw\" // oracle\n | \"binary\" // mssql\n | \"varbinary\" // mssql, sap\n | \"string\" // cockroachdb, spanner\n\nexport type WithWidthColumnType =\n | \"tinyint\" // mysql\n | \"smallint\" // mysql\n | \"mediumint\" // mysql\n | \"int\" // mysql\n | \"bigint\" // mysql\n\n/**\n * All other regular column types.\n */\nexport type SimpleColumnType =\n | \"simple-array\" // typeorm-specific, automatically mapped to string\n // |\"string\" // typeorm-specific, automatically mapped to varchar depend on platform\n | \"simple-json\" // typeorm-specific, automatically mapped to string\n | \"simple-enum\" // typeorm-specific, automatically mapped to string\n\n // numeric types\n | \"int2\" // postgres, sqlite, cockroachdb\n | \"integer\" // postgres, oracle, sqlite, cockroachdb\n | \"int4\" // postgres, cockroachdb\n | \"int8\" // postgres, sqlite, cockroachdb\n | \"int64\" // cockroachdb, spanner\n | \"unsigned big int\" // sqlite\n | \"float\" // mysql, mssql, oracle, sqlite, sap\n | \"float4\" // postgres, cockroachdb\n | \"float8\" // postgres, cockroachdb\n | \"float64\" // spanner\n | \"smallmoney\" // mssql\n | \"money\" // postgres, mssql\n\n // boolean types\n | \"boolean\" // postgres, sqlite, mysql, cockroachdb\n | \"bool\" // postgres, mysql, cockroachdb, spanner\n\n // text/binary types\n | \"tinyblob\" // mysql\n | \"tinytext\" // mysql\n | \"mediumblob\" // mysql\n | \"mediumtext\" // mysql\n | \"blob\" // mysql, oracle, sqlite, cockroachdb, sap\n | \"text\" // mysql, postgres, mssql, sqlite, cockroachdb, sap\n | \"ntext\" // mssql\n | \"citext\" // postgres\n | \"hstore\" // postgres\n | \"longblob\" // mysql\n | \"longtext\" // mysql\n | \"alphanum\" // sap\n | \"shorttext\" // sap\n | \"bytes\" // cockroachdb, spanner\n | \"bytea\" // postgres, cockroachdb\n | \"long\" // oracle\n | \"raw\" // oracle\n | \"long raw\" // oracle\n | \"bfile\" // oracle\n | \"clob\" // oracle, sqlite, sap\n | \"nclob\" // oracle, sap\n | \"image\" // mssql\n\n // date types\n | \"timetz\" // postgres\n | \"timestamptz\" // postgres, cockroachdb\n | \"timestamp with local time zone\" // oracle\n | \"smalldatetime\" // mssql\n | \"date\" // mysql, postgres, mssql, oracle, sqlite, spanner\n | \"interval year to month\" // oracle\n | \"interval day to second\" // oracle\n | \"interval\" // postgres, cockroachdb\n | \"year\" // mysql\n | \"seconddate\" // sap\n\n // geometric types\n | \"point\" // postgres, mysql\n | \"line\" // postgres\n | \"lseg\" // postgres\n | \"box\" // postgres\n | \"circle\" // postgres\n | \"path\" // postgres\n | \"polygon\" // postgres, mysql\n | \"geography\" // mssql\n | \"geometry\" // mysql\n | \"linestring\" // mysql\n | \"multipoint\" // mysql\n | \"multilinestring\" // mysql\n | \"multipolygon\" // mysql\n | \"geometrycollection\" // mysql\n | \"st_geometry\" // sap\n | \"st_point\" // sap\n\n // range types\n | \"int4range\" // postgres\n | \"int8range\" // postgres\n | \"numrange\" // postgres\n | \"tsrange\" // postgres\n | \"tstzrange\" // postgres\n | \"daterange\" // postgres\n\n // other types\n | \"enum\" // mysql, postgres\n | \"set\" // mysql\n | \"cidr\" // postgres\n | \"inet\" // postgres, cockroachdb\n | \"inet4\" // mariadb\n | \"inet6\" // mariadb\n | \"macaddr\" // postgres\n | \"bit\" // postgres, mssql\n | \"bit varying\" // postgres\n | \"varbit\" // postgres\n | \"tsvector\" // postgres\n | \"tsquery\" // postgres\n | \"uuid\" // postgres, cockroachdb, mariadb\n | \"xml\" // mssql, postgres\n | \"json\" // mysql, postgres, cockroachdb, spanner\n | \"jsonb\" // postgres, cockroachdb\n | \"varbinary\" // mssql, sap\n | \"hierarchyid\" // mssql\n | \"sql_variant\" // mssql\n | \"rowid\" // oracle\n | \"urowid\" // oracle\n | \"uniqueidentifier\" // mssql\n | \"rowversion\" // mssql\n | \"array\" // cockroachdb, sap, spanner\n | \"cube\" // postgres\n | \"ltree\" // postgres\n\n/**\n * Any column type column can be.\n */\nexport type ColumnType =\n | WithPrecisionColumnType\n | WithLengthColumnType\n | WithWidthColumnType\n | SpatialColumnType\n | SimpleColumnType\n | BooleanConstructor\n | DateConstructor\n | NumberConstructor\n | StringConstructor\n"],"sourceRoot":"../.."}
@@ -516,7 +516,16 @@ export declare class EntityMetadata {
516
516
  * If relation value is an array its being flattened.
517
517
  */
518
518
  extractRelationValuesFromEntity(entity: ObjectLiteral, relations: RelationMetadata[]): [RelationMetadata, any, EntityMetadata][];
519
- private getInverseEntityMetadata;
519
+ /**
520
+ * In the case of SingleTableInheritance, find the correct metadata
521
+ * for a given value.
522
+ *
523
+ * @param value The value to find the metadata for.
524
+ * @returns The found metadata for the entity or the base metadata if no matching metadata
525
+ * was found in the whole inheritance tree.
526
+ */
527
+ findInheritanceMetadata(value: any): EntityMetadata;
528
+ private static getInverseEntityMetadata;
520
529
  /**
521
530
  * Creates a property paths for a given entity.
522
531
  *
@@ -469,24 +469,50 @@ class EntityMetadata {
469
469
  value.forEach((subValue) => relationsAndValues.push([
470
470
  relation,
471
471
  subValue,
472
- this.getInverseEntityMetadata(subValue, relation),
472
+ EntityMetadata.getInverseEntityMetadata(subValue, relation),
473
473
  ]));
474
474
  }
475
475
  else if (value) {
476
476
  relationsAndValues.push([
477
477
  relation,
478
478
  value,
479
- this.getInverseEntityMetadata(value, relation),
479
+ EntityMetadata.getInverseEntityMetadata(value, relation),
480
480
  ]);
481
481
  }
482
482
  });
483
483
  return relationsAndValues;
484
484
  }
485
- getInverseEntityMetadata(value, relation) {
486
- const childEntityMetadata = relation.inverseEntityMetadata.childEntityMetadatas.find((metadata) => metadata.target === value.constructor);
487
- return childEntityMetadata
488
- ? childEntityMetadata
489
- : relation.inverseEntityMetadata;
485
+ /**
486
+ * In the case of SingleTableInheritance, find the correct metadata
487
+ * for a given value.
488
+ *
489
+ * @param value The value to find the metadata for.
490
+ * @returns The found metadata for the entity or the base metadata if no matching metadata
491
+ * was found in the whole inheritance tree.
492
+ */
493
+ findInheritanceMetadata(value) {
494
+ // Check for single table inheritance and find the correct metadata in that case.
495
+ // Goal is to use the correct discriminator as we could have a repository
496
+ // for an (abstract) base class and thus the target would not match.
497
+ if (this.inheritancePattern === "STI" &&
498
+ this.childEntityMetadatas.length > 0) {
499
+ // There could be a column on the base class that can manually be set to override the type.
500
+ let manuallySetDiscriminatorValue;
501
+ if (this.discriminatorColumn) {
502
+ manuallySetDiscriminatorValue =
503
+ value[this.discriminatorColumn.propertyName];
504
+ }
505
+ return (this.childEntityMetadatas.find((meta) => manuallySetDiscriminatorValue ===
506
+ meta.discriminatorValue ||
507
+ value.constructor === meta.target) || this);
508
+ }
509
+ return this;
510
+ }
511
+ // -------------------------------------------------------------------------
512
+ // Private Static Methods
513
+ // -------------------------------------------------------------------------
514
+ static getInverseEntityMetadata(value, relation) {
515
+ return relation.inverseEntityMetadata.findInheritanceMetadata(value);
490
516
  }
491
517
  // -------------------------------------------------------------------------
492
518
  // Public Static Methods
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/metadata/EntityMetadata.ts"],"names":[],"mappings":";;;AAGA,wFAAoF;AAIpF,+CAA2C;AAe3C,sFAAkF;AAClF,qDAAiD;AACjD,qDAA6C;AAE7C;;GAEG;AACH,MAAa,cAAc;IAyevB,wEAAwE;IACxE,cAAc;IACd,wEAAwE;IAExE,YAAY,OAOX;QAnfQ,mBAAa,GAAG,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;QA+BrD;;WAEG;QACH,yBAAoB,GAAqB,EAAE,CAAA;QAE3C;;;;WAIG;QACH,oBAAe,GAAe,EAAE,CAAA;QAEhC;;WAEG;QACH,cAAS,GAAc,SAAS,CAAA;QAiChC;;WAEG;QACH,iBAAY,GAAa,KAAK,CAAA;QA8B9B;;WAEG;QACH,gBAAW,GAAY,IAAI,CAAA;QA4B3B;;WAEG;QACH,4BAAuB,GAAY,KAAK,CAAA;QAExC;;;;;WAKG;QACH,eAAU,GAAY,KAAK,CAAA;QAE3B;;;WAGG;QACH,6BAAwB,GAAY,IAA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AM,CAAC,kBAAkB,KAAK,MAAM,CACjE,CAAC,MAAM,GAAG,CAAC,CAAA;QAChB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAA;QAC/C,IAAI,IAAI,CAAC,oBAAoB;YACzB,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,EAAE,CACjD,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,CACxC,CAAA;IACT,CAAC;IAED;;;;;;;OAOG;IACH,mBAAmB;QACf,MAAM,GAAG,GAAqC,EAAE,CAAA;QAChD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAC5B,mBAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CACtE,CAAA;QACD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAChC,mBAAQ,CAAC,SAAS,CACd,GAAG,EACH,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC,CACjD,CACJ,CAAA;QACD,OAAO,GAAG,CAAA;IACd,CAAC;IAED;;;;;OAKG;IACH,4BAA4B;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;YAClC,OAAO,CACH,MAAM,CAAC,OAAO,KAAK,SAAS;gBAC5B,MAAM,CAAC,WAAW;gBAClB,MAAM,CAAC,YAAY;gBACnB,MAAM,CAAC,YAAY;gBACnB,MAAM,CAAC,YAAY;gBACnB,MAAM,CAAC,SAAS,CACnB,CAAA;QACL,CAAC,CAAC,CAAA;IACN,CAAC;CACJ;AAziCD,wCAyiCC","file":"EntityMetadata.js","sourcesContent":["import { QueryRunner, SelectQueryBuilder } from \"..\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { CannotCreateEntityIdMapError } from \"../error/CannotCreateEntityIdMapError\"\nimport { OrderByCondition } from \"../find-options/OrderByCondition\"\nimport { TableMetadataArgs } from \"../metadata-args/TableMetadataArgs\"\nimport { TreeMetadataArgs } from \"../metadata-args/TreeMetadataArgs\"\nimport { OrmUtils } from \"../util/OrmUtils\"\nimport { CheckMetadata } from \"./CheckMetadata\"\nimport { ColumnMetadata } from \"./ColumnMetadata\"\nimport { EmbeddedMetadata } from \"./EmbeddedMetadata\"\nimport { EntityListenerMetadata } from \"./EntityListenerMetadata\"\nimport { ExclusionMetadata } from \"./ExclusionMetadata\"\nimport { ForeignKeyMetadata } from \"./ForeignKeyMetadata\"\nimport { IndexMetadata } from \"./IndexMetadata\"\nimport { RelationCountMetadata } from \"./RelationCountMetadata\"\nimport { RelationIdMetadata } from \"./RelationIdMetadata\"\nimport { RelationMetadata } from \"./RelationMetadata\"\nimport { TableType } from \"./types/TableTypes\"\nimport { TreeType } from \"./types/TreeTypes\"\nimport { UniqueMetadata } from \"./UniqueMetadata\"\nimport { ClosureTreeOptions } from \"./types/ClosureTreeOptions\"\nimport { EntityPropertyNotFoundError } from \"../error/EntityPropertyNotFoundError\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\nimport { shorten } from \"../util/StringUtils\"\n\n/**\n * Contains all entity metadata.\n */\nexport class EntityMetadata {\n readonly \"@instanceof\" = Symbol.for(\"EntityMetadata\")\n\n // -------------------------------------------------------------------------\n // Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection where this entity metadata is created.\n */\n connection: DataSource\n\n /**\n * Metadata arguments used to build this entity metadata.\n */\n tableMetadataArgs: TableMetadataArgs\n\n /**\n * If entity's table is a closure-typed table, then this entity will have a closure junction table metadata.\n */\n closureJunctionTable: EntityMetadata\n\n /**\n * If this is entity metadata for a junction closure table then its owner closure table metadata will be set here.\n */\n parentClosureEntityMetadata: EntityMetadata\n\n /**\n * Parent's entity metadata. Used in inheritance patterns.\n */\n parentEntityMetadata: EntityMetadata\n\n /**\n * Children entity metadatas. Used in inheritance patterns.\n */\n childEntityMetadatas: EntityMetadata[] = []\n\n /**\n * All \"inheritance tree\" from a target entity.\n * For example for target Post < ContentModel < Unit it will be an array of [Post, ContentModel, Unit].\n * It also contains child entities for single table inheritance.\n */\n inheritanceTree: Function[] = []\n\n /**\n * Table type. Tables can be closure, junction, etc.\n */\n tableType: TableType = \"regular\"\n\n /**\n * Target class to which this entity metadata is bind.\n * Note, that when using table inheritance patterns target can be different rather then table's target.\n * For virtual tables which lack of real entity (like junction tables) target is equal to their table name.\n */\n target: Function | string\n\n /**\n * Gets the name of the target.\n */\n targetName: string\n\n /**\n * Entity's name.\n * Equal to entity target class's name if target is set to table.\n * If target class is not then then it equals to table name.\n */\n name: string\n\n /**\n * View's expression.\n * Used in views\n */\n expression?: string | ((connection: DataSource) => SelectQueryBuilder<any>)\n\n /**\n * View's dependencies.\n * Used in views\n */\n dependsOn?: Set<Function | string>\n\n /**\n * Enables Sqlite \"WITHOUT ROWID\" modifier for the \"CREATE TABLE\" statement\n */\n withoutRowid?: boolean = false\n\n /**\n * Original user-given table name (taken from schema or @Entity(tableName) decorator).\n * If user haven't specified a table name this property will be undefined.\n */\n givenTableName?: string\n\n /**\n * Entity table name in the database.\n * This is final table name of the entity.\n * This name already passed naming strategy, and generated based on\n * multiple criteria, including user table name and global table prefix.\n */\n tableName: string\n\n /**\n * Entity table path. Contains database name, schema name and table name.\n * E.g. myDB.mySchema.myTable\n */\n tablePath: string\n\n /**\n * Gets the table name without global table prefix.\n * When querying table you need a table name with prefix, but in some scenarios,\n * for example when you want to name a junction table that contains names of two other tables,\n * you may want a table name without prefix.\n */\n tableNameWithoutPrefix: string\n\n /**\n * Indicates if schema will be synchronized for this entity or not.\n */\n synchronize: boolean = true\n\n /**\n * Table's database engine type (like \"InnoDB\", \"MyISAM\", etc).\n */\n engine?: string\n\n /**\n * Database name.\n */\n database?: string\n\n /**\n * Schema name. Used in Postgres and Sql Server.\n */\n schema?: string\n\n /**\n * Specifies a default order by used for queries from this table when no explicit order by is specified.\n */\n orderBy?: OrderByCondition\n\n /**\n * If this entity metadata's table using one of the inheritance patterns,\n * then this will contain what pattern it uses.\n */\n inheritancePattern?: \"STI\" /*|\"CTI\"*/\n\n /**\n * Checks if there any non-nullable column exist in this entity.\n */\n hasNonNullableRelations: boolean = false\n\n /**\n * Indicates if this entity metadata of a junction table, or not.\n * Junction table is a table created by many-to-many relationship.\n *\n * Its also possible to understand if entity is junction via tableType.\n */\n isJunction: boolean = false\n\n /**\n * Indicates if the entity should be instantiated using the constructor\n * or via allocating a new object via `Object.create()`.\n */\n isAlwaysUsingConstructor: boolean = true\n\n /**\n * Indicates if this entity is a tree, what type of tree it is.\n */\n treeType?: TreeType\n\n /**\n * Indicates if this entity is a tree, what options of tree it has.\n */\n treeOptions?: ClosureTreeOptions\n\n /**\n * Checks if this table is a junction table of the closure table.\n * This type is for tables that contain junction metadata of the closure tables.\n */\n isClosureJunction: boolean = false\n\n /**\n * Checks if entity's table has multiple primary columns.\n */\n hasMultiplePrimaryKeys: boolean = false\n\n /**\n * Indicates if this entity metadata has uuid generated columns.\n */\n hasUUIDGeneratedColumns: boolean = false\n\n /**\n * If this entity metadata is a child table of some table, it should have a discriminator value.\n * Used to store a value in a discriminator column.\n */\n discriminatorValue?: string\n\n /**\n * Entity's column metadatas defined by user.\n */\n ownColumns: ColumnMetadata[] = []\n\n /**\n * Columns of the entity, including columns that are coming from the embeddeds of this entity.\n */\n columns: ColumnMetadata[] = []\n\n /**\n * Ancestor columns used only in closure junction tables.\n */\n ancestorColumns: ColumnMetadata[] = []\n\n /**\n * Descendant columns used only in closure junction tables.\n */\n descendantColumns: ColumnMetadata[] = []\n\n /**\n * All columns except for virtual columns.\n */\n nonVirtualColumns: ColumnMetadata[] = []\n\n /**\n * In the case if this entity metadata is junction table's entity metadata,\n * this will contain all referenced columns of owner entity.\n */\n ownerColumns: ColumnMetadata[] = []\n\n /**\n * In the case if this entity metadata is junction table's entity metadata,\n * this will contain all referenced columns of inverse entity.\n */\n inverseColumns: ColumnMetadata[] = []\n\n /**\n * Gets the column with generated flag.\n */\n generatedColumns: ColumnMetadata[] = []\n\n /**\n * Gets the object id column used with mongodb database.\n */\n objectIdColumn?: ColumnMetadata\n\n /**\n * Gets entity column which contains a create date value.\n */\n createDateColumn?: ColumnMetadata\n\n /**\n * Gets entity column which contains an update date value.\n */\n updateDateColumn?: ColumnMetadata\n\n /**\n * Gets entity column which contains a delete date value.\n */\n deleteDateColumn?: ColumnMetadata\n\n /**\n * Gets entity column which contains an entity version.\n */\n versionColumn?: ColumnMetadata\n\n /**\n * Gets the discriminator column used to store entity identificator in single-table inheritance tables.\n */\n discriminatorColumn?: ColumnMetadata\n\n /**\n * Special column that stores tree level in tree entities.\n */\n treeLevelColumn?: ColumnMetadata\n\n /**\n * Nested set's left value column.\n * Used only in tree entities with nested set pattern applied.\n */\n nestedSetLeftColumn?: ColumnMetadata\n\n /**\n * Nested set's right value column.\n * Used only in tree entities with nested set pattern applied.\n */\n nestedSetRightColumn?: ColumnMetadata\n\n /**\n * Materialized path column.\n * Used only in tree entities with materialized path pattern applied.\n */\n materializedPathColumn?: ColumnMetadata\n\n /**\n * Gets the primary columns.\n */\n primaryColumns: ColumnMetadata[] = []\n\n /**\n * Entity's relation metadatas.\n */\n ownRelations: RelationMetadata[] = []\n\n /**\n * Relations of the entity, including relations that are coming from the embeddeds of this entity.\n */\n relations: RelationMetadata[] = []\n\n /**\n * List of eager relations this metadata has.\n */\n eagerRelations: RelationMetadata[] = []\n\n /**\n * List of eager relations this metadata has.\n */\n lazyRelations: RelationMetadata[] = []\n\n /**\n * Gets only one-to-one relations of the entity.\n */\n oneToOneRelations: RelationMetadata[] = []\n\n /**\n * Gets only owner one-to-one relations of the entity.\n */\n ownerOneToOneRelations: RelationMetadata[] = []\n\n /**\n * Gets only one-to-many relations of the entity.\n */\n oneToManyRelations: RelationMetadata[] = []\n\n /**\n * Gets only many-to-one relations of the entity.\n */\n manyToOneRelations: RelationMetadata[] = []\n\n /**\n * Gets only many-to-many relations of the entity.\n */\n manyToManyRelations: RelationMetadata[] = []\n\n /**\n * Gets only owner many-to-many relations of the entity.\n */\n ownerManyToManyRelations: RelationMetadata[] = []\n\n /**\n * Gets only owner one-to-one and many-to-one relations.\n */\n relationsWithJoinColumns: RelationMetadata[] = []\n\n /**\n * Tree parent relation. Used only in tree-tables.\n */\n treeParentRelation?: RelationMetadata\n\n /**\n * Tree children relation. Used only in tree-tables.\n */\n treeChildrenRelation?: RelationMetadata\n\n /**\n * Entity's relation id metadatas.\n */\n relationIds: RelationIdMetadata[] = []\n\n /**\n * Entity's relation id metadatas.\n */\n relationCounts: RelationCountMetadata[] = []\n\n /**\n * Entity's foreign key metadatas.\n */\n foreignKeys: ForeignKeyMetadata[] = []\n\n /**\n * Entity's embedded metadatas.\n */\n embeddeds: EmbeddedMetadata[] = []\n\n /**\n * All embeddeds - embeddeds from this entity metadata and from all child embeddeds, etc.\n */\n allEmbeddeds: EmbeddedMetadata[] = []\n\n /**\n * Entity's own indices.\n */\n ownIndices: IndexMetadata[] = []\n\n /**\n * Entity's index metadatas.\n */\n indices: IndexMetadata[] = []\n\n /**\n * Entity's unique metadatas.\n */\n uniques: UniqueMetadata[] = []\n\n /**\n * Entity's own uniques.\n */\n ownUniques: UniqueMetadata[] = []\n\n /**\n * Entity's check metadatas.\n */\n checks: CheckMetadata[] = []\n\n /**\n * Entity's exclusion metadatas.\n */\n exclusions: ExclusionMetadata[] = []\n\n /**\n * Entity's own listener metadatas.\n */\n ownListeners: EntityListenerMetadata[] = []\n\n /**\n * Entity listener metadatas.\n */\n listeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER LOAD\" type.\n */\n afterLoadListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER INSERT\" type.\n */\n beforeInsertListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER INSERT\" type.\n */\n afterInsertListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER UPDATE\" type.\n */\n beforeUpdateListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER UPDATE\" type.\n */\n afterUpdateListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER REMOVE\" type.\n */\n beforeRemoveListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"BEFORE SOFT REMOVE\" type.\n */\n beforeSoftRemoveListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"BEFORE RECOVER\" type.\n */\n beforeRecoverListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER REMOVE\" type.\n */\n afterRemoveListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER SOFT REMOVE\" type.\n */\n afterSoftRemoveListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER RECOVER\" type.\n */\n afterRecoverListeners: EntityListenerMetadata[] = []\n\n /**\n * Map of columns and relations of the entity.\n *\n * example: Post{ id: number, name: string, counterEmbed: { count: number }, category: Category }.\n * This method will create following object:\n * { id: \"id\", counterEmbed: { count: \"counterEmbed.count\" }, category: \"category\" }\n */\n propertiesMap: ObjectLiteral\n\n // ---------------------------------------------------------------------\n // Constructor\n // ---------------------------------------------------------------------\n\n constructor(options: {\n connection: DataSource\n inheritanceTree?: Function[]\n inheritancePattern?: \"STI\" /*|\"CTI\"*/\n tableTree?: TreeMetadataArgs\n parentClosureEntityMetadata?: EntityMetadata\n args: TableMetadataArgs\n }) {\n this.connection = options.connection\n this.inheritanceTree = options.inheritanceTree || []\n this.inheritancePattern = options.inheritancePattern\n this.treeType = options.tableTree ? options.tableTree.type : undefined\n this.treeOptions = options.tableTree\n ? options.tableTree.options\n : undefined\n this.parentClosureEntityMetadata = options.parentClosureEntityMetadata!\n this.tableMetadataArgs = options.args\n this.target = this.tableMetadataArgs.target\n this.tableType = this.tableMetadataArgs.type\n this.expression = this.tableMetadataArgs.expression\n this.withoutRowid = this.tableMetadataArgs.withoutRowid\n this.dependsOn = this.tableMetadataArgs.dependsOn\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new entity.\n */\n create(\n queryRunner?: QueryRunner,\n options?: { fromDeserializer?: boolean; pojo?: boolean },\n ): any {\n const pojo = options && options.pojo === true ? true : false\n // if target is set to a function (e.g. class) that can be created then create it\n let ret: any\n if (typeof this.target === \"function\" && !pojo) {\n if (!options?.fromDeserializer || this.isAlwaysUsingConstructor) {\n ret = new (<any>this.target)()\n } else {\n ret = Object.create(this.target.prototype)\n }\n } else {\n // otherwise simply return a new empty object\n ret = {}\n }\n\n // add \"typename\" property\n if (this.connection.options.typename) {\n ret[this.connection.options.typename] = this.targetName\n }\n\n this.lazyRelations.forEach((relation) =>\n this.connection.relationLoader.enableLazyLoad(\n relation,\n ret,\n queryRunner,\n ),\n )\n return ret\n }\n\n /**\n * Checks if given entity has an id.\n */\n hasId(entity: ObjectLiteral): boolean {\n if (!entity) return false\n\n return this.primaryColumns.every((primaryColumn) => {\n const value = primaryColumn.getEntityValue(entity)\n return value !== null && value !== undefined && value !== \"\"\n })\n }\n\n /**\n * Checks if given entity / object contains ALL primary keys entity must have.\n * Returns true if it contains all of them, false if at least one of them is not defined.\n */\n hasAllPrimaryKeys(entity: ObjectLiteral): boolean {\n return this.primaryColumns.every((primaryColumn) => {\n const value = primaryColumn.getEntityValue(entity)\n return value !== null && value !== undefined\n })\n }\n\n /**\n * Ensures that given object is an entity id map.\n * If given id is an object then it means its already id map.\n * If given id isn't an object then it means its a value of the id column\n * and it creates a new id map with this value and name of the primary column.\n */\n ensureEntityIdMap(id: any): ObjectLiteral {\n if (ObjectUtils.isObject(id)) return id\n\n if (this.hasMultiplePrimaryKeys)\n throw new CannotCreateEntityIdMapError(this, id)\n\n return this.primaryColumns[0].createValueMap(id)\n }\n\n /**\n * Gets primary keys of the entity and returns them in a literal object.\n * For example, for Post{ id: 1, title: \"hello\" } where id is primary it will return { id: 1 }\n * For multiple primary keys it returns multiple keys in object.\n * For primary keys inside embeds it returns complex object literal with keys in them.\n */\n getEntityIdMap(\n entity: ObjectLiteral | undefined,\n ): ObjectLiteral | undefined {\n if (!entity) return undefined\n\n return EntityMetadata.getValueMap(entity, this.primaryColumns, {\n skipNulls: true,\n })\n }\n\n /**\n * Creates a \"mixed id map\".\n * If entity has multiple primary keys (ids) then it will return just regular id map, like what getEntityIdMap returns.\n * But if entity has a single primary key then it will return just value of the id column of the entity, just value.\n * This is called mixed id map.\n */\n getEntityIdMixedMap(\n entity: ObjectLiteral | undefined,\n ): ObjectLiteral | undefined {\n if (!entity) return entity\n\n const idMap = this.getEntityIdMap(entity)\n if (this.hasMultiplePrimaryKeys) {\n return idMap\n } else if (idMap) {\n return this.primaryColumns[0].getEntityValue(idMap) // todo: what about parent primary column?\n }\n\n return idMap\n }\n\n /**\n * Compares two different entities by their ids.\n * Returns true if they match, false otherwise.\n */\n compareEntities(\n firstEntity: ObjectLiteral,\n secondEntity: ObjectLiteral,\n ): boolean {\n const firstEntityIdMap = this.getEntityIdMap(firstEntity)\n if (!firstEntityIdMap) return false\n\n const secondEntityIdMap = this.getEntityIdMap(secondEntity)\n if (!secondEntityIdMap) return false\n\n return OrmUtils.compareIds(firstEntityIdMap, secondEntityIdMap)\n }\n\n /**\n * Finds column with a given property name.\n */\n findColumnWithPropertyName(\n propertyName: string,\n ): ColumnMetadata | undefined {\n return this.columns.find(\n (column) => column.propertyName === propertyName,\n )\n }\n\n /**\n * Finds column with a given database name.\n */\n findColumnWithDatabaseName(\n databaseName: string,\n ): ColumnMetadata | undefined {\n return this.columns.find(\n (column) => column.databaseName === databaseName,\n )\n }\n\n /**\n * Checks if there is a column or relationship with a given property path.\n */\n hasColumnWithPropertyPath(propertyPath: string): boolean {\n const hasColumn = this.columns.some(\n (column) => column.propertyPath === propertyPath,\n )\n return hasColumn || this.hasRelationWithPropertyPath(propertyPath)\n }\n\n /**\n * Finds column with a given property path.\n */\n findColumnWithPropertyPath(\n propertyPath: string,\n ): ColumnMetadata | undefined {\n const column = this.columns.find(\n (column) => column.propertyPath === propertyPath,\n )\n if (column) return column\n\n // in the case if column with property path was not found, try to find a relation with such property path\n // if we find relation and it has a single join column then its the column user was seeking\n const relation = this.relations.find(\n (relation) => relation.propertyPath === propertyPath,\n )\n if (relation && relation.joinColumns.length === 1)\n return relation.joinColumns[0]\n\n return undefined\n }\n\n /**\n * Finds column with a given property path.\n * Does not search in relation unlike findColumnWithPropertyPath.\n */\n findColumnWithPropertyPathStrict(\n propertyPath: string,\n ): ColumnMetadata | undefined {\n return this.columns.find(\n (column) => column.propertyPath === propertyPath,\n )\n }\n\n /**\n * Finds columns with a given property path.\n * Property path can match a relation, and relations can contain multiple columns.\n */\n findColumnsWithPropertyPath(propertyPath: string): ColumnMetadata[] {\n const column = this.columns.find(\n (column) => column.propertyPath === propertyPath,\n )\n if (column) return [column]\n\n // in the case if column with property path was not found, try to find a relation with such property path\n // if we find relation and it has a single join column then its the column user was seeking\n const relation = this.findRelationWithPropertyPath(propertyPath)\n if (relation && relation.joinColumns) return relation.joinColumns\n\n return []\n }\n\n /**\n * Checks if there is a relation with the given property path.\n */\n hasRelationWithPropertyPath(propertyPath: string): boolean {\n return this.relations.some(\n (relation) => relation.propertyPath === propertyPath,\n )\n }\n\n /**\n * Finds relation with the given property path.\n */\n findRelationWithPropertyPath(\n propertyPath: string,\n ): RelationMetadata | undefined {\n return this.relations.find(\n (relation) => relation.propertyPath === propertyPath,\n )\n }\n\n /**\n * Checks if there is an embedded with a given property path.\n */\n hasEmbeddedWithPropertyPath(propertyPath: string): boolean {\n return this.allEmbeddeds.some(\n (embedded) => embedded.propertyPath === propertyPath,\n )\n }\n\n /**\n * Finds embedded with a given property path.\n */\n findEmbeddedWithPropertyPath(\n propertyPath: string,\n ): EmbeddedMetadata | undefined {\n return this.allEmbeddeds.find(\n (embedded) => embedded.propertyPath === propertyPath,\n )\n }\n\n /**\n * Returns an array of databaseNames mapped from provided propertyPaths\n */\n mapPropertyPathsToColumns(propertyPaths: string[]) {\n return propertyPaths.map((propertyPath) => {\n const column = this.findColumnWithPropertyPath(propertyPath)\n if (column == null) {\n throw new EntityPropertyNotFoundError(propertyPath, this)\n }\n return column\n })\n }\n\n /**\n * Iterates through entity and finds and extracts all values from relations in the entity.\n * If relation value is an array its being flattened.\n */\n extractRelationValuesFromEntity(\n entity: ObjectLiteral,\n relations: RelationMetadata[],\n ): [RelationMetadata, any, EntityMetadata][] {\n const relationsAndValues: [RelationMetadata, any, EntityMetadata][] = []\n relations.forEach((relation) => {\n const value = relation.getEntityValue(entity)\n if (Array.isArray(value)) {\n value.forEach((subValue) =>\n relationsAndValues.push([\n relation,\n subValue,\n this.getInverseEntityMetadata(subValue, relation),\n ]),\n )\n } else if (value) {\n relationsAndValues.push([\n relation,\n value,\n this.getInverseEntityMetadata(value, relation),\n ])\n }\n })\n return relationsAndValues\n }\n\n private getInverseEntityMetadata(\n value: any,\n relation: RelationMetadata,\n ): EntityMetadata {\n const childEntityMetadata =\n relation.inverseEntityMetadata.childEntityMetadatas.find(\n (metadata) => metadata.target === value.constructor,\n )\n return childEntityMetadata\n ? childEntityMetadata\n : relation.inverseEntityMetadata\n }\n\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a property paths for a given entity.\n *\n * @deprecated\n */\n static createPropertyPath(\n metadata: EntityMetadata,\n entity: ObjectLiteral,\n prefix: string = \"\",\n ) {\n const paths: string[] = []\n Object.keys(entity).forEach((key) => {\n // check for function is needed in the cases when createPropertyPath used on values contain a function as a value\n // example: .update().set({ name: () => `SUBSTR('', 1, 2)` })\n const parentPath = prefix ? prefix + \".\" + key : key\n if (metadata.hasEmbeddedWithPropertyPath(parentPath)) {\n const subPaths = this.createPropertyPath(\n metadata,\n entity[key],\n parentPath,\n )\n paths.push(...subPaths)\n } else {\n const path = prefix ? prefix + \".\" + key : key\n paths.push(path)\n }\n })\n return paths\n }\n\n /**\n * Finds difference between two entity id maps.\n * Returns items that exist in the first array and absent in the second array.\n */\n static difference(\n firstIdMaps: ObjectLiteral[],\n secondIdMaps: ObjectLiteral[],\n ): ObjectLiteral[] {\n return firstIdMaps.filter((firstIdMap) => {\n return !secondIdMaps.find((secondIdMap) =>\n OrmUtils.compareIds(firstIdMap, secondIdMap),\n )\n })\n }\n\n /**\n * Creates value map from the given values and columns.\n * Examples of usages are primary columns map and join columns map.\n */\n static getValueMap(\n entity: ObjectLiteral,\n columns: ColumnMetadata[],\n options?: { skipNulls?: boolean },\n ): ObjectLiteral | undefined {\n return columns.reduce((map, column) => {\n const value = column.getEntityValueMap(entity, options)\n\n // make sure that none of the values of the columns are not missing\n if (map === undefined || value === null || value === undefined)\n return undefined\n\n return OrmUtils.mergeDeep(map, value)\n }, {} as ObjectLiteral | undefined)\n }\n\n // ---------------------------------------------------------------------\n // Public Builder Methods\n // ---------------------------------------------------------------------\n\n build() {\n const namingStrategy = this.connection.namingStrategy\n const entityPrefix = this.connection.options.entityPrefix\n const entitySkipConstructor =\n this.connection.options.entitySkipConstructor\n\n this.engine = this.tableMetadataArgs.engine\n this.database =\n this.tableMetadataArgs.type === \"entity-child\" &&\n this.parentEntityMetadata\n ? this.parentEntityMetadata.database\n : this.tableMetadataArgs.database\n if (this.tableMetadataArgs.schema) {\n this.schema = this.tableMetadataArgs.schema\n } else if (\n this.tableMetadataArgs.type === \"entity-child\" &&\n this.parentEntityMetadata\n ) {\n this.schema = this.parentEntityMetadata.schema\n } else if (this.connection.options?.hasOwnProperty(\"schema\")) {\n this.schema = (this.connection.options as any).schema\n }\n this.givenTableName =\n this.tableMetadataArgs.type === \"entity-child\" &&\n this.parentEntityMetadata\n ? this.parentEntityMetadata.givenTableName\n : this.tableMetadataArgs.name\n this.synchronize =\n this.tableMetadataArgs.synchronize === false ? false : true\n this.targetName =\n typeof this.tableMetadataArgs.target === \"function\"\n ? (this.tableMetadataArgs.target as any).name\n : this.tableMetadataArgs.target\n if (this.tableMetadataArgs.type === \"closure-junction\") {\n this.tableNameWithoutPrefix =\n namingStrategy.closureJunctionTableName(this.givenTableName!)\n } else if (\n this.tableMetadataArgs.type === \"entity-child\" &&\n this.parentEntityMetadata\n ) {\n this.tableNameWithoutPrefix = namingStrategy.tableName(\n this.parentEntityMetadata.targetName,\n this.parentEntityMetadata.givenTableName,\n )\n } else {\n this.tableNameWithoutPrefix = namingStrategy.tableName(\n this.targetName,\n this.givenTableName,\n )\n\n if (\n this.tableMetadataArgs.type === \"junction\" &&\n this.connection.driver.maxAliasLength &&\n this.connection.driver.maxAliasLength > 0 &&\n this.tableNameWithoutPrefix.length >\n this.connection.driver.maxAliasLength\n ) {\n // note: we are not using DriverUtils.buildAlias here because we would like to avoid\n // hashed table names. However, current algorithm also isn't perfect, but we cannot\n // change it, since it's a big breaking change. Planned to 0.4.0\n this.tableNameWithoutPrefix = shorten(\n this.tableNameWithoutPrefix,\n { separator: \"_\", segmentLength: 3 },\n )\n }\n }\n this.tableName = entityPrefix\n ? namingStrategy.prefixTableName(\n entityPrefix,\n this.tableNameWithoutPrefix,\n )\n : this.tableNameWithoutPrefix\n this.target = this.target ? this.target : this.tableName\n this.name = this.targetName ? this.targetName : this.tableName\n this.expression = this.tableMetadataArgs.expression\n this.withoutRowid =\n this.tableMetadataArgs.withoutRowid === true ? true : false\n this.tablePath = this.connection.driver.buildTableName(\n this.tableName,\n this.schema,\n this.database,\n )\n this.orderBy =\n typeof this.tableMetadataArgs.orderBy === \"function\"\n ? this.tableMetadataArgs.orderBy(this.propertiesMap)\n : this.tableMetadataArgs.orderBy // todo: is propertiesMap available here? Looks like its not\n\n if (entitySkipConstructor !== undefined) {\n this.isAlwaysUsingConstructor = !entitySkipConstructor\n }\n\n this.isJunction =\n this.tableMetadataArgs.type === \"closure-junction\" ||\n this.tableMetadataArgs.type === \"junction\"\n this.isClosureJunction =\n this.tableMetadataArgs.type === \"closure-junction\"\n }\n\n /**\n * Registers a new column in the entity and recomputes all depend properties.\n */\n registerColumn(column: ColumnMetadata) {\n if (this.ownColumns.indexOf(column) !== -1) return\n\n this.ownColumns.push(column)\n this.columns = this.embeddeds.reduce(\n (columns, embedded) => columns.concat(embedded.columnsFromTree),\n this.ownColumns,\n )\n this.primaryColumns = this.columns.filter((column) => column.isPrimary)\n this.hasMultiplePrimaryKeys = this.primaryColumns.length > 1\n this.hasUUIDGeneratedColumns =\n this.columns.filter(\n (column) =>\n column.isGenerated || column.generationStrategy === \"uuid\",\n ).length > 0\n this.propertiesMap = this.createPropertiesMap()\n if (this.childEntityMetadatas)\n this.childEntityMetadatas.forEach((entityMetadata) =>\n entityMetadata.registerColumn(column),\n )\n }\n\n /**\n * Creates a special object - all columns and relations of the object (plus columns and relations from embeds)\n * in a special format - { propertyName: propertyName }.\n *\n * example: Post{ id: number, name: string, counterEmbed: { count: number }, category: Category }.\n * This method will create following object:\n * { id: \"id\", counterEmbed: { count: \"counterEmbed.count\" }, category: \"category\" }\n */\n createPropertiesMap(): { [name: string]: string | any } {\n const map: { [name: string]: string | any } = {}\n this.columns.forEach((column) =>\n OrmUtils.mergeDeep(map, column.createValueMap(column.propertyPath)),\n )\n this.relations.forEach((relation) =>\n OrmUtils.mergeDeep(\n map,\n relation.createValueMap(relation.propertyPath),\n ),\n )\n return map\n }\n\n /**\n * Checks if entity has any column which rely on returning data,\n * e.g. columns with auto generated value, DEFAULT values considered as dependant of returning data.\n * For example, if we need to have RETURNING after INSERT (or we need returned id for DBs not supporting RETURNING),\n * it means we cannot execute bulk inserts in some cases.\n */\n getInsertionReturningColumns(): ColumnMetadata[] {\n return this.columns.filter((column) => {\n return (\n column.default !== undefined ||\n column.isGenerated ||\n column.isCreateDate ||\n column.isUpdateDate ||\n column.isDeleteDate ||\n column.isVersion\n )\n })\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../../src/metadata/EntityMetadata.ts"],"names":[],"mappings":";;;AAGA,wF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oB,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,EAAE,CACjD,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,CACxC,CAAA;IACT,CAAC;IAED;;;;;;;OAOG;IACH,mBAAmB;QACf,MAAM,GAAG,GAAqC,EAAE,CAAA;QAChD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAC5B,mBAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CACtE,CAAA;QACD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAChC,mBAAQ,CAAC,SAAS,CACd,GAAG,EACH,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC,CACjD,CACJ,CAAA;QACD,OAAO,GAAG,CAAA;IACd,CAAC;IAED;;;;;OAKG;IACH,4BAA4B;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;YAClC,OAAO,CACH,MAAM,CAAC,OAAO,KAAK,SAAS;gBAC5B,MAAM,CAAC,WAAW;gBAClB,MAAM,CAAC,YAAY;gBACnB,MAAM,CAAC,YAAY;gBACnB,MAAM,CAAC,YAAY;gBACnB,MAAM,CAAC,SAAS,CACnB,CAAA;QACL,CAAC,CAAC,CAAA;IACN,CAAC;CACJ;AA7kCD,wCA6kCC","file":"EntityMetadata.js","sourcesContent":["import { QueryRunner, SelectQueryBuilder } from \"..\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { CannotCreateEntityIdMapError } from \"../error/CannotCreateEntityIdMapError\"\nimport { OrderByCondition } from \"../find-options/OrderByCondition\"\nimport { TableMetadataArgs } from \"../metadata-args/TableMetadataArgs\"\nimport { TreeMetadataArgs } from \"../metadata-args/TreeMetadataArgs\"\nimport { OrmUtils } from \"../util/OrmUtils\"\nimport { CheckMetadata } from \"./CheckMetadata\"\nimport { ColumnMetadata } from \"./ColumnMetadata\"\nimport { EmbeddedMetadata } from \"./EmbeddedMetadata\"\nimport { EntityListenerMetadata } from \"./EntityListenerMetadata\"\nimport { ExclusionMetadata } from \"./ExclusionMetadata\"\nimport { ForeignKeyMetadata } from \"./ForeignKeyMetadata\"\nimport { IndexMetadata } from \"./IndexMetadata\"\nimport { RelationCountMetadata } from \"./RelationCountMetadata\"\nimport { RelationIdMetadata } from \"./RelationIdMetadata\"\nimport { RelationMetadata } from \"./RelationMetadata\"\nimport { TableType } from \"./types/TableTypes\"\nimport { TreeType } from \"./types/TreeTypes\"\nimport { UniqueMetadata } from \"./UniqueMetadata\"\nimport { ClosureTreeOptions } from \"./types/ClosureTreeOptions\"\nimport { EntityPropertyNotFoundError } from \"../error/EntityPropertyNotFoundError\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\nimport { shorten } from \"../util/StringUtils\"\n\n/**\n * Contains all entity metadata.\n */\nexport class EntityMetadata {\n readonly \"@instanceof\" = Symbol.for(\"EntityMetadata\")\n\n // -------------------------------------------------------------------------\n // Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection where this entity metadata is created.\n */\n connection: DataSource\n\n /**\n * Metadata arguments used to build this entity metadata.\n */\n tableMetadataArgs: TableMetadataArgs\n\n /**\n * If entity's table is a closure-typed table, then this entity will have a closure junction table metadata.\n */\n closureJunctionTable: EntityMetadata\n\n /**\n * If this is entity metadata for a junction closure table then its owner closure table metadata will be set here.\n */\n parentClosureEntityMetadata: EntityMetadata\n\n /**\n * Parent's entity metadata. Used in inheritance patterns.\n */\n parentEntityMetadata: EntityMetadata\n\n /**\n * Children entity metadatas. Used in inheritance patterns.\n */\n childEntityMetadatas: EntityMetadata[] = []\n\n /**\n * All \"inheritance tree\" from a target entity.\n * For example for target Post < ContentModel < Unit it will be an array of [Post, ContentModel, Unit].\n * It also contains child entities for single table inheritance.\n */\n inheritanceTree: Function[] = []\n\n /**\n * Table type. Tables can be closure, junction, etc.\n */\n tableType: TableType = \"regular\"\n\n /**\n * Target class to which this entity metadata is bind.\n * Note, that when using table inheritance patterns target can be different rather then table's target.\n * For virtual tables which lack of real entity (like junction tables) target is equal to their table name.\n */\n target: Function | string\n\n /**\n * Gets the name of the target.\n */\n targetName: string\n\n /**\n * Entity's name.\n * Equal to entity target class's name if target is set to table.\n * If target class is not then then it equals to table name.\n */\n name: string\n\n /**\n * View's expression.\n * Used in views\n */\n expression?: string | ((connection: DataSource) => SelectQueryBuilder<any>)\n\n /**\n * View's dependencies.\n * Used in views\n */\n dependsOn?: Set<Function | string>\n\n /**\n * Enables Sqlite \"WITHOUT ROWID\" modifier for the \"CREATE TABLE\" statement\n */\n withoutRowid?: boolean = false\n\n /**\n * Original user-given table name (taken from schema or @Entity(tableName) decorator).\n * If user haven't specified a table name this property will be undefined.\n */\n givenTableName?: string\n\n /**\n * Entity table name in the database.\n * This is final table name of the entity.\n * This name already passed naming strategy, and generated based on\n * multiple criteria, including user table name and global table prefix.\n */\n tableName: string\n\n /**\n * Entity table path. Contains database name, schema name and table name.\n * E.g. myDB.mySchema.myTable\n */\n tablePath: string\n\n /**\n * Gets the table name without global table prefix.\n * When querying table you need a table name with prefix, but in some scenarios,\n * for example when you want to name a junction table that contains names of two other tables,\n * you may want a table name without prefix.\n */\n tableNameWithoutPrefix: string\n\n /**\n * Indicates if schema will be synchronized for this entity or not.\n */\n synchronize: boolean = true\n\n /**\n * Table's database engine type (like \"InnoDB\", \"MyISAM\", etc).\n */\n engine?: string\n\n /**\n * Database name.\n */\n database?: string\n\n /**\n * Schema name. Used in Postgres and Sql Server.\n */\n schema?: string\n\n /**\n * Specifies a default order by used for queries from this table when no explicit order by is specified.\n */\n orderBy?: OrderByCondition\n\n /**\n * If this entity metadata's table using one of the inheritance patterns,\n * then this will contain what pattern it uses.\n */\n inheritancePattern?: \"STI\" /*|\"CTI\"*/\n\n /**\n * Checks if there any non-nullable column exist in this entity.\n */\n hasNonNullableRelations: boolean = false\n\n /**\n * Indicates if this entity metadata of a junction table, or not.\n * Junction table is a table created by many-to-many relationship.\n *\n * Its also possible to understand if entity is junction via tableType.\n */\n isJunction: boolean = false\n\n /**\n * Indicates if the entity should be instantiated using the constructor\n * or via allocating a new object via `Object.create()`.\n */\n isAlwaysUsingConstructor: boolean = true\n\n /**\n * Indicates if this entity is a tree, what type of tree it is.\n */\n treeType?: TreeType\n\n /**\n * Indicates if this entity is a tree, what options of tree it has.\n */\n treeOptions?: ClosureTreeOptions\n\n /**\n * Checks if this table is a junction table of the closure table.\n * This type is for tables that contain junction metadata of the closure tables.\n */\n isClosureJunction: boolean = false\n\n /**\n * Checks if entity's table has multiple primary columns.\n */\n hasMultiplePrimaryKeys: boolean = false\n\n /**\n * Indicates if this entity metadata has uuid generated columns.\n */\n hasUUIDGeneratedColumns: boolean = false\n\n /**\n * If this entity metadata is a child table of some table, it should have a discriminator value.\n * Used to store a value in a discriminator column.\n */\n discriminatorValue?: string\n\n /**\n * Entity's column metadatas defined by user.\n */\n ownColumns: ColumnMetadata[] = []\n\n /**\n * Columns of the entity, including columns that are coming from the embeddeds of this entity.\n */\n columns: ColumnMetadata[] = []\n\n /**\n * Ancestor columns used only in closure junction tables.\n */\n ancestorColumns: ColumnMetadata[] = []\n\n /**\n * Descendant columns used only in closure junction tables.\n */\n descendantColumns: ColumnMetadata[] = []\n\n /**\n * All columns except for virtual columns.\n */\n nonVirtualColumns: ColumnMetadata[] = []\n\n /**\n * In the case if this entity metadata is junction table's entity metadata,\n * this will contain all referenced columns of owner entity.\n */\n ownerColumns: ColumnMetadata[] = []\n\n /**\n * In the case if this entity metadata is junction table's entity metadata,\n * this will contain all referenced columns of inverse entity.\n */\n inverseColumns: ColumnMetadata[] = []\n\n /**\n * Gets the column with generated flag.\n */\n generatedColumns: ColumnMetadata[] = []\n\n /**\n * Gets the object id column used with mongodb database.\n */\n objectIdColumn?: ColumnMetadata\n\n /**\n * Gets entity column which contains a create date value.\n */\n createDateColumn?: ColumnMetadata\n\n /**\n * Gets entity column which contains an update date value.\n */\n updateDateColumn?: ColumnMetadata\n\n /**\n * Gets entity column which contains a delete date value.\n */\n deleteDateColumn?: ColumnMetadata\n\n /**\n * Gets entity column which contains an entity version.\n */\n versionColumn?: ColumnMetadata\n\n /**\n * Gets the discriminator column used to store entity identificator in single-table inheritance tables.\n */\n discriminatorColumn?: ColumnMetadata\n\n /**\n * Special column that stores tree level in tree entities.\n */\n treeLevelColumn?: ColumnMetadata\n\n /**\n * Nested set's left value column.\n * Used only in tree entities with nested set pattern applied.\n */\n nestedSetLeftColumn?: ColumnMetadata\n\n /**\n * Nested set's right value column.\n * Used only in tree entities with nested set pattern applied.\n */\n nestedSetRightColumn?: ColumnMetadata\n\n /**\n * Materialized path column.\n * Used only in tree entities with materialized path pattern applied.\n */\n materializedPathColumn?: ColumnMetadata\n\n /**\n * Gets the primary columns.\n */\n primaryColumns: ColumnMetadata[] = []\n\n /**\n * Entity's relation metadatas.\n */\n ownRelations: RelationMetadata[] = []\n\n /**\n * Relations of the entity, including relations that are coming from the embeddeds of this entity.\n */\n relations: RelationMetadata[] = []\n\n /**\n * List of eager relations this metadata has.\n */\n eagerRelations: RelationMetadata[] = []\n\n /**\n * List of eager relations this metadata has.\n */\n lazyRelations: RelationMetadata[] = []\n\n /**\n * Gets only one-to-one relations of the entity.\n */\n oneToOneRelations: RelationMetadata[] = []\n\n /**\n * Gets only owner one-to-one relations of the entity.\n */\n ownerOneToOneRelations: RelationMetadata[] = []\n\n /**\n * Gets only one-to-many relations of the entity.\n */\n oneToManyRelations: RelationMetadata[] = []\n\n /**\n * Gets only many-to-one relations of the entity.\n */\n manyToOneRelations: RelationMetadata[] = []\n\n /**\n * Gets only many-to-many relations of the entity.\n */\n manyToManyRelations: RelationMetadata[] = []\n\n /**\n * Gets only owner many-to-many relations of the entity.\n */\n ownerManyToManyRelations: RelationMetadata[] = []\n\n /**\n * Gets only owner one-to-one and many-to-one relations.\n */\n relationsWithJoinColumns: RelationMetadata[] = []\n\n /**\n * Tree parent relation. Used only in tree-tables.\n */\n treeParentRelation?: RelationMetadata\n\n /**\n * Tree children relation. Used only in tree-tables.\n */\n treeChildrenRelation?: RelationMetadata\n\n /**\n * Entity's relation id metadatas.\n */\n relationIds: RelationIdMetadata[] = []\n\n /**\n * Entity's relation id metadatas.\n */\n relationCounts: RelationCountMetadata[] = []\n\n /**\n * Entity's foreign key metadatas.\n */\n foreignKeys: ForeignKeyMetadata[] = []\n\n /**\n * Entity's embedded metadatas.\n */\n embeddeds: EmbeddedMetadata[] = []\n\n /**\n * All embeddeds - embeddeds from this entity metadata and from all child embeddeds, etc.\n */\n allEmbeddeds: EmbeddedMetadata[] = []\n\n /**\n * Entity's own indices.\n */\n ownIndices: IndexMetadata[] = []\n\n /**\n * Entity's index metadatas.\n */\n indices: IndexMetadata[] = []\n\n /**\n * Entity's unique metadatas.\n */\n uniques: UniqueMetadata[] = []\n\n /**\n * Entity's own uniques.\n */\n ownUniques: UniqueMetadata[] = []\n\n /**\n * Entity's check metadatas.\n */\n checks: CheckMetadata[] = []\n\n /**\n * Entity's exclusion metadatas.\n */\n exclusions: ExclusionMetadata[] = []\n\n /**\n * Entity's own listener metadatas.\n */\n ownListeners: EntityListenerMetadata[] = []\n\n /**\n * Entity listener metadatas.\n */\n listeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER LOAD\" type.\n */\n afterLoadListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER INSERT\" type.\n */\n beforeInsertListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER INSERT\" type.\n */\n afterInsertListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER UPDATE\" type.\n */\n beforeUpdateListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER UPDATE\" type.\n */\n afterUpdateListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER REMOVE\" type.\n */\n beforeRemoveListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"BEFORE SOFT REMOVE\" type.\n */\n beforeSoftRemoveListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"BEFORE RECOVER\" type.\n */\n beforeRecoverListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER REMOVE\" type.\n */\n afterRemoveListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER SOFT REMOVE\" type.\n */\n afterSoftRemoveListeners: EntityListenerMetadata[] = []\n\n /**\n * Listener metadatas with \"AFTER RECOVER\" type.\n */\n afterRecoverListeners: EntityListenerMetadata[] = []\n\n /**\n * Map of columns and relations of the entity.\n *\n * example: Post{ id: number, name: string, counterEmbed: { count: number }, category: Category }.\n * This method will create following object:\n * { id: \"id\", counterEmbed: { count: \"counterEmbed.count\" }, category: \"category\" }\n */\n propertiesMap: ObjectLiteral\n\n // ---------------------------------------------------------------------\n // Constructor\n // ---------------------------------------------------------------------\n\n constructor(options: {\n connection: DataSource\n inheritanceTree?: Function[]\n inheritancePattern?: \"STI\" /*|\"CTI\"*/\n tableTree?: TreeMetadataArgs\n parentClosureEntityMetadata?: EntityMetadata\n args: TableMetadataArgs\n }) {\n this.connection = options.connection\n this.inheritanceTree = options.inheritanceTree || []\n this.inheritancePattern = options.inheritancePattern\n this.treeType = options.tableTree ? options.tableTree.type : undefined\n this.treeOptions = options.tableTree\n ? options.tableTree.options\n : undefined\n this.parentClosureEntityMetadata = options.parentClosureEntityMetadata!\n this.tableMetadataArgs = options.args\n this.target = this.tableMetadataArgs.target\n this.tableType = this.tableMetadataArgs.type\n this.expression = this.tableMetadataArgs.expression\n this.withoutRowid = this.tableMetadataArgs.withoutRowid\n this.dependsOn = this.tableMetadataArgs.dependsOn\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new entity.\n */\n create(\n queryRunner?: QueryRunner,\n options?: { fromDeserializer?: boolean; pojo?: boolean },\n ): any {\n const pojo = options && options.pojo === true ? true : false\n // if target is set to a function (e.g. class) that can be created then create it\n let ret: any\n if (typeof this.target === \"function\" && !pojo) {\n if (!options?.fromDeserializer || this.isAlwaysUsingConstructor) {\n ret = new (<any>this.target)()\n } else {\n ret = Object.create(this.target.prototype)\n }\n } else {\n // otherwise simply return a new empty object\n ret = {}\n }\n\n // add \"typename\" property\n if (this.connection.options.typename) {\n ret[this.connection.options.typename] = this.targetName\n }\n\n this.lazyRelations.forEach((relation) =>\n this.connection.relationLoader.enableLazyLoad(\n relation,\n ret,\n queryRunner,\n ),\n )\n return ret\n }\n\n /**\n * Checks if given entity has an id.\n */\n hasId(entity: ObjectLiteral): boolean {\n if (!entity) return false\n\n return this.primaryColumns.every((primaryColumn) => {\n const value = primaryColumn.getEntityValue(entity)\n return value !== null && value !== undefined && value !== \"\"\n })\n }\n\n /**\n * Checks if given entity / object contains ALL primary keys entity must have.\n * Returns true if it contains all of them, false if at least one of them is not defined.\n */\n hasAllPrimaryKeys(entity: ObjectLiteral): boolean {\n return this.primaryColumns.every((primaryColumn) => {\n const value = primaryColumn.getEntityValue(entity)\n return value !== null && value !== undefined\n })\n }\n\n /**\n * Ensures that given object is an entity id map.\n * If given id is an object then it means its already id map.\n * If given id isn't an object then it means its a value of the id column\n * and it creates a new id map with this value and name of the primary column.\n */\n ensureEntityIdMap(id: any): ObjectLiteral {\n if (ObjectUtils.isObject(id)) return id\n\n if (this.hasMultiplePrimaryKeys)\n throw new CannotCreateEntityIdMapError(this, id)\n\n return this.primaryColumns[0].createValueMap(id)\n }\n\n /**\n * Gets primary keys of the entity and returns them in a literal object.\n * For example, for Post{ id: 1, title: \"hello\" } where id is primary it will return { id: 1 }\n * For multiple primary keys it returns multiple keys in object.\n * For primary keys inside embeds it returns complex object literal with keys in them.\n */\n getEntityIdMap(\n entity: ObjectLiteral | undefined,\n ): ObjectLiteral | undefined {\n if (!entity) return undefined\n\n return EntityMetadata.getValueMap(entity, this.primaryColumns, {\n skipNulls: true,\n })\n }\n\n /**\n * Creates a \"mixed id map\".\n * If entity has multiple primary keys (ids) then it will return just regular id map, like what getEntityIdMap returns.\n * But if entity has a single primary key then it will return just value of the id column of the entity, just value.\n * This is called mixed id map.\n */\n getEntityIdMixedMap(\n entity: ObjectLiteral | undefined,\n ): ObjectLiteral | undefined {\n if (!entity) return entity\n\n const idMap = this.getEntityIdMap(entity)\n if (this.hasMultiplePrimaryKeys) {\n return idMap\n } else if (idMap) {\n return this.primaryColumns[0].getEntityValue(idMap) // todo: what about parent primary column?\n }\n\n return idMap\n }\n\n /**\n * Compares two different entities by their ids.\n * Returns true if they match, false otherwise.\n */\n compareEntities(\n firstEntity: ObjectLiteral,\n secondEntity: ObjectLiteral,\n ): boolean {\n const firstEntityIdMap = this.getEntityIdMap(firstEntity)\n if (!firstEntityIdMap) return false\n\n const secondEntityIdMap = this.getEntityIdMap(secondEntity)\n if (!secondEntityIdMap) return false\n\n return OrmUtils.compareIds(firstEntityIdMap, secondEntityIdMap)\n }\n\n /**\n * Finds column with a given property name.\n */\n findColumnWithPropertyName(\n propertyName: string,\n ): ColumnMetadata | undefined {\n return this.columns.find(\n (column) => column.propertyName === propertyName,\n )\n }\n\n /**\n * Finds column with a given database name.\n */\n findColumnWithDatabaseName(\n databaseName: string,\n ): ColumnMetadata | undefined {\n return this.columns.find(\n (column) => column.databaseName === databaseName,\n )\n }\n\n /**\n * Checks if there is a column or relationship with a given property path.\n */\n hasColumnWithPropertyPath(propertyPath: string): boolean {\n const hasColumn = this.columns.some(\n (column) => column.propertyPath === propertyPath,\n )\n return hasColumn || this.hasRelationWithPropertyPath(propertyPath)\n }\n\n /**\n * Finds column with a given property path.\n */\n findColumnWithPropertyPath(\n propertyPath: string,\n ): ColumnMetadata | undefined {\n const column = this.columns.find(\n (column) => column.propertyPath === propertyPath,\n )\n if (column) return column\n\n // in the case if column with property path was not found, try to find a relation with such property path\n // if we find relation and it has a single join column then its the column user was seeking\n const relation = this.relations.find(\n (relation) => relation.propertyPath === propertyPath,\n )\n if (relation && relation.joinColumns.length === 1)\n return relation.joinColumns[0]\n\n return undefined\n }\n\n /**\n * Finds column with a given property path.\n * Does not search in relation unlike findColumnWithPropertyPath.\n */\n findColumnWithPropertyPathStrict(\n propertyPath: string,\n ): ColumnMetadata | undefined {\n return this.columns.find(\n (column) => column.propertyPath === propertyPath,\n )\n }\n\n /**\n * Finds columns with a given property path.\n * Property path can match a relation, and relations can contain multiple columns.\n */\n findColumnsWithPropertyPath(propertyPath: string): ColumnMetadata[] {\n const column = this.columns.find(\n (column) => column.propertyPath === propertyPath,\n )\n if (column) return [column]\n\n // in the case if column with property path was not found, try to find a relation with such property path\n // if we find relation and it has a single join column then its the column user was seeking\n const relation = this.findRelationWithPropertyPath(propertyPath)\n if (relation && relation.joinColumns) return relation.joinColumns\n\n return []\n }\n\n /**\n * Checks if there is a relation with the given property path.\n */\n hasRelationWithPropertyPath(propertyPath: string): boolean {\n return this.relations.some(\n (relation) => relation.propertyPath === propertyPath,\n )\n }\n\n /**\n * Finds relation with the given property path.\n */\n findRelationWithPropertyPath(\n propertyPath: string,\n ): RelationMetadata | undefined {\n return this.relations.find(\n (relation) => relation.propertyPath === propertyPath,\n )\n }\n\n /**\n * Checks if there is an embedded with a given property path.\n */\n hasEmbeddedWithPropertyPath(propertyPath: string): boolean {\n return this.allEmbeddeds.some(\n (embedded) => embedded.propertyPath === propertyPath,\n )\n }\n\n /**\n * Finds embedded with a given property path.\n */\n findEmbeddedWithPropertyPath(\n propertyPath: string,\n ): EmbeddedMetadata | undefined {\n return this.allEmbeddeds.find(\n (embedded) => embedded.propertyPath === propertyPath,\n )\n }\n\n /**\n * Returns an array of databaseNames mapped from provided propertyPaths\n */\n mapPropertyPathsToColumns(propertyPaths: string[]) {\n return propertyPaths.map((propertyPath) => {\n const column = this.findColumnWithPropertyPath(propertyPath)\n if (column == null) {\n throw new EntityPropertyNotFoundError(propertyPath, this)\n }\n return column\n })\n }\n\n /**\n * Iterates through entity and finds and extracts all values from relations in the entity.\n * If relation value is an array its being flattened.\n */\n extractRelationValuesFromEntity(\n entity: ObjectLiteral,\n relations: RelationMetadata[],\n ): [RelationMetadata, any, EntityMetadata][] {\n const relationsAndValues: [RelationMetadata, any, EntityMetadata][] = []\n relations.forEach((relation) => {\n const value = relation.getEntityValue(entity)\n if (Array.isArray(value)) {\n value.forEach((subValue) =>\n relationsAndValues.push([\n relation,\n subValue,\n EntityMetadata.getInverseEntityMetadata(\n subValue,\n relation,\n ),\n ]),\n )\n } else if (value) {\n relationsAndValues.push([\n relation,\n value,\n EntityMetadata.getInverseEntityMetadata(value, relation),\n ])\n }\n })\n return relationsAndValues\n }\n\n /**\n * In the case of SingleTableInheritance, find the correct metadata\n * for a given value.\n *\n * @param value The value to find the metadata for.\n * @returns The found metadata for the entity or the base metadata if no matching metadata\n * was found in the whole inheritance tree.\n */\n findInheritanceMetadata(value: any): EntityMetadata {\n // Check for single table inheritance and find the correct metadata in that case.\n // Goal is to use the correct discriminator as we could have a repository\n // for an (abstract) base class and thus the target would not match.\n\n if (\n this.inheritancePattern === \"STI\" &&\n this.childEntityMetadatas.length > 0\n ) {\n // There could be a column on the base class that can manually be set to override the type.\n let manuallySetDiscriminatorValue: unknown\n if (this.discriminatorColumn) {\n manuallySetDiscriminatorValue =\n value[this.discriminatorColumn.propertyName]\n }\n return (\n this.childEntityMetadatas.find(\n (meta) =>\n manuallySetDiscriminatorValue ===\n meta.discriminatorValue ||\n value.constructor === meta.target,\n ) || this\n )\n }\n return this\n }\n\n // -------------------------------------------------------------------------\n // Private Static Methods\n // -------------------------------------------------------------------------\n\n private static getInverseEntityMetadata(\n value: any,\n relation: RelationMetadata,\n ): EntityMetadata {\n return relation.inverseEntityMetadata.findInheritanceMetadata(value)\n }\n\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a property paths for a given entity.\n *\n * @deprecated\n */\n static createPropertyPath(\n metadata: EntityMetadata,\n entity: ObjectLiteral,\n prefix: string = \"\",\n ) {\n const paths: string[] = []\n Object.keys(entity).forEach((key) => {\n // check for function is needed in the cases when createPropertyPath used on values contain a function as a value\n // example: .update().set({ name: () => `SUBSTR('', 1, 2)` })\n const parentPath = prefix ? prefix + \".\" + key : key\n if (metadata.hasEmbeddedWithPropertyPath(parentPath)) {\n const subPaths = this.createPropertyPath(\n metadata,\n entity[key],\n parentPath,\n )\n paths.push(...subPaths)\n } else {\n const path = prefix ? prefix + \".\" + key : key\n paths.push(path)\n }\n })\n return paths\n }\n\n /**\n * Finds difference between two entity id maps.\n * Returns items that exist in the first array and absent in the second array.\n */\n static difference(\n firstIdMaps: ObjectLiteral[],\n secondIdMaps: ObjectLiteral[],\n ): ObjectLiteral[] {\n return firstIdMaps.filter((firstIdMap) => {\n return !secondIdMaps.find((secondIdMap) =>\n OrmUtils.compareIds(firstIdMap, secondIdMap),\n )\n })\n }\n\n /**\n * Creates value map from the given values and columns.\n * Examples of usages are primary columns map and join columns map.\n */\n static getValueMap(\n entity: ObjectLiteral,\n columns: ColumnMetadata[],\n options?: { skipNulls?: boolean },\n ): ObjectLiteral | undefined {\n return columns.reduce((map, column) => {\n const value = column.getEntityValueMap(entity, options)\n\n // make sure that none of the values of the columns are not missing\n if (map === undefined || value === null || value === undefined)\n return undefined\n\n return OrmUtils.mergeDeep(map, value)\n }, {} as ObjectLiteral | undefined)\n }\n\n // ---------------------------------------------------------------------\n // Public Builder Methods\n // ---------------------------------------------------------------------\n\n build() {\n const namingStrategy = this.connection.namingStrategy\n const entityPrefix = this.connection.options.entityPrefix\n const entitySkipConstructor =\n this.connection.options.entitySkipConstructor\n\n this.engine = this.tableMetadataArgs.engine\n this.database =\n this.tableMetadataArgs.type === \"entity-child\" &&\n this.parentEntityMetadata\n ? this.parentEntityMetadata.database\n : this.tableMetadataArgs.database\n if (this.tableMetadataArgs.schema) {\n this.schema = this.tableMetadataArgs.schema\n } else if (\n this.tableMetadataArgs.type === \"entity-child\" &&\n this.parentEntityMetadata\n ) {\n this.schema = this.parentEntityMetadata.schema\n } else if (this.connection.options?.hasOwnProperty(\"schema\")) {\n this.schema = (this.connection.options as any).schema\n }\n this.givenTableName =\n this.tableMetadataArgs.type === \"entity-child\" &&\n this.parentEntityMetadata\n ? this.parentEntityMetadata.givenTableName\n : this.tableMetadataArgs.name\n this.synchronize =\n this.tableMetadataArgs.synchronize === false ? false : true\n this.targetName =\n typeof this.tableMetadataArgs.target === \"function\"\n ? (this.tableMetadataArgs.target as any).name\n : this.tableMetadataArgs.target\n if (this.tableMetadataArgs.type === \"closure-junction\") {\n this.tableNameWithoutPrefix =\n namingStrategy.closureJunctionTableName(this.givenTableName!)\n } else if (\n this.tableMetadataArgs.type === \"entity-child\" &&\n this.parentEntityMetadata\n ) {\n this.tableNameWithoutPrefix = namingStrategy.tableName(\n this.parentEntityMetadata.targetName,\n this.parentEntityMetadata.givenTableName,\n )\n } else {\n this.tableNameWithoutPrefix = namingStrategy.tableName(\n this.targetName,\n this.givenTableName,\n )\n\n if (\n this.tableMetadataArgs.type === \"junction\" &&\n this.connection.driver.maxAliasLength &&\n this.connection.driver.maxAliasLength > 0 &&\n this.tableNameWithoutPrefix.length >\n this.connection.driver.maxAliasLength\n ) {\n // note: we are not using DriverUtils.buildAlias here because we would like to avoid\n // hashed table names. However, current algorithm also isn't perfect, but we cannot\n // change it, since it's a big breaking change. Planned to 0.4.0\n this.tableNameWithoutPrefix = shorten(\n this.tableNameWithoutPrefix,\n { separator: \"_\", segmentLength: 3 },\n )\n }\n }\n this.tableName = entityPrefix\n ? namingStrategy.prefixTableName(\n entityPrefix,\n this.tableNameWithoutPrefix,\n )\n : this.tableNameWithoutPrefix\n this.target = this.target ? this.target : this.tableName\n this.name = this.targetName ? this.targetName : this.tableName\n this.expression = this.tableMetadataArgs.expression\n this.withoutRowid =\n this.tableMetadataArgs.withoutRowid === true ? true : false\n this.tablePath = this.connection.driver.buildTableName(\n this.tableName,\n this.schema,\n this.database,\n )\n this.orderBy =\n typeof this.tableMetadataArgs.orderBy === \"function\"\n ? this.tableMetadataArgs.orderBy(this.propertiesMap)\n : this.tableMetadataArgs.orderBy // todo: is propertiesMap available here? Looks like its not\n\n if (entitySkipConstructor !== undefined) {\n this.isAlwaysUsingConstructor = !entitySkipConstructor\n }\n\n this.isJunction =\n this.tableMetadataArgs.type === \"closure-junction\" ||\n this.tableMetadataArgs.type === \"junction\"\n this.isClosureJunction =\n this.tableMetadataArgs.type === \"closure-junction\"\n }\n\n /**\n * Registers a new column in the entity and recomputes all depend properties.\n */\n registerColumn(column: ColumnMetadata) {\n if (this.ownColumns.indexOf(column) !== -1) return\n\n this.ownColumns.push(column)\n this.columns = this.embeddeds.reduce(\n (columns, embedded) => columns.concat(embedded.columnsFromTree),\n this.ownColumns,\n )\n this.primaryColumns = this.columns.filter((column) => column.isPrimary)\n this.hasMultiplePrimaryKeys = this.primaryColumns.length > 1\n this.hasUUIDGeneratedColumns =\n this.columns.filter(\n (column) =>\n column.isGenerated || column.generationStrategy === \"uuid\",\n ).length > 0\n this.propertiesMap = this.createPropertiesMap()\n if (this.childEntityMetadatas)\n this.childEntityMetadatas.forEach((entityMetadata) =>\n entityMetadata.registerColumn(column),\n )\n }\n\n /**\n * Creates a special object - all columns and relations of the object (plus columns and relations from embeds)\n * in a special format - { propertyName: propertyName }.\n *\n * example: Post{ id: number, name: string, counterEmbed: { count: number }, category: Category }.\n * This method will create following object:\n * { id: \"id\", counterEmbed: { count: \"counterEmbed.count\" }, category: \"category\" }\n */\n createPropertiesMap(): { [name: string]: string | any } {\n const map: { [name: string]: string | any } = {}\n this.columns.forEach((column) =>\n OrmUtils.mergeDeep(map, column.createValueMap(column.propertyPath)),\n )\n this.relations.forEach((relation) =>\n OrmUtils.mergeDeep(\n map,\n relation.createValueMap(relation.propertyPath),\n ),\n )\n return map\n }\n\n /**\n * Checks if entity has any column which rely on returning data,\n * e.g. columns with auto generated value, DEFAULT values considered as dependant of returning data.\n * For example, if we need to have RETURNING after INSERT (or we need returned id for DBs not supporting RETURNING),\n * it means we cannot execute bulk inserts in some cases.\n */\n getInsertionReturningColumns(): ColumnMetadata[] {\n return this.columns.filter((column) => {\n return (\n column.default !== undefined ||\n column.isGenerated ||\n column.isCreateDate ||\n column.isUpdateDate ||\n column.isDeleteDate ||\n column.isVersion\n )\n })\n }\n}\n"],"sourceRoot":".."}
@@ -378,6 +378,21 @@ class EntityMetadataBuilder {
378
378
  !entityMetadata.ownColumns.find((column) => column === discriminatorColumn)) {
379
379
  entityMetadata.ownColumns.push(discriminatorColumn);
380
380
  }
381
+ // also copy the inheritance pattern & tree metadata
382
+ // this comes in handy when inheritance and trees are used together
383
+ entityMetadata.inheritancePattern =
384
+ entityMetadata.parentEntityMetadata.inheritancePattern;
385
+ if (!entityMetadata.treeType &&
386
+ !!entityMetadata.parentEntityMetadata.treeType) {
387
+ entityMetadata.treeType =
388
+ entityMetadata.parentEntityMetadata.treeType;
389
+ entityMetadata.treeOptions =
390
+ entityMetadata.parentEntityMetadata.treeOptions;
391
+ entityMetadata.treeParentRelation =
392
+ entityMetadata.parentEntityMetadata.treeParentRelation;
393
+ entityMetadata.treeLevelColumn =
394
+ entityMetadata.parentEntityMetadata.treeLevelColumn;
395
+ }
381
396
  }
382
397
  const { namingStrategy } = this.connection;
383
398
  // check if tree is used then we need to add extra columns for specific tree types