@mikro-orm/core 7.2.2-dev.14 → 7.2.2-dev.16
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 +6 -1
- package/EntityManager.js +11 -3
- package/package.json +1 -1
- package/unit-of-work/UnitOfWork.js +4 -1
- package/utils/Utils.js +1 -1
package/EntityManager.d.ts
CHANGED
|
@@ -580,6 +580,11 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
580
580
|
* Checks whether this EntityManager is currently operating inside a database transaction.
|
|
581
581
|
*/
|
|
582
582
|
isInTransaction(): boolean;
|
|
583
|
+
/**
|
|
584
|
+
* Checks whether transactions are disabled for this EntityManager.
|
|
585
|
+
* @internal
|
|
586
|
+
*/
|
|
587
|
+
isTransactionDisabled(): boolean;
|
|
583
588
|
/**
|
|
584
589
|
* Gets the transaction context (driver dependent object used to make sure queries are executed on same connection).
|
|
585
590
|
*/
|
|
@@ -633,7 +638,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
633
638
|
/**
|
|
634
639
|
* @internal
|
|
635
640
|
*/
|
|
636
|
-
tryCache<T extends object, R>(entityName: EntityName<T>, config: boolean | number | [string, number] | undefined, key: unknown, refresh?: boolean, merge?: boolean): Promise<{
|
|
641
|
+
tryCache<T extends object, R>(entityName: EntityName<T>, config: boolean | number | [string, number] | undefined, key: unknown, refresh?: boolean, merge?: boolean, schema?: string): Promise<{
|
|
637
642
|
data?: R | null;
|
|
638
643
|
key: string;
|
|
639
644
|
} | undefined>;
|
package/EntityManager.js
CHANGED
|
@@ -133,7 +133,7 @@ export class EntityManager {
|
|
|
133
133
|
options.populate = (await em.preparePopulate(entityName, options));
|
|
134
134
|
const populate = options.populate;
|
|
135
135
|
const cacheKey = em.cacheKey(entityName, options, 'em.find', where);
|
|
136
|
-
const cached = await em.tryCache(entityName, options.cache, cacheKey, options.refresh, true);
|
|
136
|
+
const cached = await em.tryCache(entityName, options.cache, cacheKey, options.refresh, true, options.schema);
|
|
137
137
|
if (cached?.data) {
|
|
138
138
|
await em.#entityLoader.populate(entityName, cached.data, populate, {
|
|
139
139
|
...options,
|
|
@@ -834,7 +834,7 @@ export class EntityManager {
|
|
|
834
834
|
validateParams(where);
|
|
835
835
|
options.populate = (await em.preparePopulate(entityName, options));
|
|
836
836
|
const cacheKey = em.cacheKey(entityName, options, 'em.findOne', where);
|
|
837
|
-
const cached = await em.tryCache(entityName, options.cache, cacheKey, options.refresh, true);
|
|
837
|
+
const cached = await em.tryCache(entityName, options.cache, cacheKey, options.refresh, true, options.schema);
|
|
838
838
|
if (cached?.data !== undefined) {
|
|
839
839
|
if (cached.data) {
|
|
840
840
|
await em.#entityLoader.populate(entityName, [cached.data], options.populate, {
|
|
@@ -1985,6 +1985,13 @@ export class EntityManager {
|
|
|
1985
1985
|
isInTransaction() {
|
|
1986
1986
|
return !!this.getContext(false).#transactionContext;
|
|
1987
1987
|
}
|
|
1988
|
+
/**
|
|
1989
|
+
* Checks whether transactions are disabled for this EntityManager.
|
|
1990
|
+
* @internal
|
|
1991
|
+
*/
|
|
1992
|
+
isTransactionDisabled() {
|
|
1993
|
+
return !!this.getContext(false).#disableTransactions;
|
|
1994
|
+
}
|
|
1988
1995
|
/**
|
|
1989
1996
|
* Gets the transaction context (driver dependent object used to make sure queries are executed on same connection).
|
|
1990
1997
|
*/
|
|
@@ -2340,7 +2347,7 @@ export class EntityManager {
|
|
|
2340
2347
|
/**
|
|
2341
2348
|
* @internal
|
|
2342
2349
|
*/
|
|
2343
|
-
async tryCache(entityName, config, key, refresh, merge) {
|
|
2350
|
+
async tryCache(entityName, config, key, refresh, merge, schema) {
|
|
2344
2351
|
config ??= this.config.get('resultCache').global;
|
|
2345
2352
|
if (!config) {
|
|
2346
2353
|
return undefined;
|
|
@@ -2362,6 +2369,7 @@ export class EntityManager {
|
|
|
2362
2369
|
merge: true,
|
|
2363
2370
|
convertCustomTypes: false,
|
|
2364
2371
|
refresh,
|
|
2372
|
+
schema,
|
|
2365
2373
|
recomputeSnapshot: true,
|
|
2366
2374
|
};
|
|
2367
2375
|
if (Array.isArray(cached) && merge) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.2.2-dev.
|
|
3
|
+
"version": "7.2.2-dev.16",
|
|
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",
|
|
@@ -467,7 +467,10 @@ export class UnitOfWork {
|
|
|
467
467
|
}
|
|
468
468
|
const groups = this.getChangeSetGroups();
|
|
469
469
|
const platform = this.#em.getPlatform();
|
|
470
|
-
const runInTransaction = !this.#em.isInTransaction() &&
|
|
470
|
+
const runInTransaction = !this.#em.isInTransaction() &&
|
|
471
|
+
!this.#em.isTransactionDisabled() &&
|
|
472
|
+
platform.supportsTransactions() &&
|
|
473
|
+
this.#em.config.get('implicitTransactions');
|
|
471
474
|
if (runInTransaction) {
|
|
472
475
|
const loggerContext = Utils.merge({ id: this.#em._id }, this.#em.getLoggerContext({ disableContextResolution: true }));
|
|
473
476
|
await this.#em.getConnection('write').transactional(trx => this.persistToDatabase(groups, trx), {
|
package/utils/Utils.js
CHANGED
|
@@ -153,7 +153,7 @@ export function parseJsonSafe(value) {
|
|
|
153
153
|
/** Collection of general-purpose utility methods used throughout the ORM. */
|
|
154
154
|
export class Utils {
|
|
155
155
|
static PK_SEPARATOR = '~~~';
|
|
156
|
-
static #ORM_VERSION = '7.2.2-dev.
|
|
156
|
+
static #ORM_VERSION = '7.2.2-dev.16';
|
|
157
157
|
/** Default session variable name backing an RLS filter argument (`current_setting('mikro.<filter>.<arg>')`). */
|
|
158
158
|
static getRlsSettingName(filterName, argName) {
|
|
159
159
|
return `mikro.${filterName}.${argName}`;
|