@mikro-orm/core 7.1.0-dev.40 → 7.1.0-dev.42
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/EntityAssigner.js
CHANGED
|
@@ -99,6 +99,14 @@ export class EntityAssigner {
|
|
|
99
99
|
return EntityAssigner.assignReference(entity, value, prop, options.em, options);
|
|
100
100
|
}
|
|
101
101
|
if (prop.kind === ReferenceKind.SCALAR && SCALAR_TYPES.has(prop.runtimeType) && (prop.setter || !prop.getter)) {
|
|
102
|
+
// mirror the hydrator (used by `em.create`) and coerce string/number inputs to `Date` instances,
|
|
103
|
+
// since `EntityData` already permits `string | Date` for `Date`-typed properties at the type level
|
|
104
|
+
if (prop.runtimeType === 'Date' &&
|
|
105
|
+
value != null &&
|
|
106
|
+
!(value instanceof Date) &&
|
|
107
|
+
(typeof value === 'string' || typeof value === 'number')) {
|
|
108
|
+
value = new Date(value);
|
|
109
|
+
}
|
|
102
110
|
validateProperty(prop, value, entity);
|
|
103
111
|
return (entity[prop.name] = value);
|
|
104
112
|
}
|
package/entity/EntityFactory.js
CHANGED
|
@@ -161,13 +161,15 @@ export class EntityFactory {
|
|
|
161
161
|
return diff2[key] === undefined;
|
|
162
162
|
})
|
|
163
163
|
.forEach(key => delete diff2[key]);
|
|
164
|
-
// but always add collection properties, formulas, generated columns,
|
|
165
|
-
// are part of the `data`, as these are excluded from
|
|
164
|
+
// but always add collection properties, formulas, generated columns, version properties, and the
|
|
165
|
+
// user-declared STI discriminator if they are part of the `data`, as these are excluded from
|
|
166
|
+
// `comparableProps` and won't appear in the diff
|
|
166
167
|
Utils.keys(data)
|
|
167
168
|
.filter(key => meta.properties[key]?.formula ||
|
|
168
169
|
meta.properties[key]?.version ||
|
|
169
170
|
(meta.properties[key]?.generated && !meta.properties[key]?.primary) ||
|
|
170
|
-
[ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(meta.properties[key]?.kind)
|
|
171
|
+
[ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(meta.properties[key]?.kind) ||
|
|
172
|
+
(key === meta.root.discriminatorColumn && meta.properties[key]?.userDefined !== false))
|
|
171
173
|
.forEach(key => (diff2[key] = data[key]));
|
|
172
174
|
// rehydrated with the new values, skip those changed by user
|
|
173
175
|
// use full hydration if the entity is already initialized, even if the caller used `initialized: false`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.1.0-dev.
|
|
3
|
+
"version": "7.1.0-dev.42",
|
|
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",
|
|
@@ -225,7 +225,7 @@ export class EntitySerializer {
|
|
|
225
225
|
return this.serialize(child, childOptions);
|
|
226
226
|
}
|
|
227
227
|
const pk = this.processCustomType(wrapped.getPrimaryKey(), prop, wrapped.__platform, options.convertCustomTypes);
|
|
228
|
-
if (options.forceObject
|
|
228
|
+
if (options.forceObject ?? wrapped.__config.get('serialization').forceObject) {
|
|
229
229
|
return Utils.primaryKeyToObject(meta, pk, visible);
|
|
230
230
|
}
|
|
231
231
|
if (Utils.isPlainObject(pk)) {
|
|
@@ -249,7 +249,7 @@ export class EntitySerializer {
|
|
|
249
249
|
return this.serialize(item, this.extractChildOptions(options, prop.name));
|
|
250
250
|
}
|
|
251
251
|
const pk = this.processCustomType(wrapped.getPrimaryKey(), prop, wrapped.__platform, options.convertCustomTypes);
|
|
252
|
-
if (options.forceObject
|
|
252
|
+
if (options.forceObject ?? wrapped.__config.get('serialization').forceObject) {
|
|
253
253
|
return Utils.primaryKeyToObject(wrapped.__meta, pk);
|
|
254
254
|
}
|
|
255
255
|
return pk;
|
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.0-dev.
|
|
144
|
+
static #ORM_VERSION = '7.1.0-dev.42';
|
|
145
145
|
/**
|
|
146
146
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
147
147
|
*/
|