@mikro-orm/core 6.6.17-dev.0 → 6.6.17-dev.2
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.d.ts +1 -0
- package/entity/EntityFactory.js +6 -0
- package/package.json +2 -2
- package/typings.d.ts +2 -2
|
@@ -26,6 +26,7 @@ export declare class EntityFactory {
|
|
|
26
26
|
private readonly hydrator;
|
|
27
27
|
private readonly eventManager;
|
|
28
28
|
private readonly comparator;
|
|
29
|
+
private recomputeSnapshot;
|
|
29
30
|
constructor(em: EntityManager);
|
|
30
31
|
create<T extends object, P extends string = string>(entityName: EntityName<T>, data: EntityData<T>, options?: FactoryOptions): New<T, P>;
|
|
31
32
|
mergeData<T extends object>(meta: EntityMetadata<T>, entity: T, data: EntityData<T>, options?: FactoryOptions): void;
|
package/entity/EntityFactory.js
CHANGED
|
@@ -17,6 +17,7 @@ class EntityFactory {
|
|
|
17
17
|
hydrator;
|
|
18
18
|
eventManager;
|
|
19
19
|
comparator;
|
|
20
|
+
recomputeSnapshot = false;
|
|
20
21
|
constructor(em) {
|
|
21
22
|
this.em = em;
|
|
22
23
|
this.driver = this.em.getDriver();
|
|
@@ -30,6 +31,8 @@ class EntityFactory {
|
|
|
30
31
|
create(entityName, data, options = {}) {
|
|
31
32
|
data = Reference_1.Reference.unwrapReference(data);
|
|
32
33
|
options.initialized ??= true;
|
|
34
|
+
// nested relations created by the hydrator need the same DB-form snapshot as the root (GH #8268)
|
|
35
|
+
options.recomputeSnapshot ??= this.recomputeSnapshot;
|
|
33
36
|
if (EntityHelper_1.EntityHelper.isEntity(data)) {
|
|
34
37
|
return data;
|
|
35
38
|
}
|
|
@@ -256,12 +259,15 @@ class EntityFactory {
|
|
|
256
259
|
}
|
|
257
260
|
}
|
|
258
261
|
hydrate(entity, meta, data, options) {
|
|
262
|
+
const recomputeSnapshot = this.recomputeSnapshot;
|
|
263
|
+
this.recomputeSnapshot = !!options.recomputeSnapshot;
|
|
259
264
|
if (options.initialized) {
|
|
260
265
|
this.hydrator.hydrate(entity, meta, data, this, 'full', options.newEntity, options.convertCustomTypes, options.schema, this.driver.getSchemaName(meta, options), options.normalizeAccessors);
|
|
261
266
|
}
|
|
262
267
|
else {
|
|
263
268
|
this.hydrator.hydrateReference(entity, meta, data, this, options.convertCustomTypes, options.schema, this.driver.getSchemaName(meta, options), options.normalizeAccessors);
|
|
264
269
|
}
|
|
270
|
+
this.recomputeSnapshot = recomputeSnapshot;
|
|
265
271
|
Utils_1.Utils.keys(data).forEach(key => {
|
|
266
272
|
(0, wrap_1.helper)(entity)?.__loadedProperties.add(key);
|
|
267
273
|
(0, wrap_1.helper)(entity)?.__serializationContext.fields?.add(key);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.6.17-dev.
|
|
3
|
+
"version": "6.6.17-dev.2",
|
|
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.17-dev.
|
|
67
|
+
"mikro-orm": "6.6.17-dev.2",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/typings.d.ts
CHANGED
|
@@ -232,11 +232,11 @@ type NonArrayObject = object & {
|
|
|
232
232
|
export type EntityDataProp<T, C extends boolean> = T extends Date ? string | Date : T extends Scalar ? T : T extends {
|
|
233
233
|
__runtime?: infer Runtime;
|
|
234
234
|
__raw?: infer Raw;
|
|
235
|
-
} ? (C extends true ? Raw : Runtime) : T extends Reference<infer U> ? EntityDataNested<U, C> : T extends ScalarReference<infer U> ? EntityDataProp<U, C> : T extends Collection<infer U, any> ? U | U[] | EntityDataNested<U, C> | EntityDataNested<U, C>[] : T extends readonly (infer U)[] ? U extends NonArrayObject ? U | U[] | EntityDataNested<U, C> | EntityDataNested<U, C>[] : U[] | EntityDataNested<U, C>[] : EntityDataNested<T, C>;
|
|
235
|
+
} ? (C extends true ? Raw : Runtime) : T extends Reference<infer U> ? EntityDataNested<U, C> : T extends ScalarReference<infer U> ? EntityDataProp<U, C> : T extends Collection<infer U, any> ? U | U[] | EntityDataNested<U, C> | EntityDataNested<U, C>[] : T extends readonly (infer U)[] ? [U] extends [NonArrayObject] ? U | U[] | EntityDataNested<U, C> | EntityDataNested<U, C>[] : U[] | EntityDataNested<U, C>[] : EntityDataNested<T, C>;
|
|
236
236
|
export type RequiredEntityDataProp<T, O, C extends boolean> = T extends Date ? string | Date : Exclude<T, null> extends RequiredNullable.Brand ? T | null : T extends Scalar ? T : T extends {
|
|
237
237
|
__runtime?: infer Runtime;
|
|
238
238
|
__raw?: infer Raw;
|
|
239
|
-
} ? (C extends true ? Raw : Runtime) : T extends Reference<infer U> ? RequiredEntityDataNested<U, O, C> : T extends ScalarReference<infer U> ? RequiredEntityDataProp<U, O, C> : T extends Collection<infer U, any> ? U | U[] | RequiredEntityDataNested<U, O, C> | RequiredEntityDataNested<U, O, C>[] : T extends readonly (infer U)[] ? U extends NonArrayObject ? U | U[] | RequiredEntityDataNested<U, O, C> | RequiredEntityDataNested<U, O, C>[] : U[] | RequiredEntityDataNested<U, O, C>[] : RequiredEntityDataNested<T, O, C>;
|
|
239
|
+
} ? (C extends true ? Raw : Runtime) : T extends Reference<infer U> ? RequiredEntityDataNested<U, O, C> : T extends ScalarReference<infer U> ? RequiredEntityDataProp<U, O, C> : T extends Collection<infer U, any> ? U | U[] | RequiredEntityDataNested<U, O, C> | RequiredEntityDataNested<U, O, C>[] : T extends readonly (infer U)[] ? [U] extends [NonArrayObject] ? U | U[] | RequiredEntityDataNested<U, O, C> | RequiredEntityDataNested<U, O, C>[] : U[] | RequiredEntityDataNested<U, O, C>[] : RequiredEntityDataNested<T, O, C>;
|
|
240
240
|
export type EntityDataNested<T, C extends boolean = false> = T extends undefined ? never : T extends any[] ? Readonly<T> : EntityData<T, C> | ExpandEntityProp<T, C>;
|
|
241
241
|
type EntityDataItem<T, C extends boolean> = C extends false ? T | EntityDataProp<T, C> | null : EntityDataProp<T, C> | null;
|
|
242
242
|
export type RequiredEntityDataNested<T, O, C extends boolean> = T extends any[] ? Readonly<T> : RequiredEntityData<T, O> | ExpandRequiredEntityProp<T, O, C>;
|