@mikro-orm/core 6.4.1-dev.17 → 6.4.1-dev.18
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/EntityFactory.js
CHANGED
|
@@ -283,18 +283,21 @@ class EntityFactory {
|
|
|
283
283
|
extractConstructorParams(meta, data, options) {
|
|
284
284
|
return meta.constructorParams.map(k => {
|
|
285
285
|
if (meta.properties[k] && [enums_1.ReferenceKind.MANY_TO_ONE, enums_1.ReferenceKind.ONE_TO_ONE].includes(meta.properties[k].kind) && data[k]) {
|
|
286
|
-
const
|
|
286
|
+
const pk = Reference_1.Reference.unwrapReference(data[k]);
|
|
287
|
+
const entity = this.unitOfWork.getById(meta.properties[k].type, pk, options.schema);
|
|
287
288
|
if (entity) {
|
|
288
289
|
return entity;
|
|
289
290
|
}
|
|
290
291
|
if (Utils_1.Utils.isEntity(data[k])) {
|
|
291
292
|
return data[k];
|
|
292
293
|
}
|
|
293
|
-
|
|
294
|
+
const nakedPk = Utils_1.Utils.extractPK(data[k], meta.properties[k].targetMeta, true);
|
|
295
|
+
if (Utils_1.Utils.isObject(data[k]) && !nakedPk) {
|
|
294
296
|
return this.create(meta.properties[k].type, data[k], options);
|
|
295
297
|
}
|
|
296
298
|
const { newEntity, initialized, ...rest } = options;
|
|
297
|
-
|
|
299
|
+
const target = this.createReference(meta.properties[k].type, nakedPk, rest);
|
|
300
|
+
return Reference_1.Reference.wrapReference(target, meta.properties[k]);
|
|
298
301
|
}
|
|
299
302
|
if (meta.properties[k]?.kind === enums_1.ReferenceKind.EMBEDDED && data[k]) {
|
|
300
303
|
/* istanbul ignore next */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.4.1-dev.
|
|
3
|
+
"version": "6.4.1-dev.18",
|
|
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.2.0",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.4.1-dev.
|
|
67
|
+
"mikro-orm": "6.4.1-dev.18",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -774,7 +774,7 @@ class UnitOfWork {
|
|
|
774
774
|
findExtraUpdates(changeSet, props) {
|
|
775
775
|
for (const prop of props) {
|
|
776
776
|
const ref = changeSet.entity[prop.name];
|
|
777
|
-
if (!ref) {
|
|
777
|
+
if (!ref || prop.deferMode === enums_1.DeferMode.INITIALLY_DEFERRED) {
|
|
778
778
|
continue;
|
|
779
779
|
}
|
|
780
780
|
if (Utils_1.Utils.isCollection(ref)) {
|