@mikro-orm/core 7.0.18-dev.5 → 7.0.18-dev.7

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": "7.0.18-dev.5",
3
+ "version": "7.0.18-dev.7",
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",
@@ -388,13 +388,22 @@ export class UnitOfWork {
388
388
  }
389
389
  continue;
390
390
  }
391
- // inlined pivot M:N (mongo): we can't scrub references from owning-side documents we haven't loaded
391
+ // inlined pivot M:N: scrub the deleted entity from each owning-side document's array;
392
+ // the owner's collection update rides along inside its UPDATE changeset in the same flush
392
393
  if (prop.kind === ReferenceKind.MANY_TO_MANY &&
393
394
  prop.mappedBy &&
394
395
  !this.#platform.usesPivotTable() &&
395
- Utils.isCollection(relation) &&
396
- !relation.isInitialized()) {
397
- throw ValidationError.cannotModifyInverseCollection(entity, prop);
396
+ Utils.isCollection(relation)) {
397
+ if (!relation.isInitialized(true)) {
398
+ throw ValidationError.cannotModifyInverseCollection(entity, prop);
399
+ }
400
+ for (const owner of relation.getItems(false)) {
401
+ const ownerColl = owner[inverseProp];
402
+ if (Utils.isCollection(ownerColl)) {
403
+ ownerColl.removeWithoutPropagation(entity);
404
+ }
405
+ }
406
+ continue;
398
407
  }
399
408
  const target = relation?.[inverseProp];
400
409
  if (relation && Utils.isCollection(target)) {
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.18-dev.5';
144
+ static #ORM_VERSION = '7.0.18-dev.7';
145
145
  /**
146
146
  * Checks if the argument is instance of `Object`. Returns false for arrays.
147
147
  */