@mikro-orm/core 7.0.12-dev.12 → 7.0.12-dev.14
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.
|
@@ -66,6 +66,7 @@ export declare class MetadataDiscovery {
|
|
|
66
66
|
private initPolyEmbeddables;
|
|
67
67
|
private initPolymorphicRelation;
|
|
68
68
|
private initEmbeddables;
|
|
69
|
+
private sameRelationTargetRoot;
|
|
69
70
|
private initSingleTableInheritance;
|
|
70
71
|
/**
|
|
71
72
|
* First pass of TPT initialization: sets up hierarchy relationships
|
|
@@ -1187,6 +1187,16 @@ export class MetadataDiscovery {
|
|
|
1187
1187
|
});
|
|
1188
1188
|
}
|
|
1189
1189
|
}
|
|
1190
|
+
sameRelationTargetRoot(rootProp, prop) {
|
|
1191
|
+
if (!rootProp || rootProp.kind !== prop.kind) {
|
|
1192
|
+
return false;
|
|
1193
|
+
}
|
|
1194
|
+
if (prop.kind !== ReferenceKind.MANY_TO_ONE && prop.kind !== ReferenceKind.ONE_TO_ONE) {
|
|
1195
|
+
return false;
|
|
1196
|
+
}
|
|
1197
|
+
const aRoot = this.#metadata.getByClassName(prop.type, false)?.root;
|
|
1198
|
+
return aRoot != null && aRoot === this.#metadata.getByClassName(rootProp.type, false)?.root;
|
|
1199
|
+
}
|
|
1190
1200
|
initSingleTableInheritance(meta, metadata) {
|
|
1191
1201
|
if (meta.root !== meta && !meta.__processed) {
|
|
1192
1202
|
meta.root = metadata.find(m => m.class === meta.root.class);
|
|
@@ -1227,11 +1237,16 @@ export class MetadataDiscovery {
|
|
|
1227
1237
|
Object.values(meta.properties).forEach(prop => {
|
|
1228
1238
|
const newProp = { ...prop };
|
|
1229
1239
|
const rootProp = meta.root.properties[prop.name];
|
|
1240
|
+
// A child that narrows a relation to a subclass of the root's declared
|
|
1241
|
+
// target (same STI hierarchy) shares the FK column with the root; treat
|
|
1242
|
+
// that as matching so the rename branch below doesn't run (which would
|
|
1243
|
+
// crash — `targetMeta` is only populated later, in `initRelation`).
|
|
1244
|
+
const narrowedRelationOverride = rootProp != null && rootProp.type !== prop.type && this.sameRelationTargetRoot(rootProp, prop);
|
|
1230
1245
|
// stiMerged is set during inlineProperties when a property was merged
|
|
1231
1246
|
// from multiple polymorphic variants with different types. The flag is
|
|
1232
1247
|
// cleared implicitly when the first child claims the root property via
|
|
1233
1248
|
// addProperty below, so subsequent children correctly trigger renaming.
|
|
1234
|
-
const typesMatch = rootProp?.type === prop.type || rootProp?.stiMerged === true;
|
|
1249
|
+
const typesMatch = rootProp?.type === prop.type || rootProp?.stiMerged === true || narrowedRelationOverride;
|
|
1235
1250
|
if (rootProp &&
|
|
1236
1251
|
(!typesMatch ||
|
|
1237
1252
|
(rootProp.fieldNames && prop.fieldNames && !compareArrays(rootProp.fieldNames, prop.fieldNames)))) {
|
|
@@ -1281,6 +1296,12 @@ export class MetadataDiscovery {
|
|
|
1281
1296
|
}
|
|
1282
1297
|
newProp.nullable = true;
|
|
1283
1298
|
newProp.inherited = !rootProp;
|
|
1299
|
+
// For narrowed relation overrides, keep the root's declaration intact so
|
|
1300
|
+
// the full target union (e.g. `Food`) is preserved for populates from the
|
|
1301
|
+
// abstract root — otherwise the last child processed would win.
|
|
1302
|
+
if (narrowedRelationOverride) {
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1284
1305
|
meta.root.addProperty(newProp);
|
|
1285
1306
|
});
|
|
1286
1307
|
meta.tableName = meta.root.tableName;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.0.12-dev.
|
|
3
|
+
"version": "7.0.12-dev.14",
|
|
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.0.12-dev.
|
|
144
|
+
static #ORM_VERSION = '7.0.12-dev.14';
|
|
145
145
|
/**
|
|
146
146
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
147
147
|
*/
|