@mikro-orm/core 7.0.11-dev.3 → 7.0.11-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.
@@ -139,12 +139,6 @@ export class EntityFactory {
139
139
  const existsData = this.#comparator.prepareEntity(entity);
140
140
  const originalEntityData = helper(entity).__originalEntityData ?? {};
141
141
  const diff = this.#comparator.diffEntities(meta.class, originalEntityData, existsData);
142
- // version properties are not part of entity snapshots
143
- if (meta.versionProperty &&
144
- data[meta.versionProperty] &&
145
- data[meta.versionProperty] !== originalEntityData[meta.versionProperty]) {
146
- diff[meta.versionProperty] = data[meta.versionProperty];
147
- }
148
142
  const diff2 = this.#comparator.diffEntities(meta.class, existsData, data, { includeInverseSides: true });
149
143
  // do not override values changed by user; for uninitialized entities,
150
144
  // the diff may include stale snapshot entries (value is undefined) — skip those
@@ -167,10 +161,11 @@ export class EntityFactory {
167
161
  return diff2[key] === undefined;
168
162
  })
169
163
  .forEach(key => delete diff2[key]);
170
- // but always add collection properties, formulas, and generated columns if they are part of the `data`,
171
- // as these are excluded from `comparableProps` and won't appear in the diff
164
+ // but always add collection properties, formulas, generated columns, and version properties if they
165
+ // are part of the `data`, as these are excluded from `comparableProps` and won't appear in the diff
172
166
  Utils.keys(data)
173
167
  .filter(key => meta.properties[key]?.formula ||
168
+ meta.properties[key]?.version ||
174
169
  (meta.properties[key]?.generated && !meta.properties[key]?.primary) ||
175
170
  [ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(meta.properties[key]?.kind))
176
171
  .forEach(key => (diff2[key] = data[key]));
@@ -47,7 +47,12 @@ export class EntityLoader {
47
47
  throw ValidationError.invalidPropertyName(entityName, invalid.field);
48
48
  }
49
49
  this.setSerializationContext(entities, populate, options);
50
+ const addedToVisited = [];
50
51
  for (const entity of entities) {
52
+ if (visited.has(entity)) {
53
+ continue;
54
+ }
55
+ addedToVisited.push(entity);
51
56
  visited.add(entity);
52
57
  }
53
58
  for (const pop of populate) {
@@ -79,7 +84,7 @@ export class EntityLoader {
79
84
  });
80
85
  }
81
86
  }
82
- for (const entity of entities) {
87
+ for (const entity of addedToVisited) {
83
88
  visited.delete(entity);
84
89
  }
85
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.0.11-dev.3",
3
+ "version": "7.0.11-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
  "keywords": [
6
6
  "data-mapper",
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.0.11-dev.3';
144
+ static #ORM_VERSION = '7.0.11-dev.4';
145
145
  /**
146
146
  * Checks if the argument is instance of `Object`. Returns false for arrays.
147
147
  */