@mikro-orm/core 6.4.12-dev.11 → 6.4.12-dev.12

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.
@@ -149,6 +149,9 @@ class EntityHelper {
149
149
  set(val) {
150
150
  const entity = Reference_1.Reference.unwrapReference(val ?? wrapped.__data[prop.name]);
151
151
  const old = Reference_1.Reference.unwrapReference(wrapped.__data[prop.name]);
152
+ if (old && old !== entity && prop.kind === enums_1.ReferenceKind.MANY_TO_ONE && prop.inversedBy && old[prop.inversedBy]) {
153
+ old[prop.inversedBy].removeWithoutPropagation(this);
154
+ }
152
155
  wrapped.__data[prop.name] = Reference_1.Reference.wrapReference(val, prop);
153
156
  // when propagation from inside hydration, we set the FK to the entity data immediately
154
157
  if (val && hydrator.isRunning() && wrapped.__originalEntityData && prop.owner) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.4.12-dev.11",
3
+ "version": "6.4.12-dev.12",
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.0",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.4.12-dev.11",
67
+ "mikro-orm": "6.4.12-dev.12",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
package/typings.js CHANGED
@@ -109,6 +109,9 @@ class EntityMetadata {
109
109
  const hydrator = wrapped.hydrator;
110
110
  const entity = entity_1.Reference.unwrapReference(val ?? wrapped.__data[prop.name]);
111
111
  const old = entity_1.Reference.unwrapReference(wrapped.__data[prop.name]);
112
+ if (old && old !== entity && prop.kind === enums_1.ReferenceKind.MANY_TO_ONE && prop.inversedBy && old[prop.inversedBy]) {
113
+ old[prop.inversedBy].removeWithoutPropagation(this);
114
+ }
112
115
  wrapped.__data[prop.name] = entity_1.Reference.wrapReference(val, prop);
113
116
  // when propagation from inside hydration, we set the FK to the entity data immediately
114
117
  if (val && hydrator.isRunning() && wrapped.__originalEntityData && prop.owner) {