5.0.0 (2022-02-06)
https://medium.com/@b4nan/mikro-orm-5-stricter-safer-smarter-b8412e84cca4
Bug Fixes
- assign: do not convert FK to entity when assigning to
mapToPK
property (b14c8fb), closes #2337 - cli: validate configuration in CLI cache commands (#2146) (544583b), closes #2145
- core: allow calling
em.create()
with reference wrapper (c069960) - core: allow empty strings in postgres arrays (#2680) (5a33722)
- core: allow using MongoNamingStrategy with SQL drivers (c38c66c)
- core: fix pivot tables for wild card schema entities (623dc91)
- core: fix populating entities with wildcard schema (98d0bfb)
- core: fix support for nested composite PKs (14dcff8)
- core: handle
file://
urls in normalizePath (#2697) (127b0ae) - core: respect request context when creating QB (a2b7b84)
- core: respect specified schema when populating (select-in) (#2676) (21a1be0)
- core: allow non-standard property names (hyphens, spaces, ...) (cc68230), closes #1958
- core: allow propagation to multiple matching inverse sides (cf7d538), closes #2371
- core: consider objects without prototype as POJO (b49807f), closes #2274
- core: declare peer dependencies on driver packages (1873e8c), closes #2110
- core: detect ts-jest usage (94acc18)
- core: do not check stack trace when detecting ts-node (06cca85)
- core: do not override existing values via
prop.onCreate
(fb67ea6) - core: do not propagate
mapToPk
properties (b93c59e) - core: fix conversion of custom type PKs in some cases (28e83ef), closes #1263
- 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 propagation of locking option with select-in population (f3990d0), closes #1670
- core: improve partial loading of 1:m relations (3ddde1e), closes #2651
- core: issue early delete queries for recreating unique properties (decfd10), closes #2273
- 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: reload default values after flush in mysql/sqlite (d57a6a9), closes #2581
- core: respect read replica options (#2152) (9ec668d), closes #1963
- 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 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 clean internal identity map with
disableIdentityMap
(0677d74), closes #1307 - embeddables: order of discovery of embeddables should not matter (d955b29), closes #2149
- knex: quote version column (#2402) (5bbbd15), closes #2401
- migrations: clear the migrations table in
migration:fresh
(63eb4e6) - migrations: respect
baseDir
and allow absolute paths for sqlitedbName
(36a3ae5) - postgres: allow type casting in nested conditions (bbd0eb4), closes #2227
- postgres: fix runtime support for native pg enum arrays (#2584) (fcdb9b0)
- postgres: limit index names to 64 characters (48c105a), closes #1915
- postgres: support comparing array columns via
$eq
(6eb320e), closes #2462 - query-builder: fix mapping of formula properties (2607266)
- query-builder: respect
0
as limit (#2700) (3f284ed) - query-builder: fix nested ordered pagination (#2351) (c5a5c6b)
- query-builder: support joining same property multiple times (b62fb05), closes #2602
- query-builder: translate field names in
qb.merge()
(5aead23), closes #2177 - query-builder: validate missing
onConflict
calls (30392bc), closes #1803 - schema: do not ignore entity level indexes with just expression (0ee9c4d)
- schema: improve diffing of default values for strings and dates (d4ac638), closes #2385
- seeder: fork EM in the seeder manager so we dont use global context (022a1cc)
- sql: split
$and
branches when auto joining to-many relations (70c795a) - sti: allow m:n relations between two STI entities (6c797e9), closes #2246
- ts-morph: fix validation of embedded polymorphic arrays (b6a068a)
- types: fix populate type hints for nullable properties (bc1bf76)
- validation: throw when calling
qb.update/delete()
afterqb.where()
(96893e0), closes #2390
Features
- cli: validate CLI package is installed locally (8952149)
- cli: add
database:create
command (#1778) (7e9d97d), closes #1757 - 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
persistOnCreate
option and enable it for seeder (f0fec1b) - core: add custom table check constraint support for postgres (#2688) (89aca5f)
- core: allow defining check constraints via callback (965f740)
- core: expose
referencedColumnNames
on m:1/1:1 decorators (2f5a5e1) - core: make
em.create()
respect required properties (2385f1d) - core: validate required properties before flushing new entities (9eec3a9)
- core: validate version mismatch in ORM packages (cf70219)
- core: add
EventType.onLoad
that fires after entity is fully loaded (14c2fa9) - core: add
freshEventManager
toem.fork()
options (a0f3fd0), closes #1741 - 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 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 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 onfields
(0097539), closes #2468 - core: conditionally support folder based discovery of ESM (8c8f0d0), closes #2631
- 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
FindOptions.fields
strictly typed (dot notation) (fd43099) - core: make
populate
parameter strictly typed with dot notation (3372f02) - core: move
@UseRequestContext()
decorator tocore
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 ofdomain
API (be27bf7) - core: validate populate hint on runtime for joined strategy too (94877e3), closes #2527
- core: validate usage of global context (#2381) (f0cbcc2)
- embeddables: allow using m:1 properties inside embeddables (#1948) (ffca73e)
- embeddables: support
onCreate
andonUpdate
(288899d), closes #2283 #2391 - entity-generator: add support for generating M:N properties (c0628c5)
- 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 - knex: export also global
knex
function (383bc24) - migrations: allow providing custom
MigrationGenerator
(3cc366b), closes #1913 - migrations: allow using migrations with ES modules (072f23f), closes #2631
- migrations: ensure the database exists when using migrator (02dd67c), closes #1757
- 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)
- query-builder: add
qb.getCount()
method (f773736), closes #2066 - query-builder: allow awaiting the
QueryBuilder
instance (#2446) (c1c4d51) - query-builder: improve typing of
qb.execute()
(c4cfedb), closes #2396 - 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: use community driven faker fork and reexport it (3c9f8e9)
- seeder: add seeder package (#929) (2b86e22), closes #251
- sql: add
qb.indexHint()
method that appends to the from clause (ce89e1f), closes #1663 - 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)
- typings: make
em.create()
and other methods strict (#1718) (e8b7119), closes #1456 - typings: make
toObject()
and similar strict (#1719) (c202396) - support flushing via
Promise.all()
(f788773), closes #2412
Performance Improvements
- core: do not update entity state on forking EM (de3191c)
BREAKING CHANGES
Please see the upgrading guide.