@mikro-orm/core 7.1.5-dev.17 → 7.1.5-dev.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.1.5-dev.17",
3
+ "version": "7.1.5-dev.19",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "keywords": [
6
6
  "data-mapper",
@@ -993,21 +993,21 @@ export class UnitOfWork {
993
993
  const commitOrderReversed = [...commitOrder].reverse();
994
994
  // early delete - when we recreate entity in the same UoW, we need to issue those delete queries before inserts
995
995
  for (const meta of commitOrderReversed) {
996
- await this.commitDeleteChangeSets(groups[ChangeSetType.DELETE_EARLY].get(meta) ?? [], ctx);
996
+ await this.commitDeleteChangeSets(groups[ChangeSetType.DELETE_EARLY].get(meta._id) ?? [], ctx);
997
997
  }
998
998
  // early update - when we recreate entity in the same UoW, we need to issue those delete queries before inserts
999
999
  for (const meta of commitOrder) {
1000
- await this.commitUpdateChangeSets(groups[ChangeSetType.UPDATE_EARLY].get(meta) ?? [], ctx);
1000
+ await this.commitUpdateChangeSets(groups[ChangeSetType.UPDATE_EARLY].get(meta._id) ?? [], ctx);
1001
1001
  }
1002
1002
  // extra updates
1003
1003
  await this.commitExtraUpdates(ChangeSetType.UPDATE_EARLY, ctx);
1004
1004
  // create
1005
1005
  for (const meta of commitOrder) {
1006
- await this.commitCreateChangeSets(groups[ChangeSetType.CREATE].get(meta) ?? [], ctx);
1006
+ await this.commitCreateChangeSets(groups[ChangeSetType.CREATE].get(meta._id) ?? [], ctx);
1007
1007
  }
1008
1008
  // update
1009
1009
  for (const meta of commitOrder) {
1010
- await this.commitUpdateChangeSets(groups[ChangeSetType.UPDATE].get(meta) ?? [], ctx);
1010
+ await this.commitUpdateChangeSets(groups[ChangeSetType.UPDATE].get(meta._id) ?? [], ctx);
1011
1011
  }
1012
1012
  // extra updates
1013
1013
  await this.commitExtraUpdates(ChangeSetType.UPDATE, ctx);
@@ -1015,7 +1015,7 @@ export class UnitOfWork {
1015
1015
  await this.commitCollectionUpdates(ctx);
1016
1016
  // delete - entity deletions need to be in reverse commit order
1017
1017
  for (const meta of commitOrderReversed) {
1018
- await this.commitDeleteChangeSets(groups[ChangeSetType.DELETE].get(meta) ?? [], ctx);
1018
+ await this.commitDeleteChangeSets(groups[ChangeSetType.DELETE].get(meta._id) ?? [], ctx);
1019
1019
  }
1020
1020
  // take snapshots of all persisted collections
1021
1021
  const visited = new Set();
@@ -1209,7 +1209,10 @@ export class UnitOfWork {
1209
1209
  return;
1210
1210
  }
1211
1211
  const group = groups[cs.type];
1212
- const groupKey = cs.meta.inheritanceType === 'tpt' ? cs.meta : cs.rootMeta;
1212
+ // keyed by `_id` so the groups share keys with `getCommitOrder()`, which dedupes by `_id`;
1213
+ // two `EntityMetadata` instances with the same `_id` (shared metadata cache) must not split
1214
+ // a group between them, or the lookup in `persistToDatabase()` misses and drops it (GH #7903)
1215
+ const groupKey = cs.meta.inheritanceType === 'tpt' ? cs.meta._id : cs.rootMeta._id;
1213
1216
  const classGroup = group.get(groupKey) ?? [];
1214
1217
  classGroup.push(cs);
1215
1218
  if (!group.has(groupKey)) {
package/utils/Utils.js CHANGED
@@ -141,7 +141,7 @@ export function parseJsonSafe(value) {
141
141
  /** Collection of general-purpose utility methods used throughout the ORM. */
142
142
  export class Utils {
143
143
  static PK_SEPARATOR = '~~~';
144
- static #ORM_VERSION = '7.1.5-dev.17';
144
+ static #ORM_VERSION = '7.1.5-dev.19';
145
145
  /**
146
146
  * Checks if the argument is instance of `Object`. Returns false for arrays.
147
147
  */