@mikro-orm/core 7.1.7-dev.0 → 7.1.7-dev.2
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/metadata/MetadataDiscovery.js +20 -4
- package/package.json +1 -1
- package/utils/Utils.js +1 -1
|
@@ -1073,10 +1073,20 @@ export class MetadataDiscovery {
|
|
|
1073
1073
|
// defaults on db level would mess up with change tracking
|
|
1074
1074
|
delete prop.default;
|
|
1075
1075
|
if (properties[prop.name] && properties[prop.name].type !== prop.type) {
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1076
|
+
const merged = properties[prop.name];
|
|
1077
|
+
const prevEntity = merged.entity;
|
|
1078
|
+
const nextEntity = prop.entity;
|
|
1079
|
+
// merge the `entity`/`target` references too, so the union type survives re-normalization (GH #7983)
|
|
1080
|
+
if (prevEntity && nextEntity) {
|
|
1081
|
+
merged.entity = (() => Utils.unique([...Utils.asArray(prevEntity()), ...Utils.asArray(nextEntity())]));
|
|
1082
|
+
}
|
|
1083
|
+
if (merged.target && prop.target) {
|
|
1084
|
+
merged.target = Utils.unique([...Utils.asArray(merged.target), ...Utils.asArray(prop.target)]);
|
|
1085
|
+
}
|
|
1086
|
+
merged.type = `${merged.type} | ${prop.type}`;
|
|
1087
|
+
merged.runtimeType = 'any';
|
|
1088
|
+
merged.stiMerged = true;
|
|
1089
|
+
return merged;
|
|
1080
1090
|
}
|
|
1081
1091
|
// Deep copy to prevent mutating the original entity's property —
|
|
1082
1092
|
// both from the merge path above (GH #6522/#6523) and from
|
|
@@ -1325,6 +1335,12 @@ export class MetadataDiscovery {
|
|
|
1325
1335
|
Object.values(meta.properties).forEach(prop => {
|
|
1326
1336
|
const newProp = { ...prop };
|
|
1327
1337
|
const rootProp = meta.root.properties[prop.name];
|
|
1338
|
+
// Same-named embedded props merged from polymorphic embeddable variants keep the merged
|
|
1339
|
+
// union-typed declaration, so nested paths of every variant stay resolvable (GH #7983).
|
|
1340
|
+
if (rootProp?.stiMerged && prop.kind === ReferenceKind.EMBEDDED) {
|
|
1341
|
+
rootProp.nullable = true; // each variant fills only its own columns
|
|
1342
|
+
return;
|
|
1343
|
+
}
|
|
1328
1344
|
// A child that narrows a relation to a subclass of the root's declared
|
|
1329
1345
|
// target (same STI hierarchy) shares the FK column with the root; treat
|
|
1330
1346
|
// that as matching so the rename branch below doesn't run (which would
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.1.7-dev.
|
|
3
|
+
"version": "7.1.7-dev.2",
|
|
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.7-dev.
|
|
144
|
+
static #ORM_VERSION = '7.1.7-dev.2';
|
|
145
145
|
/**
|
|
146
146
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
147
147
|
*/
|