@mikro-orm/core 7.0.9-dev.5 → 7.0.9-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.
@@ -1267,6 +1267,18 @@ export class MetadataDiscovery {
1267
1267
  if (prop.enum && prop.items && rootProp?.items) {
1268
1268
  newProp.items = Utils.unique([...rootProp.items, ...prop.items]);
1269
1269
  }
1270
+ // When multiple STI children share the same unique relation (OneToOne/ManyToOne),
1271
+ // replace the simple unique with a composite one including the discriminator column
1272
+ // so different subtypes can independently reference the same target row.
1273
+ if (rootProp?.unique &&
1274
+ newProp.unique &&
1275
+ [ReferenceKind.ONE_TO_ONE, ReferenceKind.MANY_TO_ONE].includes(newProp.kind)) {
1276
+ newProp.unique = false;
1277
+ rootProp.unique = false;
1278
+ meta.root.uniques.push({
1279
+ properties: [prop.name, meta.root.discriminatorColumn],
1280
+ });
1281
+ }
1270
1282
  newProp.nullable = true;
1271
1283
  newProp.inherited = !rootProp;
1272
1284
  meta.root.addProperty(newProp);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.0.9-dev.5",
3
+ "version": "7.0.9-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",
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.9-dev.5';
135
+ static #ORM_VERSION = '7.0.9-dev.7';
136
136
  /**
137
137
  * Checks if the argument is instance of `Object`. Returns false for arrays.
138
138
  */