@mikro-orm/core 6.5.7-dev.17 → 6.5.7-dev.18

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": "6.5.7-dev.17",
3
+ "version": "6.5.7-dev.18",
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.17",
67
+ "mikro-orm": "6.5.7-dev.18",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
@@ -6,6 +6,7 @@ const events_1 = require("../events");
6
6
  const TransactionContext_1 = require("../utils/TransactionContext");
7
7
  const unit_of_work_1 = require("../unit-of-work");
8
8
  const errors_1 = require("../errors");
9
+ const wrap_1 = require("../entity/wrap");
9
10
  /**
10
11
  * Manages transaction lifecycle and propagation for EntityManager.
11
12
  */
@@ -152,6 +153,14 @@ class TransactionManager {
152
153
  * Merges entities from fork to parent EntityManager.
153
154
  */
154
155
  mergeEntitiesToParent(fork, parent) {
156
+ // perf: if parent is empty, we can just move all entities from the fork to skill the `em.merge` overhead
157
+ if (parent.getUnitOfWork(false).getIdentityMap().keys().length === 0) {
158
+ for (const entity of fork.getUnitOfWork(false).getIdentityMap()) {
159
+ parent.getUnitOfWork(false).getIdentityMap().store(entity);
160
+ (0, wrap_1.helper)(entity).__em = parent;
161
+ }
162
+ return;
163
+ }
155
164
  for (const entity of fork.getUnitOfWork(false).getIdentityMap()) {
156
165
  parent.merge(entity, { disableContextResolution: true, keepIdentity: true, refresh: true, validate: false });
157
166
  }