@mikro-orm/core 7.0.7-dev.17 → 7.0.7-dev.18

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.
@@ -399,10 +399,17 @@ export class EntityLoader {
399
399
  for (const child of children) {
400
400
  childrenMap.add(getKey(child));
401
401
  }
402
+ const isInverseOneToOne = prop.kind === ReferenceKind.ONE_TO_ONE && !prop.owner;
402
403
  for (const entity of entities) {
403
- const ref = entity[prop.name] ?? {};
404
- const key = helper(ref) ? getKey(ref) : undefined;
405
- if (key && childrenMap.has(key) && !itemsMap.has(key)) {
404
+ const ref = entity[prop.name];
405
+ if (ref == null) {
406
+ continue;
407
+ }
408
+ const refKey = getKey(ref);
409
+ // For 1:1 inverse, `children` contains parent entities, so `childrenMap`
410
+ // has parent PKs — match against the entity's own PK, not the referenced entity's PK.
411
+ const childKey = isInverseOneToOne ? getKey(entity) : refKey;
412
+ if (childrenMap.has(childKey) && !itemsMap.has(refKey)) {
406
413
  entity[prop.name] = nullVal;
407
414
  helper(entity).__originalEntityData[prop.name] = null;
408
415
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.0.7-dev.17",
3
+ "version": "7.0.7-dev.18",
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
@@ -132,7 +132,7 @@ export function parseJsonSafe(value) {
132
132
  /** Collection of general-purpose utility methods used throughout the ORM. */
133
133
  export class Utils {
134
134
  static PK_SEPARATOR = '~~~';
135
- static #ORM_VERSION = '7.0.7-dev.17';
135
+ static #ORM_VERSION = '7.0.7-dev.18';
136
136
  /**
137
137
  * Checks if the argument is instance of `Object`. Returns false for arrays.
138
138
  */