@mikro-orm/core 7.2.8-dev.10 → 7.2.8-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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.2.8-dev.
|
|
3
|
+
"version": "7.2.8-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
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
|
@@ -76,12 +76,12 @@ export class EntitySerializer {
|
|
|
76
76
|
const meta = wrapped.__meta;
|
|
77
77
|
let contextCreated = false;
|
|
78
78
|
options = prepareOptions(options);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
let root = wrapped.__serializationContext.root;
|
|
80
|
+
if (!root) {
|
|
81
|
+
root = new SerializationContext();
|
|
82
82
|
contextCreated = true;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
SerializationContext.propagate(root, entity, (meta, prop) => meta.properties[prop]?.kind !== ReferenceKind.SCALAR);
|
|
85
85
|
const ret = {};
|
|
86
86
|
const props = new Set();
|
|
87
87
|
if (meta.serializedPrimaryKey && !meta.compositePK) {
|
|
@@ -21,12 +21,12 @@ export class EntityTransformer {
|
|
|
21
21
|
if (!wrapped) {
|
|
22
22
|
return entity;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
SerializationContext.
|
|
24
|
+
let root = wrapped.__serializationContext.root;
|
|
25
|
+
if (!root) {
|
|
26
|
+
root = new SerializationContext(wrapped.__serializationContext.populate, wrapped.__serializationContext.fields, wrapped.__serializationContext.exclude);
|
|
27
27
|
contextCreated = true;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
SerializationContext.propagate(root, entity, isVisible);
|
|
30
30
|
const meta = wrapped.__meta;
|
|
31
31
|
const ret = {};
|
|
32
32
|
const props = new Set();
|
|
@@ -18,7 +18,8 @@ export declare class SerializationContext<T extends object> {
|
|
|
18
18
|
/** Cleans up the serialization context by removing root references from all tracked entities. */
|
|
19
19
|
close(): void;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Propagates the context to the entity and its direct relations, so nested serialization calls pick it up.
|
|
22
|
+
* Runs for every serialized entity, so the context spreads along the serialized path instead of the whole graph.
|
|
22
23
|
*/
|
|
23
24
|
static propagate(root: SerializationContext<any>, entity: AnyEntity, isVisible: (meta: EntityMetadata, prop: string) => boolean): void;
|
|
24
25
|
/** Checks whether a property is explicitly listed in the populate hints for the current path. */
|
|
@@ -47,7 +47,8 @@ export class SerializationContext {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* Propagates the context to the entity and its direct relations, so nested serialization calls pick it up.
|
|
51
|
+
* Runs for every serialized entity, so the context spreads along the serialized path instead of the whole graph.
|
|
51
52
|
*/
|
|
52
53
|
static propagate(root, entity, isVisible) {
|
|
53
54
|
root.register(entity);
|
|
@@ -59,14 +60,14 @@ export class SerializationContext {
|
|
|
59
60
|
const target = entity[key];
|
|
60
61
|
if (Utils.isEntity(target, true)) {
|
|
61
62
|
if (!target.__helper.__serializationContext.root) {
|
|
62
|
-
|
|
63
|
+
root.register(target);
|
|
63
64
|
}
|
|
64
65
|
continue;
|
|
65
66
|
}
|
|
66
67
|
if (Utils.isCollection(target)) {
|
|
67
68
|
for (const item of target.getItems(false)) {
|
|
68
69
|
if (!item.__helper.__serializationContext.root) {
|
|
69
|
-
|
|
70
|
+
root.register(item);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
}
|
package/utils/Utils.js
CHANGED
|
@@ -153,7 +153,7 @@ export function parseJsonSafe(value) {
|
|
|
153
153
|
/** Collection of general-purpose utility methods used throughout the ORM. */
|
|
154
154
|
export class Utils {
|
|
155
155
|
static PK_SEPARATOR = '~~~';
|
|
156
|
-
static #ORM_VERSION = '7.2.8-dev.
|
|
156
|
+
static #ORM_VERSION = '7.2.8-dev.12';
|
|
157
157
|
/** Default session variable name backing an RLS filter argument (`current_setting('mikro.<filter>.<arg>')`). */
|
|
158
158
|
static getRlsSettingName(filterName, argName) {
|
|
159
159
|
return `mikro.${filterName}.${argName}`;
|