@mikro-orm/core 7.0.0-dev.322 → 7.0.0-dev.324
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/naming-strategy/EntityCaseNamingStrategy.js +1 -1
- package/package.json +1 -1
- package/serialization/EntitySerializer.js +1 -1
- package/serialization/EntityTransformer.js +4 -1
- package/serialization/SerializationContext.d.ts +2 -2
- package/serialization/SerializationContext.js +8 -3
- package/utils/Utils.js +1 -1
|
@@ -11,7 +11,7 @@ export class EntityCaseNamingStrategy extends AbstractNamingStrategy {
|
|
|
11
11
|
}
|
|
12
12
|
joinKeyColumnName(entityName, referencedColumnName, composite, tableName) {
|
|
13
13
|
entityName = this.classToTableName(entityName, tableName);
|
|
14
|
-
const name = entityName.
|
|
14
|
+
const name = entityName.substring(0, 1).toLowerCase() + entityName.substring(1);
|
|
15
15
|
if (composite && referencedColumnName) {
|
|
16
16
|
return name + '_' + referencedColumnName;
|
|
17
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.0.0-dev.
|
|
3
|
+
"version": "7.0.0-dev.324",
|
|
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",
|
|
@@ -36,7 +36,7 @@ export class EntitySerializer {
|
|
|
36
36
|
const meta = wrapped.__meta;
|
|
37
37
|
let contextCreated = false;
|
|
38
38
|
if (!wrapped.__serializationContext.root) {
|
|
39
|
-
const root = new SerializationContext(
|
|
39
|
+
const root = new SerializationContext();
|
|
40
40
|
SerializationContext.propagate(root, entity, (meta, prop) => meta.properties[prop]?.kind !== ReferenceKind.SCALAR);
|
|
41
41
|
options.populate = (options.populate ? Utils.asArray(options.populate) : options.populate);
|
|
42
42
|
contextCreated = true;
|
|
@@ -20,7 +20,7 @@ export class EntityTransformer {
|
|
|
20
20
|
return entity;
|
|
21
21
|
}
|
|
22
22
|
if (!wrapped.__serializationContext.root) {
|
|
23
|
-
const root = new SerializationContext(wrapped.
|
|
23
|
+
const root = new SerializationContext(wrapped.__serializationContext.populate, wrapped.__serializationContext.fields, wrapped.__serializationContext.exclude);
|
|
24
24
|
SerializationContext.propagate(root, entity, isVisible);
|
|
25
25
|
contextCreated = true;
|
|
26
26
|
}
|
|
@@ -64,6 +64,9 @@ export class EntityTransformer {
|
|
|
64
64
|
if (!partiallyLoaded && !populated && !isPrimary) {
|
|
65
65
|
continue;
|
|
66
66
|
}
|
|
67
|
+
if (root.isExcluded(meta.class, prop) && !populated) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
67
70
|
}
|
|
68
71
|
const cycle = root.visit(meta.class, prop);
|
|
69
72
|
if (cycle && visited) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { AnyEntity, EntityMetadata, EntityName, PopulateOptions } from '../typings.js';
|
|
2
|
-
import type { Configuration } from '../utils/Configuration.js';
|
|
3
2
|
/**
|
|
4
3
|
* Helper that allows to keep track of where we are currently at when serializing complex entity graph with cycles.
|
|
5
4
|
* Before we process a property, we call `visit` that checks if it is not a cycle path (but allows to pass cycles that
|
|
@@ -9,7 +8,7 @@ export declare class SerializationContext<T extends object> {
|
|
|
9
8
|
#private;
|
|
10
9
|
readonly path: [EntityName, string][];
|
|
11
10
|
readonly visited: Set<Partial<any>>;
|
|
12
|
-
constructor(
|
|
11
|
+
constructor(populate?: PopulateOptions<T>[], fields?: Set<string>, exclude?: readonly string[]);
|
|
13
12
|
/**
|
|
14
13
|
* Returns true when there is a cycle detected.
|
|
15
14
|
*/
|
|
@@ -21,6 +20,7 @@ export declare class SerializationContext<T extends object> {
|
|
|
21
20
|
*/
|
|
22
21
|
static propagate(root: SerializationContext<any>, entity: AnyEntity, isVisible: (meta: EntityMetadata, prop: string) => boolean): void;
|
|
23
22
|
isMarkedAsPopulated(entityName: EntityName, prop: string): boolean;
|
|
23
|
+
isExcluded(entityName: EntityName, prop: string): boolean;
|
|
24
24
|
isPartiallyLoaded(entityName: EntityName, prop: string): boolean;
|
|
25
25
|
private register;
|
|
26
26
|
}
|
|
@@ -9,12 +9,10 @@ export class SerializationContext {
|
|
|
9
9
|
path = [];
|
|
10
10
|
visited = new Set();
|
|
11
11
|
#entities = new Set();
|
|
12
|
-
#config;
|
|
13
12
|
#populate;
|
|
14
13
|
#fields;
|
|
15
14
|
#exclude;
|
|
16
|
-
constructor(
|
|
17
|
-
this.#config = config;
|
|
15
|
+
constructor(populate = [], fields, exclude) {
|
|
18
16
|
this.#populate = populate;
|
|
19
17
|
this.#fields = fields;
|
|
20
18
|
this.#exclude = exclude;
|
|
@@ -92,6 +90,13 @@ export class SerializationContext {
|
|
|
92
90
|
}
|
|
93
91
|
return !!populate?.some(p => p.field === prop);
|
|
94
92
|
}
|
|
93
|
+
isExcluded(entityName, prop) {
|
|
94
|
+
if (!this.#exclude || this.#exclude.length === 0) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
const fullPath = this.path.map(segment => segment[1] + '.').join('') + prop;
|
|
98
|
+
return this.#exclude.includes(fullPath);
|
|
99
|
+
}
|
|
95
100
|
isPartiallyLoaded(entityName, prop) {
|
|
96
101
|
if (!this.#fields) {
|
|
97
102
|
return true;
|
package/utils/Utils.js
CHANGED
|
@@ -123,7 +123,7 @@ export function parseJsonSafe(value) {
|
|
|
123
123
|
}
|
|
124
124
|
export class Utils {
|
|
125
125
|
static PK_SEPARATOR = '~~~';
|
|
126
|
-
static #ORM_VERSION = '7.0.0-dev.
|
|
126
|
+
static #ORM_VERSION = '7.0.0-dev.324';
|
|
127
127
|
/**
|
|
128
128
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
129
129
|
*/
|