Skip to main content
Version: 5.3

Changelog

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

5.3.1 (2022-08-04)

Bug Fixes

  • core: copy orphan removal stack to forks when clear: false (ab72144), closes #3360
  • core: improve check for global context usage (6c906bf), closes #3361
  • core: improve cycle detection when serializing (mainly via toPOJO) (aa10802), closes #3354
  • core: respect contextName in TransactionContext (b2b6a7d), closes #3362

5.3.0 (2022-08-01)

Bug Fixes

  • core: do not trigger auto flush from inside flush hooks (e3f34aa), closes #3345
  • schema: ensure stable order queries (e56a259), closes #3330
  • schema: respect explicit columnType when comparing columns (f0a20fa), closes #3317

Features

  • add support for full text searches (#3317) (8b8f140)
  • core: add $exists mongodb operator with SQL fallback to is not null (112f2be), closes #3295
  • core: add disableContextResolution option to em.fork() (94442f9), closes #3338
  • core: add support for virtual entities (#3351) (dcd62ac)
  • core: add validation when using non-discovered entities in em.populate() (ab93106)
  • core: improve autocomplete for columnType (6bf616d)
  • core: improve autocomplete for type, onUpdateIntegrity and onDelete (7ee2dcb)
  • entity-generator: allow defining entities with EntitySchema instead of decorators (b423c10)
  • mongo: add support for migrations in mongo driver (#3347) (c5c6115)

5.2.4 (2022-07-25)

Bug Fixes

  • core: do not allow passing null to required properties in em.create() (e7843fb), closes #3289
  • core: do not run onUpdate before we know something changed (6faa367), closes #3328
  • core: ensure m:n collection is not dirty after hydration (66e0a21), closes #3323 #3287
  • core: hidden properties are included in cache (#3300) (f0bc261)
  • core: respect schema when lazy loading reference via init (c876c9f), closes #3318

5.2.3 (2022-07-08)

Bug Fixes

  • core: ensure M:N collections are not dirty after populating of inverse side (21ba9b2), closes #3287

5.2.2 (2022-07-03)

Bug Fixes

  • core: consider two NaN as equal when computing changesets (#3250) (95116a0)
  • core: ensure correct context usage in all EntityManager public methods (cc6d59b), closes #3271
  • core: ensure FK as PK is not marked as initialized too early (f12f92f), closes #3269
  • core: fix populating of 1:m collections between wildcard schema entities (69c06aa), closes #3270
  • core: fix populating of relations in afterFlush hook (26ab686), closes #3005
  • core: fix querying JSON properties with operators directly (077ca62), closes #3246
  • mongo: persist explicit null value on object embeddable as null (1c56e7a), closes #3258
  • sql: fix prefixing of JSON queries nested on relations (847ff46), closes #3242

Features

  • core: propagate add operation to m:n owner even if not initialized (#3273) (dc9255c)

5.2.1 (2022-06-21)

Bug Fixes

  • core: fix reloading version values with custom types on PKs (ebd7888), closes #3209
  • core: fix serialization of entities wrapped in POJOs (af4fadf), closes #3221
  • core: ignore undefined values during options merge (9e0f559), closes #3234
  • mysql: handle mediumint PKs correctly (0bbbe5c), closes #3230
  • types: fix inference of optional PKs (424e0bb), closes #3230

Features

  • core: allow to adjust default type mapping (ca8ce57), closes #3066

Performance Improvements

  • core: allow disabling change tracking on property level (7d5e32d), closes #3019
  • core: make Collection.add on not managed entities much faster (75adda9), closes #3211

5.2.0 (2022-06-10)

Bug Fixes

  • core: allow changing PK via UoW (32ab215), closes #3184
  • core: ensure correct cached value in loadCount (4471bb8)
  • query-builder: fix processing of custom types in explicitly aliased queries (db137a6), closes #3172
  • typing detection with typescript 4.7 node16 (#3163) (08322fa)

Features

  • core: automatically discover target embeddables and relationships (#3190) (8624dc5)
  • entity-generator: allow generating bidirectional relations (8b93400), closes #3181
  • entity-generator: allow generating identified references (1fbf5ac)
  • schema: add logging to schema comparator (f96eaaf)

5.1.5 (2022-05-29)

Bug Fixes

  • cli: disable TS mode when we fail to register ts-node (457d9d3), closes #3152
  • core: assign new embeddable entity only when it is null or undefined (#3135) (4f870fb)

5.1.4 (2022-05-19)

Bug Fixes

  • core: allow asterisk in FindOptions.fields on TS level (43e1d0b), closes #3127
  • core: improve type of em.getContext() (158f077), closes #3120
  • core: improve validation of wrong entity references (#3085) (f5de135)
  • core: wrap relations in Reference wrapper when assigning entity instance (97f1f59), closes #3092
  • mongo: support queries with mongo specific operators on embeddables (2fb9002)
  • postgres: do not try to create schema for migrations when it exists (d6af811), closes #3106

Features

  • core: add strict option to em.findOneOrFail() (#3088) (d38242a)

5.1.3 (2022-04-27)

Bug Fixes

  • core: allow replacing target entity in relations with assign (90ec83f), closes #3026
  • core: do not inline query for JSON properties that match PK names (e6005d8), closes #3054
  • core: fix serialization when using partial loading for nested relations (00be9f1), closes #3011
  • core: hydrate nullable embedded properties as null (e8490f6), closes #3063
  • core: respect mapToPk when expanding properties (#3031) (757801e)
  • schema: fix diffing of indexes with too long inferred name (01ba9ed), closes #2932

Features

  • core: try to fix FK order automatically for custom pivot entities (cc9e427), closes #3040
  • core: validate decorator parameters are used properly (cb3e1dd), closes #3040
  • seeder: created shared context when calling other seeders (6fa04ae), closes #3022

Performance Improvements

  • core: do not use contextual EM where we know we are in a fork already (ba16532)

5.1.2 (2022-04-10)

Bug Fixes

  • core: allow converting custom types via em.nativeInsert() (#2979) (8d76852)
  • core: do not clean up UoW before each "flush step" (3ae732d), closes #2934
  • core: fix eager loading of nested embeddable m:1 properties (4867db9), closes #2975
  • core: fix eager loading when multiple relations target same entity (21922ce), closes #2990
  • core: fix mapping of inserted PKs with custom field names from batch insert (080d8e0), closes #2977
  • core: never reassign the same entity via em.assign() (cdfbabd), closes #2974
  • core: propagate entity removal in em.transactional() to upper context (6e5166b), closes #2973
  • core: respect connectionType in populate queries (fe40a9f), closes #2994
  • core: use correct path for relations inside embeddables with populate: true (4735dba), closes #2948
  • postgres: do not ignore custom PK constraint names (#2931) (24bf10e)
  • schema: do not create FK index for 1:1 properties (they are unique already) (473795c), closes #2942

Features

5.1.1 (2022-03-20)

Bug Fixes

  • core: fix custom pivot table entities for unidirectional relations (01bdbf6)
  • postgres: fix pagination with order by UUID PK (042626c), closes #2910
  • postgres: respect known schema when loading wild card entity relations (61d1e85), closes #2909

Features

  • core: validate em.begin was called when using em.commit/rollback (67fa076), closes #2918

5.1.0 (2022-03-13)

Bug Fixes

  • core: do not alias JSON conditions on update/delete queries (5c0674e), closes #2839
  • core: ensure all entities from inner context are merged to the upper one (7b3a6b4), closes #2882
  • core: fix object key utilities for null prototype objects (#2847) (b2cf01e), closes #2846
  • core: fix strict type for orderBy when entity has length property (ef45871), closes #2829
  • core: type global entityRepository option weakly (3faf8bc)
  • mysql: mark FK columns as unsigned for mixed composite PKs (67806cb), closes #2844
  • postgres: respect schema name in migration storage (fbf9bfa), closes #2828

Features

  • core: allow better control over connection type when using read-replicas (#2896) (e40ae2d)
  • core: allow forcing write connection via forceWriteConnection (#2838) (36d1969)
  • core: allow specifying custom pivot table entity (#2901) (8237d16)
  • core: allow using hooks for interface entities (#2895) (aee99b1)
  • core: enable QueryFlag.PAGINATE automatically for em.find() (ccb4223), closes #2867
  • core: map check constraint failures to specific error type (ebcbdff), closes #2836

5.0.5 (2022-02-27)

Bug Fixes

  • core: respect orphanRemoval in 1:1 relations (#2816) (55ff07b)
  • query-builder: use paginate flag automatically based on to-many joins (db9963f), closes #2823

5.0.4 (2022-02-22)

Bug Fixes

  • core: always create new entities as initialized (bbb30c5)
  • core: fix mapping default values of relation properties (bc57ed0)
  • core: fix propagation of FK as PK with not flushed entity (25be857), closes #2810
  • core: fix unsetting identity of orphans (1:1 with orphan removal) (91e7315), closes #2806
  • core: respect schema from config when adding new entities to context (7a6b6e2)
  • entity-generator: fix property names for columns with dashes (#2813) (c920d5f)

Features

  • core: respect load strategy specified in property definition (1a6b4b2), closes #2803

5.0.3 (2022-02-20)

Bug Fixes

  • core: do not trigger global context validation from repositories (f651865), closes #2778
  • core: fix processing of onUpdate properties (9cf454e), closes #2781
  • core: fix processing of multiple onUpdate properties on one entity (4f0e4cc), closes #2784
  • core: hydrate not-null embeddable prop even with all null values (09aee05), closes #2774
  • core: register entity to identity map as early as possible (d8f3613), closes #2777
  • core: respect onDelete: cascade when propagating removal (f1e8578), closes #2703
  • core: revert to require() when getting ORM version to fix webpack support (6cfb526), closes #2799
  • postgres: consider int8 as numeric when inferring autoincrement value (64bc99d), closes #2791
  • typing: fix populate hints on collections where both type args are provided (e39ef5b), closes #2771

Features

  • add better-sqlite driver (#2792) (1b39d66)
  • core: add connect config option (8aaad33)
  • core: add SchemaGenerator.clearDatabase() (ecad9c6), closes #2220
  • core: add populate option to Reference.load and Collection.loadItems (1527c1a), closes #2796

5.0.2 (2022-02-16)

Bug Fixes

  • core: allow passing entity instance in repo.nativeInsert() (791c009)
  • core: do not ignore schema name from config in em.getReference() (58680fc)
  • core: do not ignore value from database even if we only have a getter (35103b3), closes #2760
  • core: respect global schema (b569686)
  • postgres: do not ignore custom PK constraint names (3201ef7), closes #2762
  • typing: remove overloads for em.nativeInsert() (e21d470)

5.0.1 (2022-02-13)

Bug Fixes

  • core: allow cloning QB with raw conditions (04d9d88), closes #2748
  • core: allow using 0 as PK (a2e423c), closes #2729
  • core: do not propagate removal to FK as PK (a0a19c2), closes #2723
  • core: fix support for complex composite (nested) PKs (a7fc7a1), closes #2647
  • core: ignore ORM packages where we failed to extract version (b1627c5), closes #2732
  • core: respect null in Loaded type (72385b3), closes #2750
  • core: return entity type from em.create() instead of New<T> (8ff277d), closes #2727
  • core: support special characters in clientUrl (43e28b8), closes #2730
  • core: use createRequire instead of dynamic import for JSON files (f567d2d), closes #2738
  • embeddables: fix loading inline embeddables with joined strategy (adaa5c6), closes #2717
  • esm: fix getting ORM version on windows with ESM (eb3a1be)
  • mongo: fix caching populated results in mongo (42ea5be), closes #2754
  • schema: fix explicit schema name support (#2752) (68631ea)
  • typing: exclude symbols and functions from FilterQuery (1d24eb8), closes #2742

Features

  • core: add getContext parameter to @UseRequestContext() (9516b48), closes #2721
  • query-builder: allow autocomplete on qb.orderBy() (fdf03c3), closes #2747
  • schema: ensure database when calling refreshDatabase() (7ce12d6)
  • seeder: refactor seeder to support running compiled files (#2751) (8d9c4c0), closes #2728

5.0.0 (2022-02-06)

Bug Fixes

  • assign: do not convert FK to entity when assigning to mapToPK property (b14c8fb), closes #2337
  • core: allow calling em.create() with reference wrapper (c069960)
  • core: allow non-standard property names (hyphens, spaces, ...) (cc68230), closes #1958
  • core: allow propagation to multiple matching inverse sides (cf7d538), closes #2371
  • core: allow putting not managed entities to remove stack (7a47151), closes #2395
  • core: allow using updateNestedEntities flag with collections (65de1a5), closes #1717
  • core: allow using MongoNamingStrategy with SQL drivers (c38c66c), closes #2693
  • core: consider non-plain objects as PKs (2fe9f2b), closes #1721
  • core: consider objects without prototype as POJO (b49807f), closes #2274
  • core: convert custom types for onCreate & onUpdate (e5f5b38), closes #1751
  • core: convert custom types for collection items in joined strategy (5b76600), closes #1754
  • core: convert custom types on PKs in update and delete queries (b33be4a), closes #1798
  • core: defer cascading of persist operation (6abb3b0), closes #2161
  • core: detect ts-jest usage (94acc18)
  • core: do not apply limit/offset to populate pivot table queries (a73c4e0), closes #2121
  • core: do not check stack trace when detecting ts-node (06cca85)
  • core: do not override existing values via prop.onCreate (fb67ea6)
  • core: do not override internal EM instance when forking EM (8139174), closes #2342
  • core: do not propagate mapToPk properties (b93c59e)
  • core: do not save entity state in merge when it's not initialized (4141539), closes #1927
  • core: ensure correct casting in deep JSON queries with operators (5c79e34), closes #1734
  • core: fix findAndCount with populate (d2f69ae), closes #1736
  • core: fix QueryFlag.PAGINATE with joined loading strategy (c6d72b8)
  • core: fix assigning embedded arrays (f02fb75), closes #1699
  • core: fix assigning to object property without value (90165ab), closes #2492
  • core: fix clearing 1:m collections (462a126), closes #1914
  • core: fix collection state when forceEntityConstructor is used (674abbb), closes #2406 #2409
  • core: fix conversion of custom type PKs in some cases (28e83ef), closes #1263
  • core: fix extraction of child condition when populating 2 (1653269), closes #1882
  • core: fix hydrating of inlined embeddables via em.create() (057317f), closes #1840
  • core: fix joined strategy with FK as PK (5412913), closes #1902
  • core: fix M:N relations with custom type PKs (3cdc786), closes #1930
  • core: fix missing embedded columns on joined select query (#2664) (88e2309)
  • core: fix nested query with fk as pk (#2650) (cc54ff9), closes #2648
  • core: fix ordering by pivot table with explicit schema name (eb1f9bb), closes #2621
  • core: fix persisting complex composite keys in m:1 relations (9f91b54), closes #1687
  • core: fix pivot tables for wild card schema entities (623dc91), closes #2690
  • core: fix populating entities with wildcard schema (98d0bfb)
  • core: fix propagation of locking option with select-in population (f3990d0), closes #1670
  • core: fix querying by complex composite keys via entity instance (293a3cb), closes #1695
  • core: fix querying by JSON properties (73108b1), closes #1673
  • core: fix reflection of enums in babel (a5b8ee9), closes #2198
  • core: fix serialization of self referencing collections (79c2a10), closes #2059
  • core: fix state of entities from result cached (0d95eef), closes #1704
  • core: fix support for nested composite PKs (14dcff8), closes #2647
  • core: fix transaction context in nested transactions (091e60d), closes #1910
  • core: improve partial loading of 1:m relations (3ddde1e), closes #2651
  • core: issue delete queries after extra/collection updates (66468da)
  • core: issue early delete queries for recreating unique properties (decfd10), closes #2273
  • core: make entity helper property non-enumerable (3cac0cf)
  • core: propagate em.remove() to 1:m collections (c23c39c), closes #2395
  • core: propagate em.remove() to m:1 properties of 1:m relations (e6fa2f7), closes #2636
  • core: propagate unsetting of 1:1 from inverse side (1e78977), closes #1872
  • core: rehydrate custom types when using metadata cache (3bcb9a5), closes #2489
  • core: reload default values after flush in mysql/sqlite (d57a6a9), closes #2581
  • core: remove entity from its bidirectional relations after delete (7e40b5c), closes #2238
  • core: reset current transaction before running afterFlush event (d98837d), closes #1824
  • core: respect filters defined on base entities (65fec06), closes #1979
  • core: respect read replica options (#2152) (9ec668d), closes #1963
  • core: respect specified schema when populating (select-in) (#2676) (21a1be0)
  • core: rework orphan removal and cascading (#2532) (eb3ea4a)
  • core: save collection snapshots recursively after flush (3f5ba2f), closes #2410 #2411
  • core: schedule orphan removal on 1:1 inverse sides when relation nulled (a904fe8), closes #2273
  • core: support extending in tsconfig.json (#1804) (e1e0adb), closes #1792
  • core: support getters in EntitySchema property types (9858205), closes #1867
  • core: support loading lazy scalar properties via em.populate() (c20fe88), closes #1479
  • core: sync MigrateOptions type in core with migrations package (#2259) (d4b8c2c)
  • core: truly load the whole entity graph when populate: true (3c21663), closes #1134
  • core: use $and for merging of multiple filter conditions (0a0622a), closes #1776
  • core: use clean internal identity map with disableIdentityMap (0677d74), closes #1307
  • core: use tsconfig-paths loadConfig function (#1854) (76e8d1c), closes #1849
  • embeddables: add missing serialization options to @Embedded() (9f91578), closes #2464
  • embeddables: allow using more than 10 embedded arrays (7806667), closes #1912
  • embeddables: ensure order of discovery does not matter for embeddables (b095d9e), closes #2242
  • embeddables: fix validating nullable object embeddables (8ab2941), closes #2233
  • embeddables: order of discovery of embeddables should not matter (d955b29), closes #2149
  • handle file:// urls in normalizePath (#2697) (127b0ae)
  • mongo: do not use separate update queries for M:N collections if not needed (e57984d), closes #2483
  • mongo: fix extraction of child condition when populating (66ab1c6), closes #1891
  • mongo: validate usage of migrator and entity generator (1db1a63), closes #1801
  • postgres: add extra array operators (#2467) (576117e)
  • postgres: fix propagation of PKs with custom names (41380de), closes #1990
  • postgres: support comparing array columns via $eq (6eb320e), closes #2462
  • schema: improve diffing of default values for strings and dates (d4ac638), closes #2385
  • sti: allow m:n relations between two STI entities (6c797e9), closes #2246
  • sti: fix prototype of child entity after it gets loaded (a0827f5), closes #2493 #2364
  • sti: respect custom table names (42a9522), closes #2356
  • ts-morph: fix validation of embedded polymorphic arrays (b6a068a)
  • types: fix populate type hints for nullable properties (bc1bf76), closes #2701
  • validation: validate missing 1:m mappedBy key in factory (e75fcff), closes #2393

chore

  • upgrade typescript to v4.5.2 (2bd8220)

Code Refactoring

  • core: PrimaryKeyType symbol should be defined as optional (db0b399)
  • core: remove @Repository() decorator (17a55b6)
  • core: remove em.find/findOne arguments in favour of options object (7b577ab)
  • core: return Collection instance from LoadedCollection.get()/$ (27cbe69), closes #2394
  • core: use options parameter in em.merge() (aaee27c)
  • core: use options parameters on SchemaGenerator (7e48c5d)
  • enable populateAfterFlush by default (6dc184c), closes #784
  • use options parameters in IDatabaseDriver (#2204) (9a32ac0)

Features

  • cli: allow exporting async functions from CLI config (912728d)
  • cli: improve loading of CLI settings from package.json (03f9ddd), closes #545
  • cli: only warn with useTsNode: true without ts-node available (5aff134), closes #1957
  • core: add em.clearCache(key) method (1ccfad8)
  • core: add EventType.onLoad that fires after entity is fully loaded (14c2fa9)
  • core: add freshEventManager to em.fork() options (a0f3fd0), closes #1741
  • core: add persistOnCreate option and enable it for seeder (f0fec1b), closes #2629
  • core: add populateWhere option (#2660) (16c5e91)
  • core: add QueryFlag.AUTO_JOIN_ONE_TO_ONE_OWNER (be9d9e1), closes #1660
  • core: add Reference.createFromPK() helper method (2217154)
  • core: add callback parameter to Collection.remove() (0b37654), closes #2398
  • core: add custom table check constraint support for postgres (#2688) (89aca5f)
  • core: add index/key name to naming strategy (a842e3e)
  • core: add PlainObject class that DTO's can extend to treat class as POJO (#1837) (645b27a)
  • core: add support for advanced locking (0cbed9c), closes #1786
  • core: add support for concurrency checks (#2437) (acd43fe)
  • core: add support for custom property ordering (#2444) (40ae4d6)
  • core: add support for ESM via gen-esm-wrapper (aa71065), closes #1010
  • core: add support for multiple schemas (including UoW) (#2296) (d64d100), closes #2074
  • core: add support for polymorphic embeddables (#2426) (7b7c3a2), closes #1165
  • core: allow configuring aliasing naming strategy (#2419) (89d63b3)
  • core: allow defining check constraints via callback (965f740), closes #2688 #1711
  • core: allow passing arrays in orderBy parameter (#2211) (0ec22ed), closes #2010
  • core: allow providing custom Logger instance (#2443) (c7a75e0)
  • core: allow using short lived tokens in config (4499838), closes #1818
  • core: automatically infer populate hint based on fields (0097539), closes #2468
  • core: conditionally support folder based discovery of ESM (8c8f0d0), closes #2631
  • core: expose referencedColumnNames on m:1/1:1 decorators (2f5a5e1), closes #593
  • core: implement auto-flush mode (#2491) (f1d8bf1), closes #2359
  • core: implement auto-refreshing of loaded entities (#2263) (9dce38c), closes #2292
  • core: implement partial loading support for joined loading strategy (2bebb5e), closes #1707
  • core: keep collection state of dirty collections after initializing (49ed651), closes #2408
  • core: make em.create() respect required properties (2385f1d)
  • core: make FindOptions.fields strictly typed (dot notation) (fd43099)
  • core: make populate parameter strictly typed with dot notation (3372f02)
  • core: move @UseRequestContext() decorator to core package (253216d)
  • core: rework deep assigning of entities and enable it by default (#1978) (8f455ad)
  • core: support column names with spaces (00b54b4), closes #1617
  • core: use AsyncLocalStorage instead of domain API (be27bf7)
  • core: validate populate hint on runtime for joined strategy too (94877e3), closes #2527
  • core: validate required properties before flushing new entities (9eec3a9), closes #2176
  • core: validate usage of global context (#2381) (f0cbcc2)
  • core: validate version mismatch in ORM packages (cf70219)
  • embeddables: allow using m:1 properties inside embeddables (#1948) (ffca73e)
  • embeddables: support onCreate and onUpdate (288899d), closes #2283 #2391
  • entity-generator: add enum generation support (#2608) (1e0b411)
  • entity-generator: allow specifying schema (beb2993), closes #1301
  • filters: add em parameter to the filter callback parameters (6858986), closes #2214
  • migrations: allow providing custom MigrationGenerator (3cc366b), closes #1913
  • migrations: allow using migrations with ES modules (072f23f), closes #2631
  • migrations: store migrations without extensions (4036716), closes #2239
  • migrations: use snapshots for generating diffs in new migrations (#1815) (9c37f61)
  • mongo: add SchemaGenerator support for mongo (#2658) (cc11859)
  • mongo: upgrade node-mongodb to v4 (#2425) (2e4c135)
  • schema: add support for timestamp columns in mysql (a224ec9), closes #2386
  • schema: allow disabling foreign key constraints (fcdb236), closes #2548
  • schema: rework schema diffing (#1641) (05f15a3), closes #1486 #1518 #579 #1559 #1602 #1480 #1687
  • seeder: add seeder package (#929) (2b86e22), closes #251
  • sql: add callback signature to expr() with alias parameter (48702c7), closes #2405
  • sql: allow setting transaction isolation level (6ae5fbf), closes #819
  • sql: allow tuple comparison via expr helper (90777a7), closes #2399
  • sql: generate down migrations automatically (#2139) (7d78d0c)
  • support flushing via Promise.all() (f788773), closes #2412
  • typings: make em.create() and other methods strict (#1718) (e8b7119), closes #1456
  • typings: make toObject() and similar strict (#1719) (c202396)

Performance Improvements

  • core: define Reference properties on prototype (4ba390d)
  • core: do not redefine Collection properties as non-enumerable (8a604a6)
  • core: do not update entity state on forking EM (de3191c)
  • core: reuse EntityComparator on fork() (#2496) (b2a9b12)
  • core: use shared memory for cycles when computing change sets (ced0fad), closes #2379
  • core: various small performance improvements in UoW (84b5d1b)

BREAKING CHANGES

  • core: Previously the validation took place in the database, so it worked only for SQL drivers. Now we have runtime validation based on the entity metadata. This means mongo users now need to use nullable: true on their optional properties, or disable the validation globally via validateRequired: false in the ORM config.
  • core: Previously when we had nonstandard PK types, we could use PrimaryKeyType symbol to let the type system know it. It was required to define this property as required, now it can be defined as optional too.
  • core: em.create() will now require you to pass all non-optional properties. Some properties might be defined as required for TS but we have a default value for them (either runtime, or database one) - for such we can use OptionalProps symbol to specify which properties should be considered as optional.
  • After flushing a new entity, all relations are marked as populated, just like if the entity was loaded from the db. This aligns the serialized output of e.toJSON() of a loaded entity and just-inserted one.

In v4 this behaviour was disabled by default, so even after the new entity was flushed, the serialized form contained only FKs for its relations. We can opt in to this old behaviour via populateAfterFlush: false.

  • Previously it was possible to call em.populate() with a single entity input, and the output would be again just a single entity.

Due to issues with TS 4.5, this method now always return array of entities. You can use destructing if you want to have a single entity return type:

const [loadedAuthor] = await em.populate(author, ...);
  • core: Embeddable instances are now created via EntityFactory and they respect the forceEntityConstructor configuration. Due to this we need to have EM instance when assigning to embedded properties.

Using em.assign() should be preferred to get around this.

Deep assigning of child entities now works by default based on the presence of PKs in the payload. This behaviour can be disable via updateByPrimaryKey: false in the assign options.

mergeObjects option is now enabled by default.

  • core: Previously with select-in strategy as well as with QueryBuilder, table aliases were always the letter e followed by unique index. In v5, we use the same method as with joined strategy - the letter is inferred from the entity name.

This can be breaking if you used the aliases somewhere, e.g. in custom SQL fragments. We can restore to the old behaviour by implementing custom naming strategy, overriding the aliasName method:

import { AbstractNamingStrategy } from '@mikro-orm/core';

class CustomNamingStrategy extends AbstractNamingStrategy {
  aliasName(entityName: string, index: number) {
    return 'e' + index;
  }
}

Note that in v5 it is possible to use expr() helper to access the alias name dynamically, e.g. expr(alias => `lower('${alias}.name')`), which should be now preferred way instead of hardcoding the aliases.

  • core: Previously those dynamically added getters returned the array copy of collection items. In v5, we return the collection instance, which is also iterable and has a length getter and indexed access support, so it mimics the array. To get the array copy as before, call getItems() as with a regular collection.
  • core: em.getReference() now has options parameter.
  • Most of the methods on IDatabaseDriver interface now have different signature.
  • core: The decorator was problematic as it could only work properly it the file was required soon enough - before the ORM initialization, otherwise the repository would not be registered at all.

Use @Entity({ customRepository: () => CustomRepository }) in the entity definition instead.

  • core: em.fork() now has an options object parameter instead of the separate boolean params.
  • core: merge() has now the last parameter as options object instead of two separate bool params.
  • core: Populate parameter is now strictly typed and supports only array of strings or a boolean. Object way is no longer supported. To set loading strategy, use FindOptions.strategy.
  • core: Following method signatures changed, options parameter is now the only way to set things like populate, orderBy, etc.
  • em.find()
  • em.findOne()
  • em.findOneOrFail()
  • em.findAndCount()
  • repo.find()
  • repo.findOne()
  • repo.findOneOrFail()
  • repo.findAndCount()
  • repo.findAll()
  • core: SchemaGenerator API changed, boolean parameters are now removed in favour of options objects
interface SchemaGenerator {
  generate(): Promise<string>;
  createSchema(options?: { wrap?: boolean }): Promise<void>;
  ensureDatabase(): Promise<void>;
  getCreateSchemaSQL(options?: { wrap?: boolean }): Promise<string>;
  dropSchema(options?: { wrap?: boolean; dropMigrationsTable?: boolean; dropDb?: boolean }): Promise<void>;
  getDropSchemaSQL(options?: { wrap?: boolean; dropMigrationsTable?: boolean }): Promise<string>;
  updateSchema(options?: { wrap?: boolean; safe?: boolean; dropDb?: boolean; dropTables?: boolean }): Promise<void>;
  getUpdateSchemaSQL(options?: { wrap?: boolean; safe?: boolean; dropDb?: boolean; dropTables?: boolean }): Promise<string>;
  createDatabase(name: string): Promise<void>;
  dropDatabase(name: string): Promise<void>;
  execute(sql: string, options?: { wrap?: boolean }): Promise<void>;
}
  • sql: - em.transactional() signature has changed, the parameter is now options object
  • em.begin() signature has changed, the parameter is now options object
  • core: Signature of em.populate() changed, it now uses options parameter.
-populate<P>(entities: T, populate: P, where?: FilterQuery<T>, orderBy?: QueryOrderMap,
-            refresh?: boolean, validate?: boolean): Promise<Loaded<T, P>>;
+populate<P>(entities: T,populate: P, options?: EntityLoaderOptions<T>): Promise<Loaded<T, P>>;
  • typings: Some methods are now strictly typed, so previously fine usages might be restricted on TS level.
  • typings: Some methods are now strictly typed, so previously fine usages might be restricted on TS level. To get around those, we might either cast as any, provide the generic T type as any, or use expr helper.
em.create(User, { someNotDefinedProp: 123 }); // throws if someNotDefinedProp not on the User
em.create(User, { [expr('someNotDefinedProp')]: 123 }); // works, using expr
em.create<any>(User, { someNotDefinedProp: 123 }); // works, using type cast
em.create(User, { someNotDefinedProp: 123 } as any); // works, using type cast
  • core: Node ">= 12.17.0 || >= 13.10.0" required.

4.5.10 (2021-12-26)

Bug Fixes

  • core: allow putting not managed entities to remove stack (0edb72e), closes #2395
  • core: defer cascading of persist operation (7d18310), closes #2161
  • core: do not override internal EM instance when forking EM (fb0abf9), closes #2342
  • core: do not save entity state in merge when it's not initialized (bdd7452), closes #1927
  • core: fix assigning to object property without value (aca56e1), closes #2492
  • core: fix collection state when forceEntityConstructor is used (53d4c39), closes #2406 #2409
  • core: fix reflection of enums in babel (05dee1d), closes #2198
  • core: fix serialization of self referencing collections (fdbe4f4), closes #2059
  • core: rehydrate custom types when using metadata cache (3ea37a6), closes #2489
  • core: remove entity from its bidirectional relations after delete (c754a62), closes #2238
  • embeddables: add missing serialization options to @Embedded() (aca6d08), closes #2464
  • embeddables: ensure order of discovery does not matter for embeddables (e3f9dbc), closes #2242
  • embeddables: fix validating nullable object embeddables (d60dded), closes #2233
  • mongo: do not use separate update queries for M:N collections if not needed (f6383a0), closes #2483
  • postgres: add extra array operators (#2467) (a1fd357)
  • sti: fix prototype of child entity after it gets loaded (e78942a), closes #2493 #2364
  • sti: respect custom table names (b17aea9), closes #2356
  • validation: validate missing 1:m mappedBy key in factory (7ef40c0), closes #2393

Performance Improvements

  • core: define Reference properties on prototype (4ef2623)
  • core: do not redefine Collection properties as non-enumerable (523addd), closes #2543
  • core: reuse EntityComparator on fork() (#2496) (bd2ccfd)
  • core: use shared memory for cycles when computing change sets (c12ff4b), closes #2379
  • core: various small performance improvements in UoW (d8ea1c2)

4.5.9 (2021-08-24)

Note: Version bump only for package @mikro-orm/core

4.5.8 (2021-08-24)

Bug Fixes

  • core: detect ts-jest usage (d54ccc2)
  • core: do not apply limit/offset to populate pivot table queries (1f2d430), closes #2121
  • core: do not propagate mapToPk properties (c37f42e)

4.5.7 (2021-06-30)

Bug Fixes

  • core: fix clearing 1:m collections (29cd17b), closes #1914
  • core: fix M:N relations with custom type PKs (ed399b1), closes #1930
  • core: fix transaction context in nested transactions (d88dd8b), closes #1910
  • core: make entity helper property non-enumerable (ce99eb2)
  • core: respect filters defined on base entities (4657d05), closes #1979
  • embeddables: allow using more than 10 embedded arrays (ab8e706), closes #1912
  • postgres: fix propagation of PKs with custom names (9ce0c37), closes #1990

Features

  • cli: only warn with useTsNode: true without ts-node available (3aa3a6c), closes #1957

4.5.6 (2021-06-06)

Bug Fixes

  • core: fix extraction of child condition when populating 2 (f22eec1), closes #1882
  • core: fix hydrating of inlined embeddables via em.create() (34391cd), closes #1840
  • core: fix joined strategy with FK as PK (adaa59b), closes #1902
  • core: propagate unsetting of 1:1 from inverse side (903d484), closes #1872
  • core: reset current transaction before running afterFlush event (539311e), closes #1824
  • core: support getters in EntitySchema property types (0b831d0), closes #1867
  • core: use tsconfig-paths loadConfig function (#1854) (fbfb148), closes #1849
  • mongo: fix extraction of child condition when populating (3cf30e1), closes #1891

Features

  • core: add PlainObject class that DTO's can extend to treat class as POJO (#1837) (2e9c361)

4.5.5 (2021-05-17)

Bug Fixes

  • core: allow using updateNestedEntities flag with collections (db77e8b), closes #1717
  • core: convert custom types for onCreate & onUpdate (34c1aa5), closes #1751
  • core: convert custom types for collection items in joined strategy (bea37e0), closes #1754
  • core: convert custom types on PKs in update and delete queries (1b5270d), closes #1798
  • core: ensure correct casting in deep JSON queries with operators (0441967), closes #1734
  • core: fix findAndCount with populate (61bc7cf), closes #1736
  • core: issue delete queries after extra/collection updates (fc48890)
  • core: support extending in tsconfig.json (#1804) (6597552), closes #1792
  • core: use $and for merging of multiple filter conditions (19f3f1d), closes #1776
  • mongo: validate usage of migrator and entity generator (e41d1c5), closes #1801

4.5.4 (2021-04-26)

Bug Fixes

  • core: consider non-plain objects as PKs (82387ad), closes #1721
  • core: fix QueryFlag.PAGINATE with joined loading strategy (11aa0a3)
  • core: fix assigning embedded arrays (9ee8f5c), closes #1699
  • core: fix persisting complex composite keys in m:1 relations (a932366), closes #1687
  • core: fix querying by complex composite keys via entity instance (b1b7894), closes #1695
  • core: fix querying by JSON properties (bc5e1a9), closes #1673
  • core: fix state of entities from result cached (8d0f076), closes #1704

Features

  • core: add QueryFlag.AUTO_JOIN_ONE_TO_ONE_OWNER (378e468), closes #1660

4.5.3 (2021-04-09)

Bug Fixes

  • core: ensure eager loaded relations are actually loaded (897c7bd), closes #1657
  • discovery: fix metadata validation of nested embeddables (1d7c123), closes #1616
  • postgres: improve extra updates logic for batch updates (84b40bc), closes #1664

Features

  • postgres: fix batch inserts with PKs with custom field name (4500ca7), closes #1595

4.5.2 (2021-04-06)

Bug Fixes

  • core: fix mapping of complex composite keys (c0c658e), closes #1624
  • core: support native bigint as primary key (#1626) (bce7afe)

4.5.1 (2021-03-27)

Bug Fixes

  • core: create child entities that use Reference wrapper as new (b14cdcb), closes #1592
  • core: support Collection.loadCount for unidirectional M:N (27e4dd2), closes #1608
  • core: support nested embeddables inside embedded arrays (088c65d), closes #1585
  • core: support sql fragments in custom types with joined strategy (527579d), closes #1594

4.5.0 (2021-03-21)

Bug Fixes

  • core: apply filters when populating M:N relations (cd8330a), closes #1232
  • core: do not process knex.ref() via custom types (ba2ee70), closes #1538
  • core: do not update entity state when cascade merging (6c74109), closes #1523
  • core: expose filters in some repository methods (a1e1553), closes #1236
  • core: support operators in json property queries (cb5e715), closes #1487
  • sqlite: ensure booleans are hydrated as booleans (4e36df2), closes #1553
  • sqlite: fix calling em.find() from hooks (fec3285), closes #1503

Features

  • cli: allow mikro-orm config to return Promise (#1495) (629aae9)
  • core: add Collection.matching() method to allow pagination (#1502) (1ad3448), closes #334
  • core: add close method to CacheAdapter interface (2795b5a), closes #1509
  • core: allow updating nested 1:1 and m:1 references with EntityAssigner (#1535) (c1dd048)
  • core: infer configuration from environment variables (#1498) (1ff07a7), closes #1472
  • core: support custom types in embeddables (53305d3), closes #1519
  • core: support embeddable arrays (#1496) (57b605c), closes #1369
  • reflection: support enum arrays and custom types (dc65527), closes #1497
  • validation: validate correct reference types (381b5b9), closes #1568

4.4.4 (2021-02-21)

Bug Fixes

  • core: allow extending existing custom types (cc34d7e), closes #1442
  • core: do not define dynamic id property if not needed (e13188f), closes #1444

Performance Improvements

4.4.3 (2021-02-14)

Bug Fixes

  • core: ignore falsy values in Collection.remove() (3447039), closes #1408
  • core: propagate custom join columns to inverse side (m:n) (3f0a7b2), closes #1429
  • core: respect mergeObjects only for POJOs in assign helper (c5bbcee), closes #1406
  • core: use generic comparison for object properties (e9073cf), closes #1395

4.4.2 (2021-02-04)

Features

4.4.1 (2021-02-01)

Bug Fixes

  • core: allow assigning null to embeddable property (#1356) (f3a091e)
  • core: fix eager relations with joined loading strategy (ba94e28), closes #1352
  • sti: respect child types when querying for STI entity (df298a1), closes #1252
  • typing: improve handling of array properties (9d82ffb), closes #1077

4.4.0 (2021-01-24)

Bug Fixes

  • core: em.create() should not mutate the input object (b83b211), closes #1294
  • core: allow using lazy flag with formulas (4b2b5ce), closes #1229
  • core: always make new entity snapshot (1dacf1e), closes #1334
  • core: apply discriminator condition when loading STI entities (9c62370), closes #1252
  • core: clear inverse references to removed entities (3a1d927), closes #1278
  • core: fix creating entity graph from deeply nested structures (833d246), closes #1326
  • core: fix custom types with joined loading strategy (f64e657), closes #1237
  • core: fix nullable embeddables in object mode (bb8dbce), closes #1296
  • core: improve custom sql expression detection (cf8c5cd), closes #1261
  • core: make PK property of Reference required (5e1cf23)
  • core: respect context when working with filter params (97ed314), closes #1312
  • core: support FK as PK in Collection.getIdentifiers() (#1225) (f8024c9), closes #1224

Features

Performance Improvements

  • core: make IdentityMap iterable (e13757a)

4.3.4 (2020-12-11)

Bug Fixes

  • core: hydrate embeddable scalar properties (#1192) (eb73093)
  • core: validate overridden properties by embeddables (#1172) (6629a08), closes #1169
  • sql: ensure correct order of results when fetch joining (7453816), closes #1171

Features

  • core: auto-discover base entities (33bda07)

4.3.3 (2020-12-04)

Bug Fixes

  • core: fix em.create() with nested relations (dde119f), closes #1150
  • core: fix populating 1:m where the owner uses mapToPk (85a7c9d), closes #1128
  • core: fix propagating of changes to 1:m with mapToPk (b38df3e), closes #1128
  • core: fix snapshotting of composite properties (b5f19f2), closes #1079
  • schema: allow using const enums (e02ffea), closes #1096
  • sqlite: fix querying by 1:1 relation with composite PK (0da6347), closes #1157

4.3.2 (2020-11-24)

Bug Fixes

  • core: disable propagation when mapToPk is used (6f6a204), closes #1124
  • core: do not use custom toJSON when storing result cache (86ec3b3)
  • core: fix comparison of object properties and bigints (2119a65), closes #1117
  • core: fix computing changesets with reference as PK (5504436), closes #1111
  • core: fix serialization of properties with same name (d4d9c48), closes #1115
  • sql: allow using raw value for JSON prop with custom type (2a17c59), closes #1112

4.3.1 (2020-11-20)

Bug Fixes

  • core: assign embedded properties from class objects (#1087) (c2b4972), closes #1083
  • core: rework unique property extra updates (bd19d03), closes #1025 #1084
  • ts-morph: fix discovery of IdentifiedReference with ts-morph (d94bd91), closes #1088

4.3.0 (2020-11-13)

Bug Fixes

  • core: always check remove stack when cascade persisting (a9a1bee), closes #1003
  • core: do not override child class properties (#1000) (6d91f1f)
  • core: ensure correct grouping and commit order for STI (8b77525), closes #845
  • core: ensure correct handling of empty arrays (c9afabb)
  • core: ensure correct handling of empty arrays (1c4ba75)
  • core: ensure we store the right value for bigint PKs (7d7a1c9), closes #1038
  • core: fix cascading when assigning collections (d40fcfa), closes #1048
  • core: pin dependencies (0f3a8e5), closes #961
  • discovery: allow using absolute paths in entities (584854c), closes #1073
  • schema: pass entity name to joinKeyColumnName() (fe4b7bd), closes #1026
  • sql: convert custom types at query builder level (83d3ab2)
  • sql: do not batch update unique properties (87b722a), closes #1025
  • sql: inline array parameters when formatting queries (a21735f), closes #1021
  • sql: take snapshots of collections populated via joined strategy (5f3288a), closes #1041
  • validation: don't validate inherited STI props (#998) (63d1f57), closes #997

Features

  • core: allow calling Collection.set() on not initialized collections (1d0bb85), closes #1048
  • core: allow extending embeddables (#1051) (89d3250), closes #1049
  • core: allow mapping null to undefined optionally (55de84e), closes #1019
  • core: allow using multiple ORM instances with RequestContext (e11040d), closes #872
  • core: maintain transaction context automatically (#959) (e0064e4)
  • count: initial implementation of loadCount (#955) (3371415), closes #949
  • query-builder: allow mapping of complex joined results (#988) (60dd2d8), closes #932

4.2.3 (2020-10-24)

Bug Fixes

  • core: ensure global filters are enabled by default (#952) (28124fb)
  • core: rework access to target entity metadata from collections (10ca335), closes #956

4.2.2 (2020-10-22)

Bug Fixes

  • core: fix mapping of params with custom types (e5049b1), closes #940
  • core: fix wrongly inferred 1:m metadata (82f7f0a), closes #936

Features

  • core: add MetadataStorage.clear() to clear the global storage (c6fa0f4), closes #936

4.2.1 (2020-10-20)

Bug Fixes

  • core: make sure refreshing of loaded entities works (45f3f42)
  • core: validate object embeddable values on flush (cd38e17), closes #466
  • core: validate the object passed to em.persist() (90678c2)

4.2.0 (2020-10-18)

Bug Fixes

  • core: fix propagation of conditions with operators (05acd34)
  • core: reset the working state of UoW after failures (6423cf7)
  • core: update umzug types to 2.3 (4668e78), closes #926
  • core: use entity ctors also when all PKs are provided in em.create() (b45b60b), closes #924
  • schema: fix automatic discriminator map values in STI (7cd3c6f), closes #923

Features

  • core: add basic (in-memory) result caching (2f8253d)
  • core: add native support for enum arrays (9053450), closes #476
  • core: allow defining multiple entities in single file (e3ab336), closes #922
  • core: allow mapping m:1/1:1 relations to PK (#921) (894f17e), closes #750
  • core: allow storing embeddables as objects (#927) (ba881e6), closes #906
  • serialization: rework handling of cycles (1a2d026)

4.1.0 (2020-10-12)

Bug Fixes

  • core: allow defining PKs inside @BeforeCreate() (0a2299f), closes #893 #892
  • core: do not cascade remove FK primary keys (37415ce), closes #915
  • core: do not fire onInit event twice (9485f48), closes #900
  • core: ensure custom types are comparable (3714a51), closes #864
  • core: fix detection of custom type PKs with object value (61095ce), closes #910
  • core: fix mapping of returning zero values in embeddables (e42ae4a), closes #905
  • core: skip index initialization for abstract entities (#881) (a2d381f)
  • mongo: filter by serialized PK inside group condition (a492a64), closes #908
  • schema: make STI metadata discovery order independent (f477a48), closes #909
  • sqlite: rework schema support for composite keys in sqlite (82e2efd), closes #887
  • typings: improve inference of the entity type (67f8015), closes #876

Features

  • core: add EntityRepository.merge() method (f459334), closes #868

Performance Improvements

  • core: implement bulk updates in sql drivers (b005353), closes #732
  • core: improve hydration performance (3cafbf3), closes #732
  • core: interpolate query parameters at ORM level (742b813), closes #732
  • core: optimize entity hydration (6c56a05), closes #732
  • core: use batching in uow deletes (8cbb22a), closes #732
  • core: use bulk inserts in all drivers (10f2e55), closes #732
  • core: use dedicated identity maps for each entity (84667f9), closes #732
  • core: use faster way to check number of object keys (82f3ee4), closes #732
  • core: use JIT compilation for diffing entities (60f10a4), closes #732
  • core: use JIT compilation for snapshotting entities (5612759), closes #732
  • core: use JIT compilation in hydrator (1f06a52), closes #732
  • core: use JIT compiled PK getters/serializers (0ec99dc), closes #732

4.0.7 (2020-09-24)

Bug Fixes

  • core: do not store original data for references (0a9ef65), closes #864

Features

  • core: add groupBy, having and schema to CountOptions (d3c3858)

Performance Improvements

  • core: use batch inserts in UoW (postgres & mongodb) (#865) (54ad928), closes #732

4.0.6 (2020-09-22)

Bug Fixes

  • deps: update dependency escaya to ^0.0.49 (#854) (d4737b6)
  • query-builder: wrap nested array conditions with $in operator (939989a), closes #860

4.0.5 (2020-09-21)

Bug Fixes

  • core: fix merging results from QB to existing entity (218098a)
  • schema: defer creating of composite indexes + implement diffing (f57b457), closes #850

Features

  • mapping: make @Unique and @Index (optionally) typesafe (afe6801), closes #850

4.0.4 (2020-09-19)

Bug Fixes

  • core: allow filter condition callbacks without arguments (5b3401f), closes #847
  • core: allow filter condition callbacks without arguments (da8fbfc), closes #847
  • core: allow querying ArrayType with a value (e505358), closes #844
  • core: improve metadata validation of STI relations (0b97af8), closes #845
  • core: update filter typing to allow async condition (#848) (2188f62)
  • deps: update dependency escaya to ^0.0.44 (#839) (fedb41c)
  • deps: update dependency escaya to ^0.0.45 (#842) (d9f9f05)
  • query-builder: fix mapping of nested 1:1 properties (9799e70)

Features

  • core: allow setting loading strategy globally (e4378ee), closes #834

Performance Improvements

  • move reference to metadata to entity prototype + more improvements (#843) (f71e4c2), closes #732

Reverts

  • Revert "refactor: return target from decorator definition" (e021617)

4.0.3 (2020-09-15)

Bug Fixes

  • core: make a copy of custom type values to allow array diffing (6ae72ae)

Features

  • core: allow using AsyncLocalStorage for request context (47cd9a5), closes #575

Performance Improvements

  • core: create the helper instance early (f4f90eb)
  • core: do not generate internal entity uuid (9f46aa4)
  • core: do not use em.merge() internally (6a1a6d6)
  • core: remove WrappedEntity.__internal map (2228fcb)
  • core: skip processing of hooks when there are no hooks (425784b)
  • core: store entity identifier on entity helper (403acca)
  • core: store original entity data on entity helper (6a91b01)

4.0.2 (2020-09-11)

Bug Fixes

  • core: simplify Collection type args (1fb6cec)

4.0.1 (2020-09-10)

Bug Fixes

  • core: hydrate user defined discriminator columns (#831) (8671440), closes #827
  • core: refactor internals to reduce number of cycles (#830) (3994767)