v6.0.0
6.0.0 (2024-01-08)
https://mikro-orm.io/blog/mikro-orm-6-released
Bug Fixes
- core: allow using classes with private constructor with
EntitySchema
(d4d5b5e) - core: collection.loadItems() should respect wildcard populate (7f3065f), closes #4977
- core: do not load all env vars from
.env
files automatically (09e60f7) - core: ensure correct serialization of not fully populated collections (a39a850)
- core: ensure propagation and change-tracking works with
useDefineForClassFields
(#4730) (83f24aa), closes #4216 - core: fix automatic calling of
ensureDatabase
oninit
(827b1f1) - core: fix hydration of complex FKs with joined strategy (a4f30ac)
- core: fix hydration of object embeddables via joined strategy (b3e3e55), closes #5020
- core: ignore SQL converter on object embeddables with custom types (83b989e), closes #5074
- core: improve
EntitySchema
typing forrepository
option (37ee42e), closes #5006 - core: make
em.create
strictly typed for relations too (#4752) (3535cc0), closes #4748 - core: make
Loaded
type more flexible (c95e3b6), closes #3277 - core: mark
Reference.set()
as private (#5017) (5aebf0b), closes #5003 - core: refactor mapping of
Date
properties (#4391) (3a80369), closes #4362 #4360 #1476 - core: respect
@Index
and@Unique
decorators on embeddables (#4736) (c3d7717) - core: respect global
schema
option in first level cache (1833455) - core: respect schema option for entity instances in
em.insert/Many
(7eae031), closes #4424 - core: return managed entity from
em.refresh()
(0bf5363) - core: return managed entity from
em.refresh()
(55815f4) - core: rework
Collection
initialization to useem.populate()
(#4571) (7495142), closes #4464 - core: rework pivot table joining (#4438) (0506d36), closes #4423
- core: support embedded properties with conflicting property names (b43ef63), closes #5065
- core: use
join on
conditions forpopulateWhere
(#4025) (a03e57c), closes #3871 - entity-generator: use index expressions for complex indexes (e.g. conditional) (64a39f8), closes #4911
- knex: respect connection type in
em.getKnex()
(46957ba) - mongo: don't rename
id
to_id
for embeddables and entities without serialized PK (0cee82d), closes #4960 - postgres: allow postgres array operators on embedded array properties (ecf1f0c), closes #4930
- postgres: parse timestamp dates less than year 100 (e774d40), closes #5071
- respect postgresql no timestamptz precision default (#3832) (9fd7e26)
- sql: do not alias conditions for update queries with collection operators (5820d66), closes #4956
- sql: do not branch to-many joins for
$and
with a single item (a737b20) - test: fixed seed-manager.test.js on windows (#4924) (27a4504)
Code Refactoring
- remove
JavaScriptMetadataProvider
(4e337cb) - remove
Reference.load(prop: keyof T)
signature (#5015) (32b48f7)
Features
- core: add
@EnsureRequestContext
decorator + rename@UseRequestContext
(5e088ae), closes #4009 - core: add
Collection.load()
method (8aa1ad1) - core: add
EagerProps
symbol to respect eager props on type level (dfcf1f8) - core: add
em.findAll()
with optionalwhere
option (#4946) (23b0551), closes #3982 - core: add
FindOptions.exclude
(#5024) (fe239cf) - core: add
GeneratedCacheAdapter
for production usage (#4167) (bd478af), closes #4164 - core: add
Hidden
type as an alternative toHiddenProps
symbol (#5009) (c047bb1) - core: add
HiddenProps
symbol as type-level companion forhidden: true
(7984769), closes #4093 - core: add
MikroORM.initSync()
helper (#4166) (8b1a1fa), closes #4164 - core: add
Opt
type as an alternative toOptionalProps
symbol (#4753) (8853904) - core: add
orm.checkConnection()
helper (#4961) (b868f02), closes #4959 - core: add
ScalarRef
andEntityRef
types to allow explicit control (1ef7856), closes #4907 - core: add
sql.now()
,sql.lower()
andsql.upper()
functions (#5044) (016fe63) - core: add
sql.ref()
helper (#4402) (b695811) - core: add cursor-based pagination via
em.findByCursor()
(#3975) (1e6825f) - core: add customizable
LoggerContext
with labeling support (#4233) (b985646), closes #4230 - core: add discovery hooks
onMetadata
andafterDiscovered
(#4799) (5f6c4f8) - core: add entity to identity map on
em.persist()
(1b09d26), closes #4905 - core: add global
serialization.forceObject
option (731087d), closes #4881 - core: add optional
Type.compareValues
method to allow custom comparators (732307a), closes #4870 - core: add support for indexes on JSON properties (#4735) (82c8629), closes #1230
- core: allow all
CountOptions
inCollection.loadCount()
(25d1851) - core: allow auto-discovery of base classes with
EntitySchema
(10cfd28) - core: allow class references in
subscribers
array (7c8f776), closes #4231 - core: allow configuring filters in
Reference.load()
andCollection.load()
(#5025) (06012f7), closes #4975 - core: allow defining
serialization.forceObject: true
on type level (#5045) (88eb3e5) - core: allow disabling colors via
colors
ORM config option (1bcaf09), closes #5037 - core: allow extending
EntityManager
(#5064) (6c363e7) - core: allow inferring populate hint from filter via
populate: ['$infer']
(#4939) (080fdbb), closes #1309 - core: allow M:1 and 1:1 relations in virtual entities (#4932) (164a69e)
- core: allow mapping database defaults from inline embeddables (#4384) (22ad61e), closes #3887
- core: allow overriding global logging options on per-query basis (#4273) (51b6250), closes #4223
- core: allow overriding ORM config path via
--config
(#3924) (2c929e0) - core: allow passing string values for
PopulateHint
enum (populateWhere
) (2bd21eb) - core: allow populating collections with references (#4776) (3da6c39), closes #1158
- core: allow setting logger context on EM level (#5023) (7e56104), closes #5022
- core: allow type-safe populate all via
populate: ['*']
(#4927) (7780f34), closes #4920 - core: allow using
Ref
wrapper on scalar properties (#4358) (f9c30f1) - core: allow using dataloader for references and collections (#4321) (8f4790f), closes #266
- core: allow using string values for
loadStrategy
andflushMode
(f4e4e3b) - core: auto-join M:1 and 1:1 relations with filters (#5063) (66a6b75), closes #4975
- core: improve validation of bidirectional 1:1 relations (7eb6ee6)
- core: infer property type from default value (#4150) (38be986), closes #4060
- core: make
em.insert/Many
strictly typed (require all properties) (01935e6) - core: native
BigInt
support (#4719) (31a905c) - core: re-export the core package from all drivers (#3816) (175c059)
- core: remove static require calls (#3814) (b58f476), closes #3743
- core: require
mappedBy
option for 1:m properties (716aa76) - core: require explicitly marked raw queries via
raw()
helper (#4197) (9c1b205) - core: respect
ignoreFields
on type level inwrap().toObject()
(15de7a0), closes #4198 - core: respect
schema
parameter inclientUrl
(#4998) (9176ee0), closes #4997 - core: respect naming strategy and explicit field names on embedded properties (#4866) (6151f3b), closes #4371 #2165 #2361
- core: respect updates to M:N inverse sides and batch them (#4798) (ec65001), closes #4564
- core: return
Loaded
type fromRef.load()
(bc3ffa9), closes #3755 - core: return single entity from
em.populate()
when called on single entity (4c4ec23) - core: rework serialization rules to always respect populate hint (#4203) (32d7c5f), closes #4138 #4199
- core: strict partial loading (#4092) (d5d8c2d), closes #3443
- core: support atomic updates via
raw()
helper (#4094) (1cd0d1e), closes #3657 - core: support mapping one column to different STI properties (#4769) (e8d391b), closes #2388 #4440
- core: throw when trying to iterate on a not initialized collection (2a3fd27), closes #3750
- core: validate abstract target in relation decorators (dddb901)
- core: validate duplicate field names (#4968) (71fead4), closes #4359
- core: validate missing relation decorator (af31b3b), closes #3807
- entity-generator: added ability to output type option in decorator (#4935) (2d1936a)
- entity-generator: allow generating scalar properties for FKs (#4892) (abad6ca), closes #4898
- entity-generator: allow local and global configuration of all options (#4965) (2876b8a)
- entity-generator: allow overriding generated entity file name (4ebc8e3), closes #5026
- entity-generator: detect more ManyToMany relations (#4974) (d0e3ac9)
- entity-generator: generate
OptionalProps
and other symbols forEntitySchema
(00f0a34) - mysql: support
order by nulls first/last
(#5021) (df75b24), closes #5004 - postgres: add support for native enums (#4296) (8515380), closes #2764
- postgres: add support for weighted tsvectors and a custom regconfig (#3805) (a0e2c7f), closes #3317
- query-builder: add support for lateral sub-query joins (99f87c4), closes #624
- query-builder: allow joining sub-queries (#4747) (613332c), closes #4429 #4549
- query-builder: respect discriminator column when joining STI relation (57b7094), closes #4351
- query-builder: support virtual entities (27f0c83), closes #5069
- schema: add options to
schema.ensureDatabase()
method to create/clear (6a12fe1) - sql: add native support for generated columns (#4884) (a928291)
- sql: print number of affected rows for insert and update queries (36336d9)
- sql: rework joined strategy to support the default
populateWhere: 'all'
(#4957) (e5dbc24) - sql: support
$some
,$none
and$every
subquery operators (#4917) (50d2265), closes #2916 - sql: use joined strategy as default for SQL drivers (#4958) (90ec766)
- sql: use returning statements for reloading version fields on update (0a3abd7)
Performance Improvements
- core: cache if entity has event listeners (cfa8d52)
- core: optimize handling of FK value propagation (f3d0ec5)
- core: speed up detection of constructor/toJSON parameters during discovery (a1288de)
BREAKING CHANGES
Please see the upgrading guide.
Full Changelog: v5.9.7...v6.0.0