@mikro-orm/core 6.6.7 → 6.6.8-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/entity/EntityFactory.js
CHANGED
|
@@ -134,7 +134,10 @@ class EntityFactory {
|
|
|
134
134
|
.filter(key => meta.properties[key]?.formula || [enums_1.ReferenceKind.ONE_TO_MANY, enums_1.ReferenceKind.MANY_TO_MANY].includes(meta.properties[key]?.kind))
|
|
135
135
|
.forEach(key => diff2[key] = data[key]);
|
|
136
136
|
// rehydrated with the new values, skip those changed by user
|
|
137
|
-
|
|
137
|
+
// use full hydration if the entity is already initialized, even if the caller used `initialized: false`
|
|
138
|
+
// (e.g. from createReference), otherwise scalar properties in diff2 won't be applied
|
|
139
|
+
const initialized = options.initialized || (0, wrap_1.helper)(entity).__initialized;
|
|
140
|
+
this.hydrate(entity, meta, diff2, initialized ? { ...options, initialized } : options);
|
|
138
141
|
// we need to update the entity data only with keys that were not present before
|
|
139
142
|
const nullVal = this.config.get('forceUndefined') ? undefined : null;
|
|
140
143
|
Utils_1.Utils.keys(diff2).forEach(key => {
|
|
@@ -142,7 +145,7 @@ class EntityFactory {
|
|
|
142
145
|
if ([enums_1.ReferenceKind.MANY_TO_ONE, enums_1.ReferenceKind.ONE_TO_ONE].includes(prop.kind) && Utils_1.Utils.isPlainObject(data[prop.name])) {
|
|
143
146
|
diff2[key] = entity[prop.name] ? (0, wrap_1.helper)(entity[prop.name]).getPrimaryKey(options.convertCustomTypes) : null;
|
|
144
147
|
}
|
|
145
|
-
if ([enums_1.ReferenceKind.MANY_TO_ONE, enums_1.ReferenceKind.ONE_TO_ONE, enums_1.ReferenceKind.SCALAR].includes(prop.kind) && prop.customType?.ensureComparable(meta, prop) && diff2[key] != null) {
|
|
148
|
+
if (!options.convertCustomTypes && [enums_1.ReferenceKind.MANY_TO_ONE, enums_1.ReferenceKind.ONE_TO_ONE, enums_1.ReferenceKind.SCALAR].includes(prop.kind) && prop.customType?.ensureComparable(meta, prop) && diff2[key] != null) {
|
|
146
149
|
const converted = prop.customType.convertToJSValue(diff2[key], this.platform, { force: true });
|
|
147
150
|
diff2[key] = prop.customType.convertToDatabaseValue(converted, this.platform, { fromQuery: true });
|
|
148
151
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.6.
|
|
3
|
+
"version": "6.6.8-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
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"esprima": "4.0.1",
|
|
65
65
|
"fs-extra": "11.3.3",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.6.
|
|
67
|
+
"mikro-orm": "6.6.8-dev.1",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -50,10 +50,12 @@ class EntityTransformer {
|
|
|
50
50
|
continue;
|
|
51
51
|
}
|
|
52
52
|
const populated = root.isMarkedAsPopulated(meta.className, prop);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
if (!raw) {
|
|
54
|
+
const partiallyLoaded = root.isPartiallyLoaded(meta.className, prop);
|
|
55
|
+
const isPrimary = includePrimaryKeys && meta.properties[prop].primary;
|
|
56
|
+
if (!partiallyLoaded && !populated && !isPrimary) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
57
59
|
}
|
|
58
60
|
const cycle = root.visit(meta.className, prop);
|
|
59
61
|
if (cycle && visited) {
|