@mikro-orm/core 6.5.4-dev.3 → 6.5.4-dev.4

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": "6.5.4-dev.3",
3
+ "version": "6.5.4-dev.4",
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
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -64,7 +64,7 @@
64
64
  "esprima": "4.0.1",
65
65
  "fs-extra": "11.3.2",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.5.4-dev.3",
67
+ "mikro-orm": "6.5.4-dev.4",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
@@ -853,9 +853,17 @@ class UnitOfWork {
853
853
  }
854
854
  await this.changeSetPersister.executeUpdates(changeSets, batched, { ctx });
855
855
  for (const changeSet of changeSets) {
856
- (0, entity_1.helper)(changeSet.entity).__originalEntityData = this.comparator.prepareEntity(changeSet.entity);
857
- (0, entity_1.helper)(changeSet.entity).__touched = false;
858
- (0, entity_1.helper)(changeSet.entity).__initialized = true;
856
+ const wrapped = (0, entity_1.helper)(changeSet.entity);
857
+ wrapped.__originalEntityData = this.comparator.prepareEntity(changeSet.entity);
858
+ wrapped.__touched = false;
859
+ if (!wrapped.__initialized) {
860
+ for (const prop of changeSet.meta.relations) {
861
+ if ([enums_1.ReferenceKind.MANY_TO_MANY, enums_1.ReferenceKind.ONE_TO_MANY].includes(prop.kind) && changeSet.entity[prop.name] == null) {
862
+ changeSet.entity[prop.name] = entity_1.Collection.create(changeSet.entity, prop.name, undefined, wrapped.isInitialized());
863
+ }
864
+ }
865
+ wrapped.__initialized = true;
866
+ }
859
867
  await this.runHooks(enums_1.EventType.afterUpdate, changeSet);
860
868
  }
861
869
  }