@mikro-orm/core 6.6.18-dev.3 → 6.6.18-dev.5
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 +5 -0
- package/EntityManager.js +7 -0
- package/package.json +2 -2
- package/unit-of-work/UnitOfWork.js +5 -1
- package/utils/DataloaderUtils.js +2 -1
package/EntityManager.d.ts
CHANGED
|
@@ -479,6 +479,11 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
479
479
|
* Checks whether this EntityManager is currently operating inside a database transaction.
|
|
480
480
|
*/
|
|
481
481
|
isInTransaction(): boolean;
|
|
482
|
+
/**
|
|
483
|
+
* Checks whether transactions are disabled for this EntityManager.
|
|
484
|
+
* @internal
|
|
485
|
+
*/
|
|
486
|
+
isTransactionDisabled(): boolean;
|
|
482
487
|
/**
|
|
483
488
|
* Gets the transaction context (driver dependent object used to make sure queries are executed on same connection).
|
|
484
489
|
*/
|
package/EntityManager.js
CHANGED
|
@@ -1505,6 +1505,13 @@ class EntityManager {
|
|
|
1505
1505
|
isInTransaction() {
|
|
1506
1506
|
return !!this.getContext(false).transactionContext;
|
|
1507
1507
|
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Checks whether transactions are disabled for this EntityManager.
|
|
1510
|
+
* @internal
|
|
1511
|
+
*/
|
|
1512
|
+
isTransactionDisabled() {
|
|
1513
|
+
return !!this.getContext(false).disableTransactions;
|
|
1514
|
+
}
|
|
1508
1515
|
/**
|
|
1509
1516
|
* Gets the transaction context (driver dependent object used to make sure queries are executed on same connection).
|
|
1510
1517
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.6.18-dev.
|
|
3
|
+
"version": "6.6.18-dev.5",
|
|
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.3",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.6.18-dev.
|
|
67
|
+
"mikro-orm": "6.6.18-dev.5",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -340,7 +340,7 @@ class UnitOfWork {
|
|
|
340
340
|
}
|
|
341
341
|
const groups = this.getChangeSetGroups();
|
|
342
342
|
const platform = this.em.getPlatform();
|
|
343
|
-
const runInTransaction = !this.em.isInTransaction() && platform.supportsTransactions() && this.em.config.get('implicitTransactions');
|
|
343
|
+
const runInTransaction = !this.em.isInTransaction() && !this.em.isTransactionDisabled() && platform.supportsTransactions() && this.em.config.get('implicitTransactions');
|
|
344
344
|
if (runInTransaction) {
|
|
345
345
|
const loggerContext = Utils_1.Utils.merge({ id: this.em._id }, this.em.getLoggerContext({ disableContextResolution: true }));
|
|
346
346
|
await this.em.getConnection('write').transactional(trx => this.persistToDatabase(groups, trx), {
|
|
@@ -397,6 +397,10 @@ class UnitOfWork {
|
|
|
397
397
|
if (prop.formula) {
|
|
398
398
|
delete referrer[prop.name];
|
|
399
399
|
}
|
|
400
|
+
else if (prop.primary) {
|
|
401
|
+
// the referrer's primary key contains the removed entity, so its identity cannot survive the removal
|
|
402
|
+
this.unsetIdentity(referrer);
|
|
403
|
+
}
|
|
400
404
|
else {
|
|
401
405
|
delete (0, entity_1.helper)(referrer).__data[prop.name];
|
|
402
406
|
}
|
package/utils/DataloaderUtils.js
CHANGED
|
@@ -196,7 +196,8 @@ class DataloaderUtils {
|
|
|
196
196
|
const prop = group[0][0].property;
|
|
197
197
|
const options = {};
|
|
198
198
|
const wrap = (cond) => ({ [prop.name]: cond });
|
|
199
|
-
|
|
199
|
+
// `findChildrenFromPivotTable` expects the `orderBy` relative to the target entity, so no wrapping here
|
|
200
|
+
const orderBy = Utils_1.Utils.asArray(group[0][1]?.orderBy);
|
|
200
201
|
const populate = wrap(group[0][1]?.populate);
|
|
201
202
|
const owners = group.map(c => c[0].owner);
|
|
202
203
|
const $or = [];
|