@mikro-orm/core 6.5.7-dev.20 → 6.5.7-dev.22
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/EntityManager.d.ts
CHANGED
|
@@ -580,6 +580,7 @@ export interface MergeOptions {
|
|
|
580
580
|
disableContextResolution?: boolean;
|
|
581
581
|
keepIdentity?: boolean;
|
|
582
582
|
validate?: boolean;
|
|
583
|
+
cascade?: boolean; /** @default true */
|
|
583
584
|
}
|
|
584
585
|
export interface ForkOptions {
|
|
585
586
|
/** do we want a clear identity map? defaults to true */
|
package/EntityManager.js
CHANGED
|
@@ -1187,6 +1187,7 @@ class EntityManager {
|
|
|
1187
1187
|
const em = options.disableContextResolution ? this : this.getContext();
|
|
1188
1188
|
options.schema ??= em._schema;
|
|
1189
1189
|
options.validate ??= true;
|
|
1190
|
+
options.cascade ??= true;
|
|
1190
1191
|
entityName = utils_1.Utils.className(entityName);
|
|
1191
1192
|
if (options.validate) {
|
|
1192
1193
|
em.validator.validatePrimaryKey(data, em.metadata.get(entityName));
|
|
@@ -1207,7 +1208,8 @@ class EntityManager {
|
|
|
1207
1208
|
if (options.validate) {
|
|
1208
1209
|
em.validator.validate(entity, data, childMeta ?? meta);
|
|
1209
1210
|
}
|
|
1210
|
-
|
|
1211
|
+
const visited = options.cascade ? undefined : new Set([entity]);
|
|
1212
|
+
em.unitOfWork.merge(entity, visited);
|
|
1211
1213
|
return entity;
|
|
1212
1214
|
}
|
|
1213
1215
|
/**
|
package/entity/defineEntity.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ export declare class PropertyOptionsBuilder<Value> {
|
|
|
73
73
|
/**
|
|
74
74
|
* Explicitly specify the auto increment of the primary key.
|
|
75
75
|
*/
|
|
76
|
-
autoincrement(autoincrement?:
|
|
76
|
+
autoincrement<T extends boolean = true>(autoincrement?: T): PropertyOptionsBuilder<T extends true ? Opt<Value> : Value>;
|
|
77
77
|
/**
|
|
78
78
|
* Add the property to the `returning` statement.
|
|
79
79
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.5.7-dev.
|
|
3
|
+
"version": "6.5.7-dev.22",
|
|
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.2",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.5.7-dev.
|
|
67
|
+
"mikro-orm": "6.5.7-dev.22",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -153,7 +153,7 @@ class TransactionManager {
|
|
|
153
153
|
* Merges entities from fork to parent EntityManager.
|
|
154
154
|
*/
|
|
155
155
|
mergeEntitiesToParent(fork, parent) {
|
|
156
|
-
// perf: if parent is empty, we can just move all entities from the fork to
|
|
156
|
+
// perf: if parent is empty, we can just move all entities from the fork to skip the `em.merge` overhead
|
|
157
157
|
if (parent.getUnitOfWork(false).getIdentityMap().keys().length === 0) {
|
|
158
158
|
for (const entity of fork.getUnitOfWork(false).getIdentityMap()) {
|
|
159
159
|
parent.getUnitOfWork(false).getIdentityMap().store(entity);
|
|
@@ -162,7 +162,13 @@ class TransactionManager {
|
|
|
162
162
|
return;
|
|
163
163
|
}
|
|
164
164
|
for (const entity of fork.getUnitOfWork(false).getIdentityMap()) {
|
|
165
|
-
parent.merge(entity, {
|
|
165
|
+
parent.merge(entity, {
|
|
166
|
+
disableContextResolution: true,
|
|
167
|
+
keepIdentity: true,
|
|
168
|
+
refresh: true,
|
|
169
|
+
validate: false,
|
|
170
|
+
cascade: false,
|
|
171
|
+
});
|
|
166
172
|
}
|
|
167
173
|
}
|
|
168
174
|
/**
|