@mikro-orm/core 7.1.2 → 7.1.3-dev.0

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.
@@ -1379,15 +1379,17 @@ export class MetadataDiscovery {
1379
1379
  }
1380
1380
  // When multiple STI children share the same unique relation (OneToOne/ManyToOne),
1381
1381
  // replace the simple unique with a composite one including the discriminator column
1382
- // so different subtypes can independently reference the same target row.
1383
- if (rootProp?.unique &&
1384
- newProp.unique &&
1385
- [ReferenceKind.ONE_TO_ONE, ReferenceKind.MANY_TO_ONE].includes(newProp.kind)) {
1382
+ // so different subtypes can independently reference the same target row. The second
1383
+ // child already cleared `rootProp.unique`, so for 3+ children we key on the shared
1384
+ // root property existing rather than its (now false) flag, and dedupe the composite.
1385
+ if (rootProp && newProp.unique && [ReferenceKind.ONE_TO_ONE, ReferenceKind.MANY_TO_ONE].includes(newProp.kind)) {
1386
1386
  newProp.unique = false;
1387
1387
  rootProp.unique = false;
1388
- meta.root.uniques.push({
1389
- properties: [prop.name, meta.root.discriminatorColumn],
1390
- });
1388
+ const properties = [prop.name, meta.root.discriminatorColumn];
1389
+ const exists = meta.root.uniques.some(u => Utils.equals(Utils.asArray(u.properties), properties));
1390
+ if (!exists) {
1391
+ meta.root.uniques.push({ properties });
1392
+ }
1391
1393
  }
1392
1394
  newProp.nullable = true;
1393
1395
  newProp.inherited = !rootProp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.1.2",
3
+ "version": "7.1.3-dev.0",
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.1.2';
144
+ static #ORM_VERSION = '7.1.3-dev.0';
145
145
  /**
146
146
  * Checks if the argument is instance of `Object`. Returns false for arrays.
147
147
  */