@mikro-orm/core 7.2.1-dev.8 → 7.2.1-dev.9

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.
@@ -11,7 +11,7 @@ import type { AnyString, ArrayElement, AutoPath, ConnectionType, Dictionary, Ent
11
11
  import type { Routine } from './metadata/Routine.js';
12
12
  import { FlushMode, LockMode, PopulatePath, type TransactionOptions } from './enums.js';
13
13
  import type { MetadataStorage } from './metadata/MetadataStorage.js';
14
- import type { AbortQueryOptions, InflightQueryAbortStrategy, Transaction } from './connections/Connection.js';
14
+ import type { AbortQueryOptions, Connection, InflightQueryAbortStrategy, Transaction } from './connections/Connection.js';
15
15
  import { EventManager } from './events/EventManager.js';
16
16
  import type { EntityComparator } from './utils/EntityComparator.js';
17
17
  /**
@@ -130,7 +130,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
130
130
  *
131
131
  * @internal
132
132
  */
133
- withSessionContext<T>(ctx: Transaction | undefined, cb: (ctx?: Transaction) => Promise<T>): Promise<T>;
133
+ withSessionContext<T>(ctx: Transaction | undefined, cb: (ctx?: Transaction) => Promise<T>, connection?: Connection): Promise<T>;
134
134
  /**
135
135
  * Sets logger context for this entity manager.
136
136
  */
package/EntityManager.js CHANGED
@@ -399,13 +399,16 @@ export class EntityManager {
399
399
  *
400
400
  * @internal
401
401
  */
402
- async withSessionContext(ctx, cb) {
402
+ async withSessionContext(ctx, cb, connection) {
403
403
  const em = this.getContext(false);
404
404
  const sessionContext = ctx ? undefined : em.getTransactionSessionContext();
405
405
  if (!sessionContext) {
406
406
  return cb(ctx);
407
407
  }
408
- return em.getConnection('write').transactional(trx => cb(trx), { sessionContext, loggerContext: em.loggerContext });
408
+ return (connection ?? em.getConnection('write')).transactional(trx => cb(trx), {
409
+ sessionContext,
410
+ loggerContext: em.loggerContext,
411
+ });
409
412
  }
410
413
  /**
411
414
  * Sets logger context for this entity manager.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.2.1-dev.8",
3
+ "version": "7.2.1-dev.9",
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",
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.1-dev.8';
156
+ static #ORM_VERSION = '7.2.1-dev.9';
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}`;