@mikro-orm/core 7.0.16 → 7.0.17-dev.1
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/EntityManager.js +17 -1
- package/package.json +1 -1
- package/utils/Utils.js +1 -1
package/EntityManager.js
CHANGED
|
@@ -452,7 +452,23 @@ export class EntityManager {
|
|
|
452
452
|
const prop = meta?.properties[field];
|
|
453
453
|
if (prop && !ref) {
|
|
454
454
|
hint.children ??= [];
|
|
455
|
-
|
|
455
|
+
const targets = prop.polymorphic && prop.polymorphTargets?.length ? prop.polymorphTargets : [prop.targetMeta];
|
|
456
|
+
for (const targetMeta of targets) {
|
|
457
|
+
const before = hint.children.length;
|
|
458
|
+
await this.autoJoinRefsForFilters(targetMeta, { ...options, populate: hint.children }, { class: meta.root.class, propName: prop.name });
|
|
459
|
+
// For polymorphic relations, `hint.children` is applied to every polymorph target during
|
|
460
|
+
// population, so drop any auto-added hint whose field does not exist on every target —
|
|
461
|
+
// otherwise the shared `:ref` would crash when applied to a target lacking it (GH #7722).
|
|
462
|
+
if (targets.length > 1 && hint.children.length > before) {
|
|
463
|
+
const added = hint.children.splice(before);
|
|
464
|
+
for (const h of added) {
|
|
465
|
+
const f = h.field.split(':')[0];
|
|
466
|
+
if (targets.every(t => f in t.properties)) {
|
|
467
|
+
hint.children.push(h);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
456
472
|
}
|
|
457
473
|
}
|
|
458
474
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.17-dev.1",
|
|
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.
|
|
144
|
+
static #ORM_VERSION = '7.0.17-dev.1';
|
|
145
145
|
/**
|
|
146
146
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
147
147
|
*/
|