typeorm 0.2.39-dev.cf281ef → 0.2.39-dev.ef33cf4

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 (38) hide show
  1. package/README.md +36 -36
  2. package/browser/decorator/entity-view/ViewEntity.js +1 -0
  3. package/browser/decorator/entity-view/ViewEntity.js.map +1 -1
  4. package/browser/decorator/options/ViewEntityOptions.d.ts +5 -0
  5. package/browser/decorator/options/ViewEntityOptions.js.map +1 -1
  6. package/browser/metadata/EntityMetadata.d.ts +5 -0
  7. package/browser/metadata/EntityMetadata.js +1 -0
  8. package/browser/metadata/EntityMetadata.js.map +1 -1
  9. package/browser/metadata-args/TableMetadataArgs.d.ts +4 -0
  10. package/browser/metadata-args/TableMetadataArgs.js.map +1 -1
  11. package/browser/migration/MigrationExecutor.js +4 -0
  12. package/browser/migration/MigrationExecutor.js.map +1 -1
  13. package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.js +2 -8
  14. package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
  15. package/browser/schema-builder/RdbmsSchemaBuilder.js +223 -148
  16. package/browser/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
  17. package/browser/schema-builder/util/ViewUtils.d.ts +7 -0
  18. package/browser/schema-builder/util/ViewUtils.js +25 -0
  19. package/browser/schema-builder/util/ViewUtils.js.map +1 -0
  20. package/decorator/entity-view/ViewEntity.js +1 -0
  21. package/decorator/entity-view/ViewEntity.js.map +1 -1
  22. package/decorator/options/ViewEntityOptions.d.ts +5 -0
  23. package/decorator/options/ViewEntityOptions.js.map +1 -1
  24. package/metadata/EntityMetadata.d.ts +5 -0
  25. package/metadata/EntityMetadata.js +1 -0
  26. package/metadata/EntityMetadata.js.map +1 -1
  27. package/metadata-args/TableMetadataArgs.d.ts +4 -0
  28. package/metadata-args/TableMetadataArgs.js.map +1 -1
  29. package/migration/MigrationExecutor.js +4 -0
  30. package/migration/MigrationExecutor.js.map +1 -1
  31. package/package.json +1 -1
  32. package/query-builder/transformer/RawSqlResultsToEntityTransformer.js +2 -8
  33. package/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
  34. package/schema-builder/RdbmsSchemaBuilder.js +222 -147
  35. package/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
  36. package/schema-builder/util/ViewUtils.d.ts +7 -0
  37. package/schema-builder/util/ViewUtils.js +28 -0
  38. package/schema-builder/util/ViewUtils.js.map +1 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/metadata/EntityMetadata.ts"],"names":[],"mappings":";;;;AAGA,sFAAmF;AAInF,6CAA0C;AAC1C,mDAA4C;AAgB5C;;GAEG;AACH;IA8cI,wEAAwE;IACxE,cAAc;IACd,wEAAwE;IAExE,wBAAY,OAOX;QA1bD;;WAEG;QACH,yBAAoB,GAAqB,EAAE,CAAC;QAE5C;;;;WAIG;QACH,oBAAe,GAAe,EAAE,CAAC;QAEjC;;WAEG;QACH,cAAS,GAAc,SAAS,CAAC;QA2BjC;;WAEG;QACH,iBAAY,GAAa,KAAK,CAAC;QA8B/B;;WAEG;QACH,gBAAW,GAAY,IAAI,CAAC;QA4B5B;;WAEG;QACH,4BAAuB,GAAY,KAAK,CAAC;QAEzC;;;;;WAKG;QACH,eAAU,GAAY,KAAK,CAAC;QAE5B;;;WAGG;QACH,6BAAwB,GAAY,IAAI,CAAC;QAYzC;;;WAGG;QACH,sBAAiB,GAAY,KAAK,CAAC;QAEnC;;WAEG;QACH,2BAAsB,GAAY,KAAK,CAAC;QAExC;;WAEG;QACH,4BAAuB,GAAY,KAAK,CAAC;QAQzC;;WAEG;QACH,eAAU,GAAqB,EAAE,CAAC;QAElC;;WAEG;QACH,YAAO,GAAqB,EAAE,CAAC;QAE/B;;WAEG;QACH,oBAAe,GAAqB,EAAE,CAAC;QAEvC;;WAEG;QACH,sBAAiB,GAAqB,EAAE,CAAC;QAEzC;;WAEG;QACH,sBAAiB,GAAqB,EAAE,CAAC;Q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,MAAM,GAAG,CAAC,CAAC;QAC7D,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAA,MAAM,IAAI,OAAA,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,kBAAkB,KAAK,MAAM,EAA1D,CAA0D,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QACpI,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAChD,IAAI,IAAI,CAAC,oBAAoB;YACzB,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,UAAA,cAAc,IAAI,OAAA,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,EAArC,CAAqC,CAAC,CAAC;IACnG,CAAC;IAED;;;;;;;OAOG;IACH,4CAAmB,GAAnB;QACI,IAAM,GAAG,GAAmC,EAAE,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAA,MAAM,IAAI,OAAA,mBAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAnE,CAAmE,CAAC,CAAC;QACpG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAA,QAAQ,IAAI,OAAA,mBAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAvE,CAAuE,CAAC,CAAC;QAC5G,OAAO,GAAG,CAAC;IACf,CAAC;IACL,qBAAC;AAAD,CA70BA,AA60BC,IAAA;AA70BY,wCAAc","file":"EntityMetadata.js","sourcesContent":["import {QueryRunner, SelectQueryBuilder} from \"..\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {Connection} from \"../connection/Connection\";\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 {shorten} from \"../util/StringUtils\";\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\";\n\n/**\n * Contains all entity metadata.\n */\nexport class EntityMetadata {\n\n // -------------------------------------------------------------------------\n // Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection where this entity metadata is created.\n */\n connection: Connection;\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: Connection) => SelectQueryBuilder<any>);\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 \"AFTER REMOVE\" type.\n */\n afterRemoveListeners: 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: Connection,\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 ? options.tableTree.options : 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 }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new entity.\n */\n create(queryRunner?: QueryRunner, options?: { fromDeserializer?: boolean }): any {\n // if target is set to a function (e.g. class) that can be created then create it\n let ret: any;\n if (this.target instanceof Function) {\n if (!options?.fromDeserializer || this.isAlwaysUsingConstructor) {\n ret = new (<any> this.target)();\n } else {\n ret = Object.create(this.target.prototype);\n }\n\n this.lazyRelations.forEach(relation => this.connection.relationLoader.enableLazyLoad(relation, ret, queryRunner));\n return ret;\n }\n\n // otherwise simply return a new empty object\n const newObject = {};\n this.lazyRelations.forEach(relation => this.connection.relationLoader.enableLazyLoad(relation, newObject, queryRunner));\n return newObject;\n }\n\n /**\n * Checks if given entity has an id.\n */\n hasId(entity: ObjectLiteral): boolean {\n if (!entity)\n 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 (id instanceof Object)\n 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(entity: ObjectLiteral|undefined): ObjectLiteral|undefined {\n if (!entity)\n return undefined;\n\n return EntityMetadata.getValueMap(entity, this.primaryColumns, { skipNulls: true });\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(entity: ObjectLiteral|undefined): ObjectLiteral|undefined {\n if (!entity)\n return entity;\n\n const idMap = this.getEntityIdMap(entity);\n if (this.hasMultiplePrimaryKeys) {\n return idMap;\n\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(firstEntity: ObjectLiteral, secondEntity: ObjectLiteral): boolean {\n\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(propertyName: string): ColumnMetadata|undefined {\n return this.columns.find(column => column.propertyName === propertyName);\n }\n\n /**\n * Finds column with a given database name.\n */\n findColumnWithDatabaseName(databaseName: string): ColumnMetadata|undefined {\n return this.columns.find(column => column.databaseName === databaseName);\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(column => column.propertyPath === propertyPath);\n return hasColumn || this.hasRelationWithPropertyPath(propertyPath);\n }\n\n /**\n * Finds column with a given property path.\n */\n findColumnWithPropertyPath(propertyPath: string): ColumnMetadata|undefined {\n const column = this.columns.find(column => column.propertyPath === propertyPath);\n if (column)\n 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(relation => relation.propertyPath === propertyPath);\n if (relation && relation.joinColumns.length === 1)\n return relation.joinColumns[0];\n\n return undefined;\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(column => column.propertyPath === propertyPath);\n if (column)\n 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)\n 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(relation => relation.propertyPath === propertyPath);\n }\n\n /**\n * Finds relation with the given property path.\n */\n findRelationWithPropertyPath(propertyPath: string): RelationMetadata|undefined {\n return this.relations.find(relation => relation.propertyPath === propertyPath);\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(embedded => embedded.propertyPath === propertyPath);\n }\n\n /**\n * Finds embedded with a given property path.\n */\n findEmbeddedWithPropertyPath(propertyPath: string): EmbeddedMetadata|undefined {\n return this.allEmbeddeds.find(embedded => embedded.propertyPath === propertyPath);\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(entity: ObjectLiteral, relations: RelationMetadata[]): [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 => relationsAndValues.push([relation, subValue, this.getInverseEntityMetadata(subValue, relation)]));\n } else if (value) {\n relationsAndValues.push([relation, value, this.getInverseEntityMetadata(value, relation)]);\n }\n });\n return relationsAndValues;\n }\n\n private getInverseEntityMetadata(value: any, relation: RelationMetadata): EntityMetadata {\n const childEntityMetadata = relation.inverseEntityMetadata.childEntityMetadatas.find(metadata =>\n metadata.target === value.constructor\n );\n return childEntityMetadata ? childEntityMetadata : 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(metadata: EntityMetadata, entity: ObjectLiteral, prefix: string = \"\") {\n const paths: string[] = [];\n Object.keys(entity).forEach(key => {\n\n // check for function is needed in the cases when createPropertyPath used on values containg 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(metadata, entity[key], parentPath);\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(firstIdMaps: ObjectLiteral[], secondIdMaps: ObjectLiteral[]): ObjectLiteral[] {\n return firstIdMaps.filter(firstIdMap => {\n return !secondIdMaps.find(secondIdMap => OrmUtils.compareIds(firstIdMap, secondIdMap));\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(entity: ObjectLiteral, columns: ColumnMetadata[], options?: { skipNulls?: boolean }): 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 = this.connection.options.entitySkipConstructor;\n\n this.engine = this.tableMetadataArgs.engine;\n this.database = this.tableMetadataArgs.type === \"entity-child\" && this.parentEntityMetadata ? this.parentEntityMetadata.database : this.tableMetadataArgs.database;\n if (this.tableMetadataArgs.schema) {\n this.schema = this.tableMetadataArgs.schema;\n }\n else if ((this.tableMetadataArgs.type === \"entity-child\") && this.parentEntityMetadata) {\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 = this.tableMetadataArgs.type === \"entity-child\" && this.parentEntityMetadata ? this.parentEntityMetadata.givenTableName : this.tableMetadataArgs.name;\n this.synchronize = this.tableMetadataArgs.synchronize === false ? false : true;\n this.targetName = this.tableMetadataArgs.target instanceof Function ? (this.tableMetadataArgs.target as any).name : this.tableMetadataArgs.target;\n if (this.tableMetadataArgs.type === \"closure-junction\") {\n this.tableNameWithoutPrefix = namingStrategy.closureJunctionTableName(this.givenTableName!);\n } else if (this.tableMetadataArgs.type === \"entity-child\" && this.parentEntityMetadata) {\n this.tableNameWithoutPrefix = namingStrategy.tableName(this.parentEntityMetadata.targetName, this.parentEntityMetadata.givenTableName);\n } else {\n this.tableNameWithoutPrefix = namingStrategy.tableName(this.targetName, this.givenTableName);\n\n if (this.connection.driver.maxAliasLength && this.connection.driver.maxAliasLength > 0 && this.tableNameWithoutPrefix.length > this.connection.driver.maxAliasLength) {\n this.tableNameWithoutPrefix = shorten(this.tableNameWithoutPrefix, { separator: \"_\", segmentLength: 3 });\n }\n }\n this.tableName = entityPrefix ? namingStrategy.prefixTableName(entityPrefix, this.tableNameWithoutPrefix) : 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 = this.tableMetadataArgs.withoutRowid === true ? true : false;\n this.tablePath = this.connection.driver.buildTableName(this.tableName, this.schema, this.database);\n this.orderBy = (this.tableMetadataArgs.orderBy instanceof Function) ? this.tableMetadataArgs.orderBy(this.propertiesMap) : 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 = this.tableMetadataArgs.type === \"closure-junction\" || this.tableMetadataArgs.type === \"junction\";\n this.isClosureJunction = 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)\n return;\n\n this.ownColumns.push(column);\n this.columns = this.embeddeds.reduce((columns, embedded) => columns.concat(embedded.columnsFromTree), this.ownColumns);\n this.primaryColumns = this.columns.filter(column => column.isPrimary);\n this.hasMultiplePrimaryKeys = this.primaryColumns.length > 1;\n this.hasUUIDGeneratedColumns = this.columns.filter(column => column.isGenerated || column.generationStrategy === \"uuid\").length > 0;\n this.propertiesMap = this.createPropertiesMap();\n if (this.childEntityMetadatas)\n this.childEntityMetadatas.forEach(entityMetadata => entityMetadata.registerColumn(column));\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 => OrmUtils.mergeDeep(map, column.createValueMap(column.propertyPath)));\n this.relations.forEach(relation => OrmUtils.mergeDeep(map, relation.createValueMap(relation.propertyPath)));\n return map;\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../../src/metadata/EntityMetadata.ts"],"names":[],"mappings":";;;;AAGA,sFAAmF;AAInF,6CAA0C;AAC1C,mDAA4C;AAgB5C;;GAEG;AACH;IAodI,wEAAwE;IACxE,cAAc;IACd,wEAAwE;IAExE,wBAAY,OAOX;QAhcD;;WAEG;QACH,yBAAoB,GAAqB,EAAE,CAAC;QAE5C;;;;WAIG;QACH,oBAAe,GAAe,EAAE,CAAC;QAEjC;;WAEG;QACH,cAAS,GAAc,SAAS,CAAC;QAiCjC;;WAEG;QACH,iBAAY,GAAa,KAAK,CAAC;QA8B/B;;WAEG;QACH,gBAAW,GAAY,IAAI,CAAC;QA4B5B;;WAEG;QACH,4BAAuB,GAAY,KAAK,CAAC;QAEzC;;;;;WAKG;QACH,eAAU,GAAY,KAAK,CAAC;QAE5B;;;WAGG;QACH,6BAAwB,GAAY,IAAI,CAAC;QAYzC;;;WAGG;QACH,sBAAiB,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E,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAvE,CAAuE,CAAC,CAAC;QAC5G,OAAO,GAAG,CAAC;IACf,CAAC;IACL,qBAAC;AAAD,CAp1BA,AAo1BC,IAAA;AAp1BY,wCAAc","file":"EntityMetadata.js","sourcesContent":["import {QueryRunner, SelectQueryBuilder} from \"..\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {Connection} from \"../connection/Connection\";\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 {shorten} from \"../util/StringUtils\";\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\";\n\n/**\n * Contains all entity metadata.\n */\nexport class EntityMetadata {\n\n // -------------------------------------------------------------------------\n // Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection where this entity metadata is created.\n */\n connection: Connection;\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: Connection) => 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 \"AFTER REMOVE\" type.\n */\n afterRemoveListeners: 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: Connection,\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 ? options.tableTree.options : 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(queryRunner?: QueryRunner, options?: { fromDeserializer?: boolean }): any {\n // if target is set to a function (e.g. class) that can be created then create it\n let ret: any;\n if (this.target instanceof Function) {\n if (!options?.fromDeserializer || this.isAlwaysUsingConstructor) {\n ret = new (<any> this.target)();\n } else {\n ret = Object.create(this.target.prototype);\n }\n\n this.lazyRelations.forEach(relation => this.connection.relationLoader.enableLazyLoad(relation, ret, queryRunner));\n return ret;\n }\n\n // otherwise simply return a new empty object\n const newObject = {};\n this.lazyRelations.forEach(relation => this.connection.relationLoader.enableLazyLoad(relation, newObject, queryRunner));\n return newObject;\n }\n\n /**\n * Checks if given entity has an id.\n */\n hasId(entity: ObjectLiteral): boolean {\n if (!entity)\n 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 (id instanceof Object)\n 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(entity: ObjectLiteral|undefined): ObjectLiteral|undefined {\n if (!entity)\n return undefined;\n\n return EntityMetadata.getValueMap(entity, this.primaryColumns, { skipNulls: true });\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(entity: ObjectLiteral|undefined): ObjectLiteral|undefined {\n if (!entity)\n return entity;\n\n const idMap = this.getEntityIdMap(entity);\n if (this.hasMultiplePrimaryKeys) {\n return idMap;\n\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(firstEntity: ObjectLiteral, secondEntity: ObjectLiteral): boolean {\n\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(propertyName: string): ColumnMetadata|undefined {\n return this.columns.find(column => column.propertyName === propertyName);\n }\n\n /**\n * Finds column with a given database name.\n */\n findColumnWithDatabaseName(databaseName: string): ColumnMetadata|undefined {\n return this.columns.find(column => column.databaseName === databaseName);\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(column => column.propertyPath === propertyPath);\n return hasColumn || this.hasRelationWithPropertyPath(propertyPath);\n }\n\n /**\n * Finds column with a given property path.\n */\n findColumnWithPropertyPath(propertyPath: string): ColumnMetadata|undefined {\n const column = this.columns.find(column => column.propertyPath === propertyPath);\n if (column)\n 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(relation => relation.propertyPath === propertyPath);\n if (relation && relation.joinColumns.length === 1)\n return relation.joinColumns[0];\n\n return undefined;\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(column => column.propertyPath === propertyPath);\n if (column)\n 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)\n 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(relation => relation.propertyPath === propertyPath);\n }\n\n /**\n * Finds relation with the given property path.\n */\n findRelationWithPropertyPath(propertyPath: string): RelationMetadata|undefined {\n return this.relations.find(relation => relation.propertyPath === propertyPath);\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(embedded => embedded.propertyPath === propertyPath);\n }\n\n /**\n * Finds embedded with a given property path.\n */\n findEmbeddedWithPropertyPath(propertyPath: string): EmbeddedMetadata|undefined {\n return this.allEmbeddeds.find(embedded => embedded.propertyPath === propertyPath);\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(entity: ObjectLiteral, relations: RelationMetadata[]): [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 => relationsAndValues.push([relation, subValue, this.getInverseEntityMetadata(subValue, relation)]));\n } else if (value) {\n relationsAndValues.push([relation, value, this.getInverseEntityMetadata(value, relation)]);\n }\n });\n return relationsAndValues;\n }\n\n private getInverseEntityMetadata(value: any, relation: RelationMetadata): EntityMetadata {\n const childEntityMetadata = relation.inverseEntityMetadata.childEntityMetadatas.find(metadata =>\n metadata.target === value.constructor\n );\n return childEntityMetadata ? childEntityMetadata : 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(metadata: EntityMetadata, entity: ObjectLiteral, prefix: string = \"\") {\n const paths: string[] = [];\n Object.keys(entity).forEach(key => {\n\n // check for function is needed in the cases when createPropertyPath used on values containg 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(metadata, entity[key], parentPath);\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(firstIdMaps: ObjectLiteral[], secondIdMaps: ObjectLiteral[]): ObjectLiteral[] {\n return firstIdMaps.filter(firstIdMap => {\n return !secondIdMaps.find(secondIdMap => OrmUtils.compareIds(firstIdMap, secondIdMap));\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(entity: ObjectLiteral, columns: ColumnMetadata[], options?: { skipNulls?: boolean }): 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 = this.connection.options.entitySkipConstructor;\n\n this.engine = this.tableMetadataArgs.engine;\n this.database = this.tableMetadataArgs.type === \"entity-child\" && this.parentEntityMetadata ? this.parentEntityMetadata.database : this.tableMetadataArgs.database;\n if (this.tableMetadataArgs.schema) {\n this.schema = this.tableMetadataArgs.schema;\n }\n else if ((this.tableMetadataArgs.type === \"entity-child\") && this.parentEntityMetadata) {\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 = this.tableMetadataArgs.type === \"entity-child\" && this.parentEntityMetadata ? this.parentEntityMetadata.givenTableName : this.tableMetadataArgs.name;\n this.synchronize = this.tableMetadataArgs.synchronize === false ? false : true;\n this.targetName = this.tableMetadataArgs.target instanceof Function ? (this.tableMetadataArgs.target as any).name : this.tableMetadataArgs.target;\n if (this.tableMetadataArgs.type === \"closure-junction\") {\n this.tableNameWithoutPrefix = namingStrategy.closureJunctionTableName(this.givenTableName!);\n } else if (this.tableMetadataArgs.type === \"entity-child\" && this.parentEntityMetadata) {\n this.tableNameWithoutPrefix = namingStrategy.tableName(this.parentEntityMetadata.targetName, this.parentEntityMetadata.givenTableName);\n } else {\n this.tableNameWithoutPrefix = namingStrategy.tableName(this.targetName, this.givenTableName);\n\n if (this.connection.driver.maxAliasLength && this.connection.driver.maxAliasLength > 0 && this.tableNameWithoutPrefix.length > this.connection.driver.maxAliasLength) {\n this.tableNameWithoutPrefix = shorten(this.tableNameWithoutPrefix, { separator: \"_\", segmentLength: 3 });\n }\n }\n this.tableName = entityPrefix ? namingStrategy.prefixTableName(entityPrefix, this.tableNameWithoutPrefix) : 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 = this.tableMetadataArgs.withoutRowid === true ? true : false;\n this.tablePath = this.connection.driver.buildTableName(this.tableName, this.schema, this.database);\n this.orderBy = (this.tableMetadataArgs.orderBy instanceof Function) ? this.tableMetadataArgs.orderBy(this.propertiesMap) : 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 = this.tableMetadataArgs.type === \"closure-junction\" || this.tableMetadataArgs.type === \"junction\";\n this.isClosureJunction = 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)\n return;\n\n this.ownColumns.push(column);\n this.columns = this.embeddeds.reduce((columns, embedded) => columns.concat(embedded.columnsFromTree), this.ownColumns);\n this.primaryColumns = this.columns.filter(column => column.isPrimary);\n this.hasMultiplePrimaryKeys = this.primaryColumns.length > 1;\n this.hasUUIDGeneratedColumns = this.columns.filter(column => column.isGenerated || column.generationStrategy === \"uuid\").length > 0;\n this.propertiesMap = this.createPropertiesMap();\n if (this.childEntityMetadatas)\n this.childEntityMetadatas.forEach(entityMetadata => entityMetadata.registerColumn(column));\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 => OrmUtils.mergeDeep(map, column.createValueMap(column.propertyPath)));\n this.relations.forEach(relation => OrmUtils.mergeDeep(map, relation.createValueMap(relation.propertyPath)));\n return map;\n }\n}\n"],"sourceRoot":".."}
@@ -45,6 +45,10 @@ export interface TableMetadataArgs {
45
45
  * View expression.
46
46
  */
47
47
  expression?: string | ((connection: Connection) => SelectQueryBuilder<any>);
48
+ /**
49
+ * View dependencies.
50
+ */
51
+ dependsOn?: Set<Function | string>;
48
52
  /**
49
53
  * Indicates if view is materialized
50
54
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/metadata-args/TableMetadataArgs.ts"],"names":[],"mappings":"","file":"TableMetadataArgs.js","sourcesContent":["import {Connection, SelectQueryBuilder} from \"..\";\nimport {OrderByCondition} from \"../find-options/OrderByCondition\";\nimport {TableType} from \"../metadata/types/TableTypes\";\n\n/**\n * Arguments for TableMetadata class, helps to construct an TableMetadata object.\n */\nexport interface TableMetadataArgs {\n\n /**\n * Class to which table is applied.\n * Function target is a table defined in the class.\n * String target is a table defined in a json schema.\n */\n target: Function|string;\n\n /**\n * Table's name. If name is not set then table's name will be generated from target's name.\n */\n name?: string;\n\n /**\n * Table type. Tables can be abstract, closure, junction, embedded, etc.\n */\n type: TableType;\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|((object: any) => OrderByCondition|any);\n\n /**\n * Table's database engine type (like \"InnoDB\", \"MyISAM\", etc).\n */\n engine?: string;\n\n /**\n * Database name. Used in MySql and Sql Server.\n */\n database?: string;\n\n /**\n * Schema name. Used in Postgres and Sql Server.\n */\n schema?: string;\n\n /**\n * Indicates if schema synchronization is enabled or disabled for this entity.\n * If it will be set to false then schema sync will and migrations ignore this entity.\n * By default schema synchronization is enabled for all entities.\n */\n synchronize?: boolean;\n\n /**\n * View expression.\n */\n expression?: string|((connection: Connection) => SelectQueryBuilder<any>);\n\n /**\n * Indicates if view is materialized\n */\n materialized?: boolean;\n\n /**\n * If set to 'true' this option disables Sqlite's default behaviour of secretly creating\n * an integer primary key column named 'rowid' on table creation. \n */\n withoutRowid?: boolean; \n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../../src/metadata-args/TableMetadataArgs.ts"],"names":[],"mappings":"","file":"TableMetadataArgs.js","sourcesContent":["import {Connection, SelectQueryBuilder} from \"..\";\nimport {OrderByCondition} from \"../find-options/OrderByCondition\";\nimport {TableType} from \"../metadata/types/TableTypes\";\n\n/**\n * Arguments for TableMetadata class, helps to construct an TableMetadata object.\n */\nexport interface TableMetadataArgs {\n\n /**\n * Class to which table is applied.\n * Function target is a table defined in the class.\n * String target is a table defined in a json schema.\n */\n target: Function|string;\n\n /**\n * Table's name. If name is not set then table's name will be generated from target's name.\n */\n name?: string;\n\n /**\n * Table type. Tables can be abstract, closure, junction, embedded, etc.\n */\n type: TableType;\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|((object: any) => OrderByCondition|any);\n\n /**\n * Table's database engine type (like \"InnoDB\", \"MyISAM\", etc).\n */\n engine?: string;\n\n /**\n * Database name. Used in MySql and Sql Server.\n */\n database?: string;\n\n /**\n * Schema name. Used in Postgres and Sql Server.\n */\n schema?: string;\n\n /**\n * Indicates if schema synchronization is enabled or disabled for this entity.\n * If it will be set to false then schema sync will and migrations ignore this entity.\n * By default schema synchronization is enabled for all entities.\n */\n synchronize?: boolean;\n\n /**\n * View expression.\n */\n expression?: string|((connection: Connection) => SelectQueryBuilder<any>);\n\n /**\n * View dependencies.\n */\n dependsOn?: Set<Function|string>;\n\n /**\n * Indicates if view is materialized\n */\n materialized?: boolean;\n\n /**\n * If set to 'true' this option disables Sqlite's default behaviour of secretly creating\n * an integer primary key column named 'rowid' on table creation.\n */\n withoutRowid?: boolean;\n}\n"],"sourceRoot":".."}
@@ -270,6 +270,10 @@ var MigrationExecutor = /** @class */ (function () {
270
270
  transactionStartedByUs = true;
271
271
  _c.label = 2;
272
272
  case 2: return [4 /*yield*/, migration.instance.up(queryRunner)
273
+ .catch(function (error) {
274
+ _this.connection.logger.logMigration("Migration \"" + migration.name + "\" has been failed, error: " + (error === null || error === void 0 ? void 0 : error.message));
275
+ throw error;
276
+ })
273
277
  .then(function () { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
274
278
  return (0, tslib_1.__generator)(this, function (_a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,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;wBACpD,qBAAM,EAAE,CAAC,MAAM,EAAE;iCACZ,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC;iCAC1B,KAAK,CAAI,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAe,CAAC;iCAC/C,QAAQ,CAAI,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,aAAU,CAAC;iCACxC,aAAa,CAAC,UAAU,CAAC;iCACzB,OAAO,EAAE,EAAA;;wBALd,SAKc,CAAC;;;;;;KAGtB;IAEe,2CAAe,GAA/B,UAA+C,QAAyC;;;;;;wBAC9E,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;;;;wBAGxE,sBAAO,QAAQ,CAAC,WAAW,CAAC,EAAC;;6BAEzB,CAAC,IAAI,CAAC,WAAW,EAAjB,wBAAiB;wBACjB,qBAAM,WAAW,CAAC,OAAO,EAAE,EAAA;;wBAA3B,SAA2B,CAAC;;;;;;;KAGvC;IACL,wBAAC;AAAD,CAnfA,AAmfC,IAAA;AAnfY,8CAAiB","file":"MigrationExecutor.js","sourcesContent":["import {Table} from \"../schema-builder/table/Table\";\nimport {Connection} from \"../connection/Connection\";\nimport {Migration} from \"./Migration\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {SqlServerDriver} from \"../driver/sqlserver/SqlServerDriver\";\nimport {MssqlParameter} from \"../driver/sqlserver/MssqlParameter\";\nimport {MongoDriver} from \"../driver/mongodb/MongoDriver\";\nimport {MongoQueryRunner} from \"../driver/mongodb/MongoQueryRunner\";\nimport { TypeORMError } from \"../error\";\n\n/**\n * Executes migrations: runs pending and reverts previously executed migrations.\n */\nexport class MigrationExecutor {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Indicates how migrations should be run in transactions.\n * all: all migrations are run in a single transaction\n * none: all migrations are run without a transaction\n * each: each migration is run in a separate transaction\n */\n transaction: \"all\" | \"none\" | \"each\" = \"all\";\n\n // -------------------------------------------------------------------------\n // Private Properties\n // -------------------------------------------------------------------------\n\n private readonly migrationsDatabase?: string;\n private readonly migrationsSchema?: string;\n private readonly migrationsTable: string;\n private readonly migrationsTableName: string;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: Connection,\n protected queryRunner?: QueryRunner) {\n\n const { schema } = this.connection.driver.options as any;\n const database = this.connection.driver.database;\n this.migrationsDatabase = database;\n this.migrationsSchema = schema;\n this.migrationsTableName = connection.options.migrationsTableName || \"migrations\";\n this.migrationsTable = this.connection.driver.buildTableName(this.migrationsTableName, schema, database);\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Tries to execute a single migration given.\n */\n public async executeMigration(migration: Migration): Promise<Migration> {\n return this.withQueryRunner(async (queryRunner) => {\n await this.createMigrationsTableIfNotExist(queryRunner);\n await (migration.instance as any).up(queryRunner);\n await this.insertExecutedMigration(queryRunner, migration);\n\n return migration;\n });\n }\n\n /**\n * Returns an array of all migrations.\n */\n public async getAllMigrations(): Promise<Migration[]> {\n return Promise.resolve(this.getMigrations());\n }\n\n /**\n * Returns an array of all executed migrations.\n */\n public async getExecutedMigrations(): Promise<Migration[]> {\n return this.withQueryRunner(async queryRunner => {\n await this.createMigrationsTableIfNotExist(queryRunner);\n\n return await this.loadExecutedMigrations(queryRunner);\n });\n }\n\n /**\n * Returns an array of all pending migrations.\n */\n public async getPendingMigrations(): Promise<Migration[]> {\n const allMigrations = await this.getAllMigrations();\n const executedMigrations = await this.getExecutedMigrations();\n\n return allMigrations.filter(migration =>\n !executedMigrations.find(\n executedMigration =>\n executedMigration.name === migration.name\n )\n );\n }\n\n /**\n * Inserts an executed migration.\n */\n public insertMigration(migration: Migration): Promise<void> {\n return new Promise((resolve, reject) => {\n this.withQueryRunner(queryRunner => {\n this.insertExecutedMigration(queryRunner, migration)\n .then(resolve)\n .catch(reject);\n });\n });\n }\n\n /**\n * Deletes an executed migration.\n */\n public deleteMigration(migration: Migration): Promise<void> {\n return new Promise((resolve, reject) => {\n this.withQueryRunner(queryRunner => {\n this.deleteExecutedMigration(queryRunner, migration)\n .then(resolve)\n .catch(reject);\n });\n });\n }\n\n /**\n * Lists all migrations and whether they have been executed or not\n * returns true if there are unapplied migrations\n */\n async showMigrations(): Promise<boolean> {\n let hasUnappliedMigrations = false;\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n for (const migration of allMigrations) {\n const executedMigration = executedMigrations.find(executedMigration => executedMigration.name === migration.name);\n\n if (executedMigration) {\n this.connection.logger.logSchemaBuild(` [X] ${migration.name}`);\n } else {\n hasUnappliedMigrations = true;\n this.connection.logger.logSchemaBuild(` [ ] ${migration.name}`);\n }\n }\n\n // if query runner was created by us then release it\n if (!this.queryRunner) {\n await queryRunner.release();\n }\n\n return hasUnappliedMigrations;\n }\n\n /**\n * Executes all pending migrations. Pending migrations are migrations that are not yet executed,\n * thus not saved in the database.\n */\n async executePendingMigrations(): Promise<Migration[]> {\n\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration = this.getLatestTimestampMigration(executedMigrations);\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n // variable to store all migrations we did successefuly\n const successMigrations: Migration[] = [];\n\n // find all migrations that needs to be executed\n const pendingMigrations = allMigrations.filter(migration => {\n // check if we already have executed migration\n const executedMigration = executedMigrations.find(executedMigration => executedMigration.name === migration.name);\n if (executedMigration)\n return false;\n\n // migration is new and not executed. now check if its timestamp is correct\n // if (lastTimeExecutedMigration && migration.timestamp < lastTimeExecutedMigration.timestamp)\n // throw new TypeORMError(`New migration found: ${migration.name}, however this migration's timestamp is not valid. Migration's timestamp should not be older then migrations already executed in the database.`);\n\n // every check is passed means that migration was not run yet and we need to run it\n return true;\n });\n\n // if no migrations are pending then nothing to do here\n if (!pendingMigrations.length) {\n this.connection.logger.logSchemaBuild(`No migrations are pending`);\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n return [];\n }\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(`${executedMigrations.length} migrations are already loaded in the database.`);\n this.connection.logger.logSchemaBuild(`${allMigrations.length} migrations were found in the source code.`);\n if (lastTimeExecutedMigration)\n this.connection.logger.logSchemaBuild(`${lastTimeExecutedMigration.name} is the last executed migration. It was executed on ${new Date(lastTimeExecutedMigration.timestamp).toString()}.`);\n this.connection.logger.logSchemaBuild(`${pendingMigrations.length} migrations are new migrations that needs to be executed.`);\n\n // start transaction if its not started yet\n let transactionStartedByUs = false;\n if (this.transaction === \"all\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n // run all pending migrations in a sequence\n try {\n for (const migration of pendingMigrations) {\n if (this.transaction === \"each\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n await migration.instance!.up(queryRunner)\n .then(async () => { // now when migration is executed we need to insert record about it into the database\n await this.insertExecutedMigration(queryRunner, migration);\n // commit transaction if we started it\n if (this.transaction === \"each\" && transactionStartedByUs)\n await queryRunner.commitTransaction();\n })\n .then(() => { // informative log about migration success\n successMigrations.push(migration);\n this.connection.logger.logSchemaBuild(`Migration ${migration.name} has been executed successfully.`);\n });\n }\n\n // commit transaction if we started it\n if (this.transaction === \"all\" && transactionStartedByUs)\n await queryRunner.commitTransaction();\n\n } catch (err) { // rollback transaction if we started it\n if (transactionStartedByUs) {\n try { // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n\n throw err;\n\n } finally {\n\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n }\n return successMigrations;\n\n }\n\n /**\n * Reverts last migration that were run.\n */\n async undoLastMigration(): Promise<void> {\n\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration = this.getLatestExecutedMigration(executedMigrations);\n\n // if no migrations found in the database then nothing to revert\n if (!lastTimeExecutedMigration) {\n this.connection.logger.logSchemaBuild(`No migrations was found in the database. Nothing to revert!`);\n return;\n }\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n // find the instance of the migration we need to remove\n const migrationToRevert = allMigrations.find(migration => migration.name === lastTimeExecutedMigration!.name);\n\n // if no migrations found in the database then nothing to revert\n if (!migrationToRevert)\n throw new TypeORMError(`No migration ${lastTimeExecutedMigration.name} was found in the source code. Make sure you have this migration in your codebase and its included in the connection options.`);\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(`${executedMigrations.length} migrations are already loaded in the database.`);\n this.connection.logger.logSchemaBuild(`${lastTimeExecutedMigration.name} is the last executed migration. It was executed on ${new Date(lastTimeExecutedMigration.timestamp).toString()}.`);\n this.connection.logger.logSchemaBuild(`Now reverting it...`);\n\n // start transaction if its not started yet\n let transactionStartedByUs = false;\n if ((this.transaction !== \"none\") && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n try {\n await migrationToRevert.instance!.down(queryRunner);\n await this.deleteExecutedMigration(queryRunner, migrationToRevert);\n this.connection.logger.logSchemaBuild(`Migration ${migrationToRevert.name} has been reverted successfully.`);\n\n // commit transaction if we started it\n if (transactionStartedByUs)\n await queryRunner.commitTransaction();\n\n } catch (err) { // rollback transaction if we started it\n if (transactionStartedByUs) {\n try { // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n\n throw err;\n\n } finally {\n\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates table \"migrations\" that will store information about executed migrations.\n */\n protected async createMigrationsTableIfNotExist(queryRunner: QueryRunner): Promise<void> {\n // If driver is mongo no need to create\n if (this.connection.driver instanceof MongoDriver) {\n return;\n }\n const tableExist = await queryRunner.hasTable(this.migrationsTable); // todo: table name should be configurable\n if (!tableExist) {\n await queryRunner.createTable(new Table(\n {\n database: this.migrationsDatabase,\n schema: this.migrationsSchema,\n name: this.migrationsTable,\n columns: [\n {\n name: \"id\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationId}),\n isGenerated: true,\n generationStrategy: \"increment\",\n isPrimary: true,\n isNullable: false\n },\n {\n name: \"timestamp\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationTimestamp}),\n isPrimary: false,\n isNullable: false\n },\n {\n name: \"name\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationName}),\n isNullable: false\n },\n ]\n },\n ));\n }\n }\n\n /**\n * Loads all migrations that were executed and saved into the database (sorts by id).\n */\n protected async loadExecutedMigrations(queryRunner: QueryRunner): Promise<Migration[]> {\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n return await mongoRunner.databaseConnection\n .db(this.connection.driver.database!)\n .collection(this.migrationsTableName)\n .find<Migration>()\n .sort({\"_id\": -1})\n .toArray();\n } else {\n const migrationsRaw: ObjectLiteral[] = await this.connection.manager\n .createQueryBuilder(queryRunner)\n .select()\n .orderBy(this.connection.driver.escape(\"id\"), \"DESC\")\n .from(this.migrationsTable, this.migrationsTableName)\n .getRawMany();\n return migrationsRaw.map(migrationRaw => {\n return new Migration(parseInt(migrationRaw[\"id\"]), parseInt(migrationRaw[\"timestamp\"]), migrationRaw[\"name\"]);\n });\n }\n }\n\n /**\n * Gets all migrations that setup for this connection.\n */\n protected getMigrations(): Migration[] {\n const migrations = this.connection.migrations.map(migration => {\n const migrationClassName = migration.name || (migration.constructor as any).name;\n const migrationTimestamp = parseInt(migrationClassName.substr(-13), 10);\n if (!migrationTimestamp || isNaN(migrationTimestamp)) {\n throw new TypeORMError(`${migrationClassName} migration name is wrong. Migration class name should have a JavaScript timestamp appended.`);\n }\n\n return new Migration(undefined, migrationTimestamp, migrationClassName, migration);\n });\n\n this.checkForDuplicateMigrations(migrations);\n\n // sort them by timestamp\n return migrations.sort((a, b) => a.timestamp - b.timestamp);\n }\n\n protected checkForDuplicateMigrations(migrations: Migration[]) {\n const migrationNames = migrations.map(migration => migration.name);\n const duplicates = Array.from(new Set(migrationNames.filter((migrationName, index) => migrationNames.indexOf(migrationName) < index)));\n if (duplicates.length > 0) {\n throw Error(`Duplicate migrations: ${duplicates.join(\", \")}`);\n }\n }\n\n /**\n * Finds the latest migration (sorts by timestamp) in the given array of migrations.\n */\n protected getLatestTimestampMigration(migrations: Migration[]): Migration|undefined {\n const sortedMigrations = migrations.map(migration => migration).sort((a, b) => (a.timestamp - b.timestamp) * -1);\n return sortedMigrations.length > 0 ? sortedMigrations[0] : undefined;\n }\n\n /**\n * Finds the latest migration in the given array of migrations.\n * PRE: Migration array must be sorted by descending id.\n */\n protected getLatestExecutedMigration(sortedMigrations: Migration[]): Migration|undefined {\n return sortedMigrations.length > 0 ? sortedMigrations[0] : undefined;\n }\n\n /**\n * Inserts new executed migration's data into migrations table.\n */\n protected async insertExecutedMigration(queryRunner: QueryRunner, migration: Migration): Promise<void> {\n const values: ObjectLiteral = {};\n if (this.connection.driver instanceof SqlServerDriver) {\n values[\"timestamp\"] = new MssqlParameter(migration.timestamp, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationTimestamp }) as any);\n values[\"name\"] = new MssqlParameter(migration.name, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationName }) as any);\n } else {\n values[\"timestamp\"] = migration.timestamp;\n values[\"name\"] = migration.name;\n }\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n await mongoRunner.databaseConnection.db(this.connection.driver.database!).collection(this.migrationsTableName).insertOne(values);\n } else {\n const qb = queryRunner.manager.createQueryBuilder();\n await qb.insert()\n .into(this.migrationsTable)\n .values(values)\n .execute();\n }\n }\n\n /**\n * Delete previously executed migration's data from the migrations table.\n */\n protected async deleteExecutedMigration(queryRunner: QueryRunner, migration: Migration): Promise<void> {\n\n const conditions: ObjectLiteral = {};\n if (this.connection.driver instanceof SqlServerDriver) {\n conditions[\"timestamp\"] = new MssqlParameter(migration.timestamp, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationTimestamp }) as any);\n conditions[\"name\"] = new MssqlParameter(migration.name, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationName }) as any);\n } else {\n conditions[\"timestamp\"] = migration.timestamp;\n conditions[\"name\"] = migration.name;\n }\n\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n await mongoRunner.databaseConnection.db(this.connection.driver.database!).collection(this.migrationsTableName).deleteOne(conditions);\n } else {\n const qb = queryRunner.manager.createQueryBuilder();\n await qb.delete()\n .from(this.migrationsTable)\n .where(`${qb.escape(\"timestamp\")} = :timestamp`)\n .andWhere(`${qb.escape(\"name\")} = :name`)\n .setParameters(conditions)\n .execute();\n }\n\n }\n\n protected async withQueryRunner<T extends any>(callback: (queryRunner: QueryRunner) => T) {\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n\n try {\n return callback(queryRunner);\n } finally {\n if (!this.queryRunner) {\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AC;wBACpD,qBAAM,WAAW,CAAC,kBAAkB,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAS,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,EAAA;;wBAApI,SAAoI,CAAC;;;wBAE/H,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;wBACpD,qBAAM,EAAE,CAAC,MAAM,EAAE;iCACZ,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC;iCAC1B,KAAK,CAAI,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAe,CAAC;iCAC/C,QAAQ,CAAI,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,aAAU,CAAC;iCACxC,aAAa,CAAC,UAAU,CAAC;iCACzB,OAAO,EAAE,EAAA;;wBALd,SAKc,CAAC;;;;;;KAGtB;IAEe,2CAAe,GAA/B,UAA+C,QAAyC;;;;;;wBAC9E,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;;;;wBAGxE,sBAAO,QAAQ,CAAC,WAAW,CAAC,EAAC;;6BAEzB,CAAC,IAAI,CAAC,WAAW,EAAjB,wBAAiB;wBACjB,qBAAM,WAAW,CAAC,OAAO,EAAE,EAAA;;wBAA3B,SAA2B,CAAC;;;;;;;KAGvC;IACL,wBAAC;AAAD,CAvfA,AAufC,IAAA;AAvfY,8CAAiB","file":"MigrationExecutor.js","sourcesContent":["import {Table} from \"../schema-builder/table/Table\";\nimport {Connection} from \"../connection/Connection\";\nimport {Migration} from \"./Migration\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {SqlServerDriver} from \"../driver/sqlserver/SqlServerDriver\";\nimport {MssqlParameter} from \"../driver/sqlserver/MssqlParameter\";\nimport {MongoDriver} from \"../driver/mongodb/MongoDriver\";\nimport {MongoQueryRunner} from \"../driver/mongodb/MongoQueryRunner\";\nimport { TypeORMError } from \"../error\";\n\n/**\n * Executes migrations: runs pending and reverts previously executed migrations.\n */\nexport class MigrationExecutor {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Indicates how migrations should be run in transactions.\n * all: all migrations are run in a single transaction\n * none: all migrations are run without a transaction\n * each: each migration is run in a separate transaction\n */\n transaction: \"all\" | \"none\" | \"each\" = \"all\";\n\n // -------------------------------------------------------------------------\n // Private Properties\n // -------------------------------------------------------------------------\n\n private readonly migrationsDatabase?: string;\n private readonly migrationsSchema?: string;\n private readonly migrationsTable: string;\n private readonly migrationsTableName: string;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: Connection,\n protected queryRunner?: QueryRunner) {\n\n const { schema } = this.connection.driver.options as any;\n const database = this.connection.driver.database;\n this.migrationsDatabase = database;\n this.migrationsSchema = schema;\n this.migrationsTableName = connection.options.migrationsTableName || \"migrations\";\n this.migrationsTable = this.connection.driver.buildTableName(this.migrationsTableName, schema, database);\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Tries to execute a single migration given.\n */\n public async executeMigration(migration: Migration): Promise<Migration> {\n return this.withQueryRunner(async (queryRunner) => {\n await this.createMigrationsTableIfNotExist(queryRunner);\n await (migration.instance as any).up(queryRunner);\n await this.insertExecutedMigration(queryRunner, migration);\n\n return migration;\n });\n }\n\n /**\n * Returns an array of all migrations.\n */\n public async getAllMigrations(): Promise<Migration[]> {\n return Promise.resolve(this.getMigrations());\n }\n\n /**\n * Returns an array of all executed migrations.\n */\n public async getExecutedMigrations(): Promise<Migration[]> {\n return this.withQueryRunner(async queryRunner => {\n await this.createMigrationsTableIfNotExist(queryRunner);\n\n return await this.loadExecutedMigrations(queryRunner);\n });\n }\n\n /**\n * Returns an array of all pending migrations.\n */\n public async getPendingMigrations(): Promise<Migration[]> {\n const allMigrations = await this.getAllMigrations();\n const executedMigrations = await this.getExecutedMigrations();\n\n return allMigrations.filter(migration =>\n !executedMigrations.find(\n executedMigration =>\n executedMigration.name === migration.name\n )\n );\n }\n\n /**\n * Inserts an executed migration.\n */\n public insertMigration(migration: Migration): Promise<void> {\n return new Promise((resolve, reject) => {\n this.withQueryRunner(queryRunner => {\n this.insertExecutedMigration(queryRunner, migration)\n .then(resolve)\n .catch(reject);\n });\n });\n }\n\n /**\n * Deletes an executed migration.\n */\n public deleteMigration(migration: Migration): Promise<void> {\n return new Promise((resolve, reject) => {\n this.withQueryRunner(queryRunner => {\n this.deleteExecutedMigration(queryRunner, migration)\n .then(resolve)\n .catch(reject);\n });\n });\n }\n\n /**\n * Lists all migrations and whether they have been executed or not\n * returns true if there are unapplied migrations\n */\n async showMigrations(): Promise<boolean> {\n let hasUnappliedMigrations = false;\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n for (const migration of allMigrations) {\n const executedMigration = executedMigrations.find(executedMigration => executedMigration.name === migration.name);\n\n if (executedMigration) {\n this.connection.logger.logSchemaBuild(` [X] ${migration.name}`);\n } else {\n hasUnappliedMigrations = true;\n this.connection.logger.logSchemaBuild(` [ ] ${migration.name}`);\n }\n }\n\n // if query runner was created by us then release it\n if (!this.queryRunner) {\n await queryRunner.release();\n }\n\n return hasUnappliedMigrations;\n }\n\n /**\n * Executes all pending migrations. Pending migrations are migrations that are not yet executed,\n * thus not saved in the database.\n */\n async executePendingMigrations(): Promise<Migration[]> {\n\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration = this.getLatestTimestampMigration(executedMigrations);\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n // variable to store all migrations we did successefuly\n const successMigrations: Migration[] = [];\n\n // find all migrations that needs to be executed\n const pendingMigrations = allMigrations.filter(migration => {\n // check if we already have executed migration\n const executedMigration = executedMigrations.find(executedMigration => executedMigration.name === migration.name);\n if (executedMigration)\n return false;\n\n // migration is new and not executed. now check if its timestamp is correct\n // if (lastTimeExecutedMigration && migration.timestamp < lastTimeExecutedMigration.timestamp)\n // throw new TypeORMError(`New migration found: ${migration.name}, however this migration's timestamp is not valid. Migration's timestamp should not be older then migrations already executed in the database.`);\n\n // every check is passed means that migration was not run yet and we need to run it\n return true;\n });\n\n // if no migrations are pending then nothing to do here\n if (!pendingMigrations.length) {\n this.connection.logger.logSchemaBuild(`No migrations are pending`);\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n return [];\n }\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(`${executedMigrations.length} migrations are already loaded in the database.`);\n this.connection.logger.logSchemaBuild(`${allMigrations.length} migrations were found in the source code.`);\n if (lastTimeExecutedMigration)\n this.connection.logger.logSchemaBuild(`${lastTimeExecutedMigration.name} is the last executed migration. It was executed on ${new Date(lastTimeExecutedMigration.timestamp).toString()}.`);\n this.connection.logger.logSchemaBuild(`${pendingMigrations.length} migrations are new migrations that needs to be executed.`);\n\n // start transaction if its not started yet\n let transactionStartedByUs = false;\n if (this.transaction === \"all\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n // run all pending migrations in a sequence\n try {\n for (const migration of pendingMigrations) {\n if (this.transaction === \"each\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n await migration.instance!.up(queryRunner)\n .catch(error => { // informative log about migration failure\n this.connection.logger.logMigration(`Migration \"${migration.name}\" has been failed, error: ${error?.message}`);\n throw error;\n })\n .then(async () => { // now when migration is executed we need to insert record about it into the database\n await this.insertExecutedMigration(queryRunner, migration);\n // commit transaction if we started it\n if (this.transaction === \"each\" && transactionStartedByUs)\n await queryRunner.commitTransaction();\n })\n .then(() => { // informative log about migration success\n successMigrations.push(migration);\n this.connection.logger.logSchemaBuild(`Migration ${migration.name} has been executed successfully.`);\n });\n }\n\n // commit transaction if we started it\n if (this.transaction === \"all\" && transactionStartedByUs)\n await queryRunner.commitTransaction();\n\n } catch (err) { // rollback transaction if we started it\n if (transactionStartedByUs) {\n try { // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n\n throw err;\n\n } finally {\n\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n }\n return successMigrations;\n\n }\n\n /**\n * Reverts last migration that were run.\n */\n async undoLastMigration(): Promise<void> {\n\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration = this.getLatestExecutedMigration(executedMigrations);\n\n // if no migrations found in the database then nothing to revert\n if (!lastTimeExecutedMigration) {\n this.connection.logger.logSchemaBuild(`No migrations was found in the database. Nothing to revert!`);\n return;\n }\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n // find the instance of the migration we need to remove\n const migrationToRevert = allMigrations.find(migration => migration.name === lastTimeExecutedMigration!.name);\n\n // if no migrations found in the database then nothing to revert\n if (!migrationToRevert)\n throw new TypeORMError(`No migration ${lastTimeExecutedMigration.name} was found in the source code. Make sure you have this migration in your codebase and its included in the connection options.`);\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(`${executedMigrations.length} migrations are already loaded in the database.`);\n this.connection.logger.logSchemaBuild(`${lastTimeExecutedMigration.name} is the last executed migration. It was executed on ${new Date(lastTimeExecutedMigration.timestamp).toString()}.`);\n this.connection.logger.logSchemaBuild(`Now reverting it...`);\n\n // start transaction if its not started yet\n let transactionStartedByUs = false;\n if ((this.transaction !== \"none\") && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n try {\n await migrationToRevert.instance!.down(queryRunner);\n await this.deleteExecutedMigration(queryRunner, migrationToRevert);\n this.connection.logger.logSchemaBuild(`Migration ${migrationToRevert.name} has been reverted successfully.`);\n\n // commit transaction if we started it\n if (transactionStartedByUs)\n await queryRunner.commitTransaction();\n\n } catch (err) { // rollback transaction if we started it\n if (transactionStartedByUs) {\n try { // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n\n throw err;\n\n } finally {\n\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates table \"migrations\" that will store information about executed migrations.\n */\n protected async createMigrationsTableIfNotExist(queryRunner: QueryRunner): Promise<void> {\n // If driver is mongo no need to create\n if (this.connection.driver instanceof MongoDriver) {\n return;\n }\n const tableExist = await queryRunner.hasTable(this.migrationsTable); // todo: table name should be configurable\n if (!tableExist) {\n await queryRunner.createTable(new Table(\n {\n database: this.migrationsDatabase,\n schema: this.migrationsSchema,\n name: this.migrationsTable,\n columns: [\n {\n name: \"id\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationId}),\n isGenerated: true,\n generationStrategy: \"increment\",\n isPrimary: true,\n isNullable: false\n },\n {\n name: \"timestamp\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationTimestamp}),\n isPrimary: false,\n isNullable: false\n },\n {\n name: \"name\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationName}),\n isNullable: false\n },\n ]\n },\n ));\n }\n }\n\n /**\n * Loads all migrations that were executed and saved into the database (sorts by id).\n */\n protected async loadExecutedMigrations(queryRunner: QueryRunner): Promise<Migration[]> {\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n return await mongoRunner.databaseConnection\n .db(this.connection.driver.database!)\n .collection(this.migrationsTableName)\n .find<Migration>()\n .sort({\"_id\": -1})\n .toArray();\n } else {\n const migrationsRaw: ObjectLiteral[] = await this.connection.manager\n .createQueryBuilder(queryRunner)\n .select()\n .orderBy(this.connection.driver.escape(\"id\"), \"DESC\")\n .from(this.migrationsTable, this.migrationsTableName)\n .getRawMany();\n return migrationsRaw.map(migrationRaw => {\n return new Migration(parseInt(migrationRaw[\"id\"]), parseInt(migrationRaw[\"timestamp\"]), migrationRaw[\"name\"]);\n });\n }\n }\n\n /**\n * Gets all migrations that setup for this connection.\n */\n protected getMigrations(): Migration[] {\n const migrations = this.connection.migrations.map(migration => {\n const migrationClassName = migration.name || (migration.constructor as any).name;\n const migrationTimestamp = parseInt(migrationClassName.substr(-13), 10);\n if (!migrationTimestamp || isNaN(migrationTimestamp)) {\n throw new TypeORMError(`${migrationClassName} migration name is wrong. Migration class name should have a JavaScript timestamp appended.`);\n }\n\n return new Migration(undefined, migrationTimestamp, migrationClassName, migration);\n });\n\n this.checkForDuplicateMigrations(migrations);\n\n // sort them by timestamp\n return migrations.sort((a, b) => a.timestamp - b.timestamp);\n }\n\n protected checkForDuplicateMigrations(migrations: Migration[]) {\n const migrationNames = migrations.map(migration => migration.name);\n const duplicates = Array.from(new Set(migrationNames.filter((migrationName, index) => migrationNames.indexOf(migrationName) < index)));\n if (duplicates.length > 0) {\n throw Error(`Duplicate migrations: ${duplicates.join(\", \")}`);\n }\n }\n\n /**\n * Finds the latest migration (sorts by timestamp) in the given array of migrations.\n */\n protected getLatestTimestampMigration(migrations: Migration[]): Migration|undefined {\n const sortedMigrations = migrations.map(migration => migration).sort((a, b) => (a.timestamp - b.timestamp) * -1);\n return sortedMigrations.length > 0 ? sortedMigrations[0] : undefined;\n }\n\n /**\n * Finds the latest migration in the given array of migrations.\n * PRE: Migration array must be sorted by descending id.\n */\n protected getLatestExecutedMigration(sortedMigrations: Migration[]): Migration|undefined {\n return sortedMigrations.length > 0 ? sortedMigrations[0] : undefined;\n }\n\n /**\n * Inserts new executed migration's data into migrations table.\n */\n protected async insertExecutedMigration(queryRunner: QueryRunner, migration: Migration): Promise<void> {\n const values: ObjectLiteral = {};\n if (this.connection.driver instanceof SqlServerDriver) {\n values[\"timestamp\"] = new MssqlParameter(migration.timestamp, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationTimestamp }) as any);\n values[\"name\"] = new MssqlParameter(migration.name, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationName }) as any);\n } else {\n values[\"timestamp\"] = migration.timestamp;\n values[\"name\"] = migration.name;\n }\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n await mongoRunner.databaseConnection.db(this.connection.driver.database!).collection(this.migrationsTableName).insertOne(values);\n } else {\n const qb = queryRunner.manager.createQueryBuilder();\n await qb.insert()\n .into(this.migrationsTable)\n .values(values)\n .execute();\n }\n }\n\n /**\n * Delete previously executed migration's data from the migrations table.\n */\n protected async deleteExecutedMigration(queryRunner: QueryRunner, migration: Migration): Promise<void> {\n\n const conditions: ObjectLiteral = {};\n if (this.connection.driver instanceof SqlServerDriver) {\n conditions[\"timestamp\"] = new MssqlParameter(migration.timestamp, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationTimestamp }) as any);\n conditions[\"name\"] = new MssqlParameter(migration.name, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationName }) as any);\n } else {\n conditions[\"timestamp\"] = migration.timestamp;\n conditions[\"name\"] = migration.name;\n }\n\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n await mongoRunner.databaseConnection.db(this.connection.driver.database!).collection(this.migrationsTableName).deleteOne(conditions);\n } else {\n const qb = queryRunner.manager.createQueryBuilder();\n await qb.delete()\n .from(this.migrationsTable)\n .where(`${qb.escape(\"timestamp\")} = :timestamp`)\n .andWhere(`${qb.escape(\"name\")} = :name`)\n .setParameters(conditions)\n .execute();\n }\n\n }\n\n protected async withQueryRunner<T extends any>(callback: (queryRunner: QueryRunner) => T) {\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n\n try {\n return callback(queryRunner);\n } finally {\n if (!this.queryRunner) {\n await queryRunner.release();\n }\n }\n }\n}\n"],"sourceRoot":".."}
package/package.json CHANGED
@@ -1 +1 @@
1
- { "name": "typeorm", "private": false, "version": "0.2.39-dev.cf281ef", "description": "Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, MongoDB databases.", "license": "MIT", "readmeFilename": "README.md", "author": { "name": "Umed Khudoiberdiev", "email": "pleerock.me@gmail.com" }, "main": "./index.js", "browser": { "./browser/driver/aurora-data-api/AuroraDataApiDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/cockroachdb/CockroachDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/postgres/PostgresDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/oracle/OracleDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sap/SapDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mysql/MysqlDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sqlserver/SqlServerDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/MongoDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/MongoQueryRunner.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/entity-manager/MongoEntityManager.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/repository/MongoRepository.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sqlite/SqliteDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/better-sqlite3/BetterSqlite3Driver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/util/DirectoryExportedClassesLoader.js": "./browser/platform/BrowserDirectoryExportedClassesLoader.js", "./browser/logger/FileLogger.js": "./browser/platform/BrowserFileLoggerDummy.js", "./browser/connection/ConnectionOptionsReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/connection/options-reader/ConnectionOptionsXmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/connection/options-reader/ConnectionOptionsYmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/platform/PlatformTools.js": "./browser/platform/BrowserPlatformTools.js", "./index.js": "./browser/index.js" }, "repository": { "type": "git", "url": "https://github.com/typeorm/typeorm.git" }, "bugs": { "url": "https://github.com/typeorm/typeorm/issues" }, "tags": [ "orm", "typescript", "typescript-orm", "mysql", "mysql-orm", "postgresql", "postgresql-orm", "mariadb", "mariadb-orm", "sqlite", "sqlite-orm", "sql-server", "sql-server-orm", "oracle", "oracle-orm" ], "devDependencies": { "@types/app-root-path": "^1.2.4", "@types/chai": "^4.2.15", "@types/chai-as-promised": "^7.1.3", "@types/debug": "^4.1.5", "@types/dotenv": "^8.2.0", "@types/js-yaml": "^4.0.0", "@types/mkdirp": "^1.0.1", "@types/mocha": "^8.2.1", "@types/node": "^14.14.31", "@types/rimraf": "^3.0.0", "@types/sha.js": "^2.4.0", "@types/sinon": "^9.0.10", "@types/source-map-support": "^0.5.3", "@types/xml2js": "^0.4.8", "@types/yargs": "^17.0.2", "@typescript-eslint/eslint-plugin": "^4.15.2", "@typescript-eslint/parser": "^4.15.2", "better-sqlite3": "^7.1.2", "chai": "^4.3.0", "chai-as-promised": "^7.1.1", "class-transformer": "^0.4.0", "conventional-changelog-angular": "^5.0.12", "conventional-changelog-cli": "^2.1.1", "del": "^6.0.0", "eslint": "^7.20.0", "gulp": "^4.0.2", "gulp-eslint": "^6.0.0", "gulp-istanbul": "^1.1.3", "gulp-mocha": "^8.0.0", "gulp-rename": "^2.0.0", "gulp-replace": "^1.0.0", "gulp-shell": "^0.8.0", "gulp-sourcemaps": "^3.0.0", "gulp-typescript": "^6.0.0-alpha.1", "gulpclass": "^0.2.0", "husky": "^5.1.1", "lint-staged": "^10.5.4", "mocha": "^8.3.0", "mongodb": "^3.6.4", "mssql": "^6.3.1", "mysql": "^2.18.1", "mysql2": "^2.2.5", "oracledb": "^5.1.0", "pg": "^8.5.1", "pg-query-stream": "^4.0.0", "redis": "^3.1.1", "remap-istanbul": "^0.13.0", "rimraf": "^3.0.2", "sinon": "^9.2.4", "sinon-chai": "^3.5.0", "source-map-support": "^0.5.19", "sql.js": "^1.4.0", "sqlite3": "^5.0.2", "ts-node": "^9.1.1", "typeorm-aurora-data-api-driver": "^2.0.0", "typescript": "^4.2.2" }, "peerDependencies": { "@sap/hana-client": "*", "better-sqlite3": "*", "hdb-pool": "*", "ioredis": "*", "mongodb": "^3.6.0", "mssql": "*", "mysql2": "*", "oracledb": "*", "pg": "*", "pg-native": "*", "pg-query-stream": "*", "redis": "*", "sql.js": "*", "sqlite3": "*", "typeorm-aurora-data-api-driver": "*" }, "peerDependenciesMeta": { "@sap/hana-client": { "optional": true }, "better-sqlite3": { "optional": true }, "hdb-pool": { "optional": true }, "ioredis": { "optional": true }, "mongodb": { "optional": true }, "mssql": { "optional": true }, "mysql2": { "optional": true }, "oracledb": { "optional": true }, "pg": { "optional": true }, "pg-native": { "optional": true }, "pg-query-stream": { "optional": true }, "redis": { "optional": true }, "sql.js": { "optional": true }, "sqlite3": { "optional": true }, "typeorm-aurora-data-api-driver": { "optional": true } }, "dependencies": { "@sqltools/formatter": "^1.2.2", "app-root-path": "^3.0.0", "buffer": "^6.0.3", "chalk": "^4.1.0", "cli-highlight": "^2.1.11", "debug": "^4.3.1", "dotenv": "^8.2.0", "glob": "^7.1.6", "js-yaml": "^4.0.0", "mkdirp": "^1.0.4", "reflect-metadata": "^0.1.13", "sha.js": "^2.4.11", "tslib": "^2.1.0", "xml2js": "^0.4.23", "yargs": "^17.0.1", "zen-observable-ts": "^1.0.0" }, "lint-staged": { "*.ts": [ "eslint --fix", "git add" ] }, "scripts": { "test": "rimraf ./build && tsc && mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 60000 ./build/compiled/test", "test-fast": "mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 60000 ./build/compiled/test", "compile": "rimraf ./build && tsc", "watch": "./node_modules/.bin/tsc -w", "package": "gulp package", "lint": "eslint -c ./.eslintrc.js src/**/*.ts test/**/*.ts sample/**/*.ts", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1" }, "bin": { "typeorm": "./cli.js" }, "funding": "https://opencollective.com/typeorm", "collective": { "type": "opencollective", "url": "https://opencollective.com/typeorm", "logo": "https://opencollective.com/opencollective/logo.txt" }, "nyc": { "all": true, "cache": false, "exclude": [ "**/*.d.ts" ], "extension": [ ".ts" ], "include": [ "build/compiled/src/**", "src/**" ], "reporter": "json" } }
1
+ { "name": "typeorm", "private": false, "version": "0.2.39-dev.ef33cf4", "description": "Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, MongoDB databases.", "license": "MIT", "readmeFilename": "README.md", "author": { "name": "Umed Khudoiberdiev", "email": "pleerock.me@gmail.com" }, "main": "./index.js", "browser": { "./browser/driver/aurora-data-api/AuroraDataApiDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/cockroachdb/CockroachDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/postgres/PostgresDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/oracle/OracleDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sap/SapDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mysql/MysqlDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sqlserver/SqlServerDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/MongoDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/MongoQueryRunner.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/entity-manager/MongoEntityManager.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/repository/MongoRepository.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sqlite/SqliteDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/better-sqlite3/BetterSqlite3Driver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/util/DirectoryExportedClassesLoader.js": "./browser/platform/BrowserDirectoryExportedClassesLoader.js", "./browser/logger/FileLogger.js": "./browser/platform/BrowserFileLoggerDummy.js", "./browser/connection/ConnectionOptionsReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/connection/options-reader/ConnectionOptionsXmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/connection/options-reader/ConnectionOptionsYmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/platform/PlatformTools.js": "./browser/platform/BrowserPlatformTools.js", "./index.js": "./browser/index.js" }, "repository": { "type": "git", "url": "https://github.com/typeorm/typeorm.git" }, "bugs": { "url": "https://github.com/typeorm/typeorm/issues" }, "tags": [ "orm", "typescript", "typescript-orm", "mysql", "mysql-orm", "postgresql", "postgresql-orm", "mariadb", "mariadb-orm", "sqlite", "sqlite-orm", "sql-server", "sql-server-orm", "oracle", "oracle-orm" ], "devDependencies": { "@types/app-root-path": "^1.2.4", "@types/chai": "^4.2.15", "@types/chai-as-promised": "^7.1.3", "@types/debug": "^4.1.5", "@types/dotenv": "^8.2.0", "@types/js-yaml": "^4.0.0", "@types/mkdirp": "^1.0.1", "@types/mocha": "^8.2.1", "@types/node": "^14.14.31", "@types/rimraf": "^3.0.0", "@types/sha.js": "^2.4.0", "@types/sinon": "^9.0.10", "@types/source-map-support": "^0.5.3", "@types/xml2js": "^0.4.8", "@types/yargs": "^17.0.2", "@typescript-eslint/eslint-plugin": "^4.15.2", "@typescript-eslint/parser": "^4.15.2", "better-sqlite3": "^7.1.2", "chai": "^4.3.0", "chai-as-promised": "^7.1.1", "class-transformer": "^0.4.0", "conventional-changelog-angular": "^5.0.12", "conventional-changelog-cli": "^2.1.1", "del": "^6.0.0", "eslint": "^7.20.0", "gulp": "^4.0.2", "gulp-eslint": "^6.0.0", "gulp-istanbul": "^1.1.3", "gulp-mocha": "^8.0.0", "gulp-rename": "^2.0.0", "gulp-replace": "^1.0.0", "gulp-shell": "^0.8.0", "gulp-sourcemaps": "^3.0.0", "gulp-typescript": "^6.0.0-alpha.1", "gulpclass": "^0.2.0", "husky": "^5.1.1", "lint-staged": "^10.5.4", "mocha": "^8.3.0", "mongodb": "^3.6.4", "mssql": "^6.3.1", "mysql": "^2.18.1", "mysql2": "^2.2.5", "oracledb": "^5.1.0", "pg": "^8.5.1", "pg-query-stream": "^4.0.0", "redis": "^3.1.1", "remap-istanbul": "^0.13.0", "rimraf": "^3.0.2", "sinon": "^9.2.4", "sinon-chai": "^3.5.0", "source-map-support": "^0.5.19", "sql.js": "^1.4.0", "sqlite3": "^5.0.2", "ts-node": "^9.1.1", "typeorm-aurora-data-api-driver": "^2.0.0", "typescript": "^4.2.2" }, "peerDependencies": { "@sap/hana-client": "*", "better-sqlite3": "*", "hdb-pool": "*", "ioredis": "*", "mongodb": "^3.6.0", "mssql": "*", "mysql2": "*", "oracledb": "*", "pg": "*", "pg-native": "*", "pg-query-stream": "*", "redis": "*", "sql.js": "*", "sqlite3": "*", "typeorm-aurora-data-api-driver": "*" }, "peerDependenciesMeta": { "@sap/hana-client": { "optional": true }, "better-sqlite3": { "optional": true }, "hdb-pool": { "optional": true }, "ioredis": { "optional": true }, "mongodb": { "optional": true }, "mssql": { "optional": true }, "mysql2": { "optional": true }, "oracledb": { "optional": true }, "pg": { "optional": true }, "pg-native": { "optional": true }, "pg-query-stream": { "optional": true }, "redis": { "optional": true }, "sql.js": { "optional": true }, "sqlite3": { "optional": true }, "typeorm-aurora-data-api-driver": { "optional": true } }, "dependencies": { "@sqltools/formatter": "^1.2.2", "app-root-path": "^3.0.0", "buffer": "^6.0.3", "chalk": "^4.1.0", "cli-highlight": "^2.1.11", "debug": "^4.3.1", "dotenv": "^8.2.0", "glob": "^7.1.6", "js-yaml": "^4.0.0", "mkdirp": "^1.0.4", "reflect-metadata": "^0.1.13", "sha.js": "^2.4.11", "tslib": "^2.1.0", "xml2js": "^0.4.23", "yargs": "^17.0.1", "zen-observable-ts": "^1.0.0" }, "lint-staged": { "*.ts": [ "eslint --fix", "git add" ] }, "scripts": { "test": "rimraf ./build && tsc && mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 60000 ./build/compiled/test", "test-fast": "mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 60000 ./build/compiled/test", "compile": "rimraf ./build && tsc", "watch": "./node_modules/.bin/tsc -w", "package": "gulp package", "lint": "eslint -c ./.eslintrc.js src/**/*.ts test/**/*.ts sample/**/*.ts", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1" }, "bin": { "typeorm": "./cli.js" }, "funding": "https://opencollective.com/typeorm", "collective": { "type": "opencollective", "url": "https://opencollective.com/typeorm", "logo": "https://opencollective.com/opencollective/logo.txt" }, "nyc": { "all": true, "cache": false, "exclude": [ "**/*.d.ts" ], "extension": [ ".ts" ], "include": [ "build/compiled/src/**", "src/**" ], "reporter": "json" } }
@@ -146,14 +146,8 @@ var RawSqlResultsToEntityTransformer = /** @class */ (function () {
146
146
  return;
147
147
  // this check need to avoid setting properties than not belong to entity when single table inheritance used. (todo: check if we still need it)
148
148
  // const metadata = metadata.childEntityMetadatas.find(childEntityMetadata => discriminatorValue === childEntityMetadata.discriminatorValue);
149
- if (join.relation) {
150
- var relation = metadata.relations.find(function (relation) { return relation.propertyPath === join.relation.propertyPath; });
151
- if (!relation)
152
- return;
153
- // Use current entity's type metadata, join might be from an STI parent with a different type
154
- if (relation.inverseEntityMetadata)
155
- join.alias.metadata = relation.inverseEntityMetadata;
156
- }
149
+ if (join.relation && !metadata.relations.find(function (relation) { return relation === join.relation; }))
150
+ return;
157
151
  // some checks to make sure this join is for current alias
158
152
  if (join.mapToProperty) {
159
153
  if (join.mapToPropertyParentAlias !== alias.name)