@mikro-orm/core 6.6.15-dev.3 → 6.6.15-dev.5

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.
@@ -957,7 +957,10 @@ class MetadataDiscovery {
957
957
  if (rootProp?.kind !== prop.kind) {
958
958
  return false;
959
959
  }
960
- if (prop.kind !== enums_1.ReferenceKind.MANY_TO_ONE && prop.kind !== enums_1.ReferenceKind.ONE_TO_ONE) {
960
+ if (prop.kind !== enums_1.ReferenceKind.MANY_TO_ONE &&
961
+ prop.kind !== enums_1.ReferenceKind.ONE_TO_ONE &&
962
+ prop.kind !== enums_1.ReferenceKind.ONE_TO_MANY &&
963
+ prop.kind !== enums_1.ReferenceKind.MANY_TO_MANY) {
961
964
  return false;
962
965
  }
963
966
  const aRoot = this.metadata.find(prop.type)?.root;
@@ -999,7 +1002,13 @@ class MetadataDiscovery {
999
1002
  // that as matching so the rename branch below doesn't run (which would
1000
1003
  // crash — `targetMeta` is only populated later, in `initRelation`).
1001
1004
  const narrowedRelationOverride = rootProp != null && rootProp.type !== prop.type && this.sameRelationTargetRoot(rootProp, prop);
1002
- if (rootProp && !narrowedRelationOverride && (rootProp.type !== prop.type || (rootProp.fieldNames && prop.fieldNames && !(0, Utils_1.compareArrays)(rootProp.fieldNames, prop.fieldNames)))) {
1005
+ // Inverse-side relations (1:m, inverse m:n) have no FK column on this
1006
+ // entity, so the rename branch — which exists to disambiguate physical
1007
+ // columns shared across STI children — doesn't apply. Skipping it also
1008
+ // avoids crashing on `[...rootProp.fieldNames]` since fieldNames is
1009
+ // never populated for inverse-side properties.
1010
+ const isInverseSideRelation = prop.kind === enums_1.ReferenceKind.ONE_TO_MANY || (prop.kind === enums_1.ReferenceKind.MANY_TO_MANY && !prop.owner);
1011
+ if (rootProp && !narrowedRelationOverride && !isInverseSideRelation && (rootProp.type !== prop.type || (rootProp.fieldNames && prop.fieldNames && !(0, Utils_1.compareArrays)(rootProp.fieldNames, prop.fieldNames)))) {
1003
1012
  const name = newProp.name;
1004
1013
  this.initFieldName(newProp, newProp.object);
1005
1014
  newProp.renamedFrom = name;
@@ -1040,6 +1049,14 @@ class MetadataDiscovery {
1040
1049
  if (narrowedRelationOverride) {
1041
1050
  return;
1042
1051
  }
1052
+ // STI siblings can declare the same property name on inverse-side relations
1053
+ // pointing to disjoint targets (e.g. `Dog.items → DogItem` and
1054
+ // `Cat.items → CatItem` with no shared base). There's no physical column
1055
+ // to manage at root, and propagating would clobber the first child's
1056
+ // declaration; each child keeps its local typed property instead.
1057
+ if (isInverseSideRelation && rootProp && rootProp.type !== prop.type) {
1058
+ return;
1059
+ }
1043
1060
  meta.root.addProperty(newProp);
1044
1061
  });
1045
1062
  meta.collection = meta.root.collection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.6.15-dev.3",
3
+ "version": "6.6.15-dev.5",
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.3",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.6.15-dev.3",
67
+ "mikro-orm": "6.6.15-dev.5",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }