@mikro-orm/core 6.5.10-dev.11 → 6.5.10-dev.12
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/entity/EntityLoader.js +19 -1
- package/package.json +2 -2
package/entity/EntityLoader.js
CHANGED
|
@@ -213,7 +213,7 @@ class EntityLoader {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
async findChildren(entities, prop, populate, options, ref) {
|
|
216
|
-
const children = this.getChildReferences(entities, prop, options, ref);
|
|
216
|
+
const children = Utils_1.Utils.unique(this.getChildReferences(entities, prop, options, ref));
|
|
217
217
|
const meta = prop.targetMeta;
|
|
218
218
|
let fk = Utils_1.Utils.getPrimaryKeyHash(meta.primaryKeys);
|
|
219
219
|
let schema = options.schema;
|
|
@@ -269,6 +269,24 @@ class EntityLoader {
|
|
|
269
269
|
// @ts-ignore not a public option, will be propagated to the populate call
|
|
270
270
|
visited: options.visited,
|
|
271
271
|
});
|
|
272
|
+
if ([enums_1.ReferenceKind.ONE_TO_ONE, enums_1.ReferenceKind.MANY_TO_ONE].includes(prop.kind) && items.length !== children.length) {
|
|
273
|
+
const nullVal = this.em.config.get('forceUndefined') ? undefined : null;
|
|
274
|
+
const itemsMap = {};
|
|
275
|
+
const childrenMap = {};
|
|
276
|
+
for (const item of items) {
|
|
277
|
+
itemsMap[(0, wrap_1.helper)(item).getSerializedPrimaryKey()] ??= true;
|
|
278
|
+
}
|
|
279
|
+
for (const child of children) {
|
|
280
|
+
childrenMap[(0, wrap_1.helper)(child).getSerializedPrimaryKey()] ??= true;
|
|
281
|
+
}
|
|
282
|
+
for (const entity of entities) {
|
|
283
|
+
const key = (0, wrap_1.helper)(entity[prop.name] ?? {})?.getSerializedPrimaryKey();
|
|
284
|
+
if (childrenMap[key] != null && itemsMap[key] == null) {
|
|
285
|
+
entity[prop.name] = nullVal;
|
|
286
|
+
(0, wrap_1.helper)(entity).__originalEntityData[prop.name] = null;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
272
290
|
for (const item of items) {
|
|
273
291
|
if (ref && !(0, wrap_1.helper)(item).__onLoadFired) {
|
|
274
292
|
(0, wrap_1.helper)(item).__initialized = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.5.10-dev.
|
|
3
|
+
"version": "6.5.10-dev.12",
|
|
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.2",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.5.10-dev.
|
|
67
|
+
"mikro-orm": "6.5.10-dev.12",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|