@mikro-orm/sql 7.1.9-dev.14 → 7.1.9-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.
@@ -110,7 +110,15 @@ export class AbstractSqlConnection extends Connection {
110
110
  return ret;
111
111
  }
112
112
  catch (error) {
113
- await this.rollback(trx, options.eventBroadcaster, options.loggerContext);
113
+ // A failing rollback must not mask why the transaction failed in the first place — the
114
+ // `'kill session'` abort strategy tears the connection down, so the rollback that follows can
115
+ // only ever report the dead connection.
116
+ try {
117
+ await this.rollback(trx, options.eventBroadcaster, options.loggerContext);
118
+ }
119
+ catch (rollbackError) {
120
+ this.logger.warn('query', `Failed to roll back transaction: ${rollbackError.message}`);
121
+ }
114
122
  throw error;
115
123
  }
116
124
  }
@@ -138,18 +146,8 @@ export class AbstractSqlConnection extends Connection {
138
146
  trxBuilder = trxBuilder.setAccessMode('read only');
139
147
  }
140
148
  const trx = await trxBuilder.execute();
141
- if (options.ctx) {
142
- const ctx = options.ctx;
143
- ctx.index ??= 0;
144
- const savepointName = `trx${ctx.index + 1}`;
145
- Reflect.defineProperty(trx, 'index', { value: ctx.index + 1 });
146
- Reflect.defineProperty(trx, 'savepointName', { value: savepointName });
147
- this.logQuery(this.platform.getSavepointSQL(savepointName), options.loggerContext);
148
- }
149
- else {
150
- for (const query of this.platform.getBeginTransactionSQL(options)) {
151
- this.logQuery(query, options.loggerContext);
152
- }
149
+ for (const query of this.platform.getBeginTransactionSQL(options)) {
150
+ this.logQuery(query, options.loggerContext);
153
151
  }
154
152
  await options.eventBroadcaster?.dispatchEvent(EventType.afterTransactionStart, trx);
155
153
  return trx;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.1.9-dev.14",
3
+ "version": "7.1.9-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",
@@ -53,7 +53,7 @@
53
53
  "@mikro-orm/core": "^7.1.8"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.1.9-dev.14"
56
+ "@mikro-orm/core": "7.1.9-dev.16"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"