@mikro-orm/core 7.2.8-dev.5 → 7.2.8-dev.6

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.2.8-dev.5",
3
+ "version": "7.2.8-dev.6",
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",
@@ -395,7 +395,7 @@ export class UnitOfWork {
395
395
  this.#persistStack.delete(entity);
396
396
  this.#identityMap.delete(entity);
397
397
  }
398
- // remove from referencing relations that are nullable
398
+ // unlink loaded inverse-side items only when the FK is `set null`, other delete rules are left to the database
399
399
  const entityMeta = helper(entity).__meta;
400
400
  for (const prop of entityMeta.bidirectionalRelations) {
401
401
  const inverseProp = prop.mappedBy || prop.inversedBy;
@@ -410,7 +410,9 @@ export class UnitOfWork {
410
410
  : inverseTarget.class !== entityMeta.class) {
411
411
  continue;
412
412
  }
413
- if (prop.kind === ReferenceKind.ONE_TO_MANY && prop2.nullable && Utils.isCollection(relation)) {
413
+ if (prop.kind === ReferenceKind.ONE_TO_MANY &&
414
+ prop2.deleteRule === 'set null' &&
415
+ Utils.isCollection(relation)) {
414
416
  for (const item of relation.getItems(false)) {
415
417
  delete item[inverseProp];
416
418
  }
package/utils/Utils.js CHANGED
@@ -153,7 +153,7 @@ export function parseJsonSafe(value) {
153
153
  /** Collection of general-purpose utility methods used throughout the ORM. */
154
154
  export class Utils {
155
155
  static PK_SEPARATOR = '~~~';
156
- static #ORM_VERSION = '7.2.8-dev.5';
156
+ static #ORM_VERSION = '7.2.8-dev.6';
157
157
  /** Default session variable name backing an RLS filter argument (`current_setting('mikro.<filter>.<arg>')`). */
158
158
  static getRlsSettingName(filterName, argName) {
159
159
  return `mikro.${filterName}.${argName}`;