@mikro-orm/core 6.6.17-dev.1 → 6.6.17-dev.3

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.
@@ -26,6 +26,7 @@ export declare class EntityFactory {
26
26
  private readonly hydrator;
27
27
  private readonly eventManager;
28
28
  private readonly comparator;
29
+ private recomputeSnapshot;
29
30
  constructor(em: EntityManager);
30
31
  create<T extends object, P extends string = string>(entityName: EntityName<T>, data: EntityData<T>, options?: FactoryOptions): New<T, P>;
31
32
  mergeData<T extends object>(meta: EntityMetadata<T>, entity: T, data: EntityData<T>, options?: FactoryOptions): void;
@@ -17,6 +17,7 @@ class EntityFactory {
17
17
  hydrator;
18
18
  eventManager;
19
19
  comparator;
20
+ recomputeSnapshot = false;
20
21
  constructor(em) {
21
22
  this.em = em;
22
23
  this.driver = this.em.getDriver();
@@ -30,6 +31,8 @@ class EntityFactory {
30
31
  create(entityName, data, options = {}) {
31
32
  data = Reference_1.Reference.unwrapReference(data);
32
33
  options.initialized ??= true;
34
+ // nested relations created by the hydrator need the same DB-form snapshot as the root (GH #8268)
35
+ options.recomputeSnapshot ??= this.recomputeSnapshot;
33
36
  if (EntityHelper_1.EntityHelper.isEntity(data)) {
34
37
  return data;
35
38
  }
@@ -256,12 +259,15 @@ class EntityFactory {
256
259
  }
257
260
  }
258
261
  hydrate(entity, meta, data, options) {
262
+ const recomputeSnapshot = this.recomputeSnapshot;
263
+ this.recomputeSnapshot = !!options.recomputeSnapshot;
259
264
  if (options.initialized) {
260
265
  this.hydrator.hydrate(entity, meta, data, this, 'full', options.newEntity, options.convertCustomTypes, options.schema, this.driver.getSchemaName(meta, options), options.normalizeAccessors);
261
266
  }
262
267
  else {
263
268
  this.hydrator.hydrateReference(entity, meta, data, this, options.convertCustomTypes, options.schema, this.driver.getSchemaName(meta, options), options.normalizeAccessors);
264
269
  }
270
+ this.recomputeSnapshot = recomputeSnapshot;
265
271
  Utils_1.Utils.keys(data).forEach(key => {
266
272
  (0, wrap_1.helper)(entity)?.__loadedProperties.add(key);
267
273
  (0, wrap_1.helper)(entity)?.__serializationContext.fields?.add(key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.6.17-dev.1",
3
+ "version": "6.6.17-dev.3",
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.3",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.6.17-dev.1",
67
+ "mikro-orm": "6.6.17-dev.3",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }