@mikro-orm/core 6.5.7-dev.22 → 6.5.7-dev.23
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 +2 -2
- package/utils/TransactionManager.js +15 -9
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.23",
|
|
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.23",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -153,22 +153,28 @@ class TransactionManager {
|
|
|
153
153
|
* Merges entities from fork to parent EntityManager.
|
|
154
154
|
*/
|
|
155
155
|
mergeEntitiesToParent(fork, parent) {
|
|
156
|
+
const parentUoW = parent.getUnitOfWork(false);
|
|
156
157
|
// perf: if parent is empty, we can just move all entities from the fork to skip the `em.merge` overhead
|
|
157
|
-
if (
|
|
158
|
+
if (parentUoW.getIdentityMap().keys().length === 0) {
|
|
158
159
|
for (const entity of fork.getUnitOfWork(false).getIdentityMap()) {
|
|
159
|
-
|
|
160
|
+
parentUoW.getIdentityMap().store(entity);
|
|
160
161
|
(0, wrap_1.helper)(entity).__em = parent;
|
|
161
162
|
}
|
|
162
163
|
return;
|
|
163
164
|
}
|
|
164
165
|
for (const entity of fork.getUnitOfWork(false).getIdentityMap()) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
166
|
+
const wrapped = (0, wrap_1.helper)(entity);
|
|
167
|
+
const meta = wrapped.__meta;
|
|
168
|
+
// eslint-disable-next-line dot-notation
|
|
169
|
+
const parentEntity = parentUoW.getById(meta.className, wrapped.getPrimaryKey(), parent['_schema'], true);
|
|
170
|
+
if (parentEntity && parentEntity !== entity) {
|
|
171
|
+
const parentWrapped = (0, wrap_1.helper)(parentEntity);
|
|
172
|
+
parentWrapped.__data = (0, wrap_1.helper)(entity).__data;
|
|
173
|
+
parentWrapped.__originalEntityData = (0, wrap_1.helper)(entity).__originalEntityData;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
parentUoW.merge(entity, new Set([entity]));
|
|
177
|
+
}
|
|
172
178
|
}
|
|
173
179
|
}
|
|
174
180
|
/**
|