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)

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

5.3.0 (2022-08-01)

Bug Fixes

  • postgres: fix having non-PK serial column next to a non-serial PK (6c589b0), closes #3350
  • query-builder: fix qb.insert()/update() on embeddables in inline mode (#3340) (e611fa0)
  • schema: respect explicit columnType when comparing columns (f0a20fa), closes #3317
  • schema: respect schema when renaming columns in postgres (#3344) (f905336)

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 support for virtual entities (#3351) (dcd62ac)

5.2.4 (2022-07-25)

Bug Fixes

  • knex: fix $or over 1:m and m:1 auto-joined relations (#3307) (b6f12b2)

Features

  • knex: allow partial loading of 1:1 owner property from inverse side (d642018), closes #3324

5.2.3 (2022-07-08)

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

5.2.2 (2022-07-03)

Bug Fixes

  • sql: fix prefixing of JSON queries nested on relations (847ff46), closes #3242

5.2.1 (2022-06-21)

Bug Fixes

  • core: prefer current schema for loading wild card pivot table entities (f40cafa), closes #3177

5.2.0 (2022-06-10)

Bug Fixes

  • core: allow changing PK via UoW (32ab215), closes #3184
  • query-builder: fix calling qb.count('id', true).getCount() (a97324a), closes #3182
  • query-builder: fix processing of custom types in explicitly aliased queries (db137a6), closes #3172
  • typing detection with typescript 4.7 node16 (#3163) (08322fa)

Features

  • knex: allow reusing existing knex client via driverOptions (c169eda), closes #3167
  • schema: add logging to schema comparator (f96eaaf)

5.1.5 (2022-05-29)

Bug Fixes

  • query-builder: fix aliasing of relations with composite PK (095e241), closes #3053

Performance Improvements

  • query-builder: use distinct counts only when joining to-many relations (eebe34d), closes #3044

5.1.4 (2022-05-19)

Bug Fixes

  • core: fix aliasing of formula properties in complex conditions (#3130) (071846e)
  • core: improve type of em.getContext() (158f077), closes #3120
  • postgres: do not try to create schema for migrations when it exists (d6af811), closes #3106

5.1.3 (2022-04-27)

Bug Fixes

  • schema: remove FKs first when trying to dropSchema without disabled FKs (b1b5f55), closes #3004
  • sqlite: upgrade knex to v2 + switch back to sqlite3 (f3e4b9d), closes #3046

5.1.2 (2022-04-10)

Bug Fixes

  • core: do not quote knex.raw() instances returned from custom types (8a4c836), closes #1841
  • core: fix mapping of inserted PKs with custom field names from batch insert (080d8e0), closes #2977
  • core: support PopulateHint.INFER with pagination and joined strategy (56f8737), closes #2985
  • postgres: do not ignore custom PK constraint names (#2931) (24bf10e)

Features

  • mariadb: implement check constraint support + fix json column diffing (b513b16), closes #2151
  • schema: support mysql 8 (#2961) (acc960e)

5.1.1 (2022-03-20)

Bug Fixes

  • core: fix custom pivot table entities for unidirectional relations (01bdbf6)
  • knex: order by with a formula field should not include as for sub-queries (#2929) (74751fb)
  • postgres: allow explicit schema name in prop.pivotTable (1860ff5), closes #2919
  • postgres: fix pagination with order by UUID PK (042626c), closes #2910

5.1.0 (2022-03-13)

Bug Fixes

  • core: do not alias JSON conditions on update/delete queries (5c0674e), closes #2839
  • core: fix ordering by complex composite PKs (dde11d3), closes #2886
  • knex: order by with a formula field should not include as (#2848) (09e8bfa)
  • knex: fully qualify sub-query order-by fields (#2835) (f74dc73)
  • 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: enable QueryFlag.PAGINATE automatically for em.find() (ccb4223), closes #2867

5.0.5 (2022-02-27)

Bug Fixes

  • core: fix auto-joining multiple 1:1 properties (0566e74), closes #2821
  • knex: respect explicit transaction in em.count() (#2818) (2d26a63)
  • query-builder: use paginate flag automatically based on to-many joins (db9963f), closes #2823

5.0.4 (2022-02-22)

Bug Fixes

  • schema: escape table/column comments (fff1581), closes #2805

5.0.3 (2022-02-20)

Bug Fixes

  • core: do not trigger global context validation from repositories (f651865), closes #2778

Features

5.0.2 (2022-02-16)

Bug Fixes

  • core: do not ignore schema name in batch queries (b47393e)
  • core: do not ignore schema name in collection updates (d688dc1)
  • postgres: do not ignore custom PK constraint names (3201ef7), closes #2762

5.0.1 (2022-02-13)

Bug Fixes

Features

  • query-builder: allow autocomplete on qb.orderBy() (fdf03c3), closes #2747

5.0.0 (2022-02-06)

Bug Fixes

  • core: allow non-standard property names (hyphens, spaces, ...) (cc68230), closes #1958
  • core: do not ignore qb.onConflict(...).merge() without params (527e188), closes #1774
  • core: ensure correct aliasing when auto-joining PKs in group conditions (38775e6), closes #1734
  • core: fix QueryFlag.PAGINATE with joined loading strategy (c6d72b8)
  • core: fix M:N relations with custom type PKs (3cdc786), closes #1930
  • core: fix nested query with fk as pk (#2650) (cc54ff9), closes #2648
  • core: fix ordering by json properties (741959f)
  • core: fix ordering by pivot table with explicit schema name (eb1f9bb), closes #2621
  • 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 JSON properties (73108b1), closes #1673
  • core: fix removing of m:n items when one is composite (81c0b30), closes #1961
  • core: fix support for nested composite PKs (14dcff8), closes #2647
  • core: improve partial loading of 1:m relations (3ddde1e), closes #2651
  • core: initialize empty collections when fetch joining (02714e5)
  • core: mark entity generator and migrations as peer deps of knex (0e24473), closes #1879
  • core: respect read replica options (#2152) (9ec668d), closes #1963
  • core: respect request context when creating QB (a2b7b84), closes #2669
  • core: update version values in batch updates (8476400), closes #1703
  • core: use $and for merging of multiple filter conditions (0a0622a), closes #1776
  • entity-generator: fix boolean default values (908a638), closes #1917
  • knex: quote version column (#2402) (5bbbd15), closes #2401
  • mongo: validate usage of migrator and entity generator (1db1a63), closes #1801
  • postgres: allow type casting in nested conditions (bbd0eb4), closes #2227
  • query-builder: allow passing array of keys to qb.onConflict().merge() (e4a1cf0), closes #1774
  • query-builder: do not wipe previously defined conditions with qb.delete() (b8a5154), closes #2136
  • query-builder: fix mapping of formula properties (2607266), closes #1599 #2705
  • query-builder: fix nested ordered pagination (#2351) (c5a5c6b)
  • query-builder: respect 0 as limit (#2700) (3f284ed)
  • 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), closes #2706
  • schema: improve diffing of default values for strings and dates (d4ac638), closes #2385
  • sql: split $and branches when auto joining to-many relations (70c795a), closes #2677
  • validation: throw when calling qb.update/delete() after qb.where() (96893e0), closes #2390

chore

  • upgrade typescript to v4.5.2 (2bd8220)

Code Refactoring

  • core: PrimaryKeyType symbol should be defined as optional (db0b399)
  • core: use options parameters on SchemaGenerator (7e48c5d)
  • use options parameters in IDatabaseDriver (#2204) (9a32ac0)

Features

  • core: add QueryFlag.AUTO_JOIN_ONE_TO_ONE_OWNER (be9d9e1), closes #1660
  • core: add custom table check constraint support for postgres (#2688) (89aca5f)
  • core: add index/key name to naming strategy (a842e3e)
  • 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: implement auto-flush mode (#2491) (f1d8bf1), closes #2359
  • core: implement partial loading support for joined loading strategy (2bebb5e), closes #1707
  • 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: support column names with spaces (00b54b4), closes #1617
  • core: validate version mismatch in ORM packages (cf70219)
  • embeddables: allow using m:1 properties inside embeddables (#1948) (ffca73e)
  • entity-generator: add enum generation support (#2608) (1e0b411)
  • entity-generator: add support for generating M:N properties (c0628c5)
  • 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: use snapshots for generating diffs in new migrations (#1815) (9c37f61)
  • mongo: add SchemaGenerator support for mongo (#2658) (cc11859)
  • 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
  • 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: generate down migrations automatically (#2139) (7d78d0c)
  • typings: make em.create() and other methods strict (#1718) (e8b7119), closes #1456

BREAKING CHANGES

  • 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.
  • 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: em.getReference() now has options parameter.
  • Most of the methods on IDatabaseDriver interface now have different signature.
  • 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: 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. 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

4.5.10 (2021-12-26)

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

4.5.9 (2021-08-24)

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

4.5.8 (2021-08-24)

Bug Fixes

  • query-builder: do not wipe previously defined conditions with qb.delete() (380fe3d), closes #2136

4.5.7 (2021-06-30)

Bug Fixes

  • core: fix M:N relations with custom type PKs (ed399b1), closes #1930
  • core: fix removing of m:n items when one is composite (8084845), closes #1961
  • entity-generator: fix boolean default values (219fc0c), closes #1917

4.5.6 (2021-06-06)

Bug Fixes

  • core: mark entity generator and migrations as peer deps of knex (4ad80af), closes #1879

4.5.5 (2021-05-17)

Bug Fixes

  • core: do not ignore qb.onConflict(...).merge() without params (68b570e), closes #1774
  • core: ensure correct aliasing when auto-joining PKs in group conditions (ec971b6), closes #1734
  • core: fix ordering by json properties (53bef71)
  • core: use $and for merging of multiple filter conditions (19f3f1d), closes #1776
  • mongo: validate usage of migrator and entity generator (e41d1c5), closes #1801
  • query-builder: allow passing array of keys to qb.onConflict().merge() (fc3cf01), closes #1774
  • query-builder: validate missing onConflict calls (d9ae997), closes #1803

4.5.4 (2021-04-26)

Bug Fixes

  • core: fix QueryFlag.PAGINATE with joined loading strategy (11aa0a3)
  • core: fix querying by JSON properties (bc5e1a9), closes #1673
  • core: initialize empty collections when fetch joining (6fb9560)
  • core: update version values in batch updates (f5c8ed8), closes #1703

Features

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

4.5.3 (2021-04-09)

Bug Fixes

  • core: do not auto-join composite relations when not needed (b1420a6), closes #1658
  • core: fix aliasing of embeddables in update query (#1650) (6cb5f62)
  • knex: find by custom types with object subconditions (#1656) (d8c328a)

Features

  • query-builder: allow passing raw query bindings via qb.raw() (aa423a5), closes #1654

4.5.2 (2021-04-06)

Bug Fixes

  • core: fix mapping of complex composite keys (c0c658e), closes #1624
  • core: fix querying embeddables over cast fields (#1639) (cb5b25c)
  • core: support advanced custom types in batch queries (88cc71e), closes #1625
  • knex: find entity by advanced custom types (#1630) (ef945d5)

4.5.1 (2021-03-27)

Bug Fixes

  • core: support Collection.loadCount for unidirectional M:N (27e4dd2), closes #1608
  • core: support sql fragments in custom types with joined strategy (527579d), closes #1594

4.5.0 (2021-03-21)

Bug Fixes

  • core: do not process knex.ref() via custom types (ba2ee70), closes #1538
  • core: fix auto-joining with $not operator (8071fd0), closes #1537

Features

4.4.4 (2021-02-21)

Bug Fixes

  • core: improve quoting of advanced custom types (cda3638)

4.4.3 (2021-02-14)

Bug Fixes

  • core: handle convertToJSValueSQL at QB level too (fbb2825), closes #1432
  • core: quote custom type aliases (#1415) (6f6d1ec)

4.4.2 (2021-02-04)

Features

4.4.1 (2021-02-01)

Bug Fixes

4.4.0 (2021-01-24)

Bug Fixes

  • core: allow using lazy flag with formulas (4b2b5ce), closes #1229
  • core: fix pessimistic locking via em.findOne() (a0419a4), closes #1291
  • mysql: enforce 64 character limit for identifier names in SQL (#1297) (9c83b6d), closes #1271
  • schema: fix index name with explicit schema (b62d9ec), closes #1215
  • schema: fix renaming of multiple columns at the same time (677a2b7), closes #1262
  • sql: sort fetch-joined properties on their orderBy (#1336) (f18cd88), closes #1331

Features

4.3.4 (2020-12-11)

Bug Fixes

  • knex: reject in commit() method if commit statement fails (#1177) (f3beb7f), closes #1176
  • sql: ensure correct order of results when fetch joining (7453816), closes #1171
  • sql: use __ when aliasing fetch-joined properties (1479366), closes #1171

4.3.3 (2020-12-04)

Bug Fixes

  • core: fix snapshotting of composite properties (b5f19f2), closes #1079
  • schema: fix diffing tables in other than default schema (429d832), closes #1142 #1143
  • sql: allow no results in em.count() (bc3cdf6), closes #1135

4.3.2 (2020-11-24)

Bug Fixes

  • sql: allow using raw value for JSON prop with custom type (2a17c59), closes #1112

4.3.1 (2020-11-20)

Bug Fixes

  • core: do not interpolate escaped question marks (c54c2a2)

4.3.0 (2020-11-13)

Bug Fixes

  • core: ensure correct grouping and commit order for STI (8b77525), closes #845
  • core: pin dependencies (0f3a8e5), closes #961
  • schema: do not add unique constraint to PKs (a7da03d), closes #1064
  • schema: ensure we do not ignore some columns (5d7dfc1), closes #1009
  • sql: allow using dot inside custom order by expression (11e8c56), closes #1067
  • sql: convert custom types at query builder level (83d3ab2)
  • sql: fix populating M:N via joined strategy with conditions (7113827), closes #1043
  • sql: implement diffing of simple scalar indexes (dc81ef0), closes #957
  • sql: inline array parameters when formatting queries (a21735f), closes #1021
  • sql: interpolate ?? as identifier (a3d4c09), closes #983

Features

  • core: maintain transaction context automatically (#959) (e0064e4)
  • query-builder: allow mapping of complex joined results (#988) (60dd2d8), closes #932

4.2.3 (2020-10-24)

Bug Fixes

  • core: ensure qb.getFormattedQuery() works with postgres (63b2521)

4.2.2 (2020-10-22)

Bug Fixes

  • core: fix mapping of params with custom types (e5049b1), closes #940
  • schema: make sure we do not create FK columns twice in sqlite (1eb6374), closes #942

4.2.1 (2020-10-20)

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

4.2.0 (2020-10-18)

Bug Fixes

  • schema: improve column type equality check (#925) (152f399)

Features

  • core: add basic (in-memory) result caching (2f8253d)
  • core: allow storing embeddables as objects (#927) (ba881e6), closes #906

4.1.1 (2020-10-14)

Bug Fixes

  • postgres: escape question marks in parameters (813e3cd), closes #920

4.1.0 (2020-10-12)

Bug Fixes

  • schema: allow using non-abstract root entity in STI (9dd3aed), closes #874
  • 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

Performance Improvements

  • core: implement bulk updates in mongo driver (5f347c1), closes #732
  • core: implement bulk updates in sql drivers (b005353), closes #732
  • core: interpolate query parameters at ORM level (742b813), 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 compiled PK getters/serializers (0ec99dc), closes #732
  • core: use raw sql for batch updates (1089c57), closes #732

4.0.7 (2020-09-24)

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

  • query-builder: do not select 1:1 owner when auto-joining (86c3032), closes #858
  • query-builder: fix auto-joining of 1:m PKs (920995f), closes #857
  • query-builder: fix count query with auto-joining of 1:1 (9b8056c), closes #858
  • query-builder: wrap nested array conditions with $in operator (939989a), closes #860

4.0.5 (2020-09-21)

Bug Fixes

  • schema: defer creating of composite indexes + implement diffing (f57b457), closes #850

4.0.4 (2020-09-19)

Bug Fixes

  • query-builder: fix mapping of 1:1 inverse sides (a46281e), closes #849
  • query-builder: fix mapping of nested 1:1 properties (9799e70)

Performance Improvements

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

4.0.3 (2020-09-15)

Performance Improvements

  • core: do not use em.merge() internally (6a1a6d6)

4.0.2 (2020-09-11)

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

4.0.1 (2020-09-10)

Bug Fixes

  • core: refactor internals to reduce number of cycles (#830) (3994767)