mythix-orm-postgresql 1.6.2 → 1.7.0

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.
@@ -173,18 +173,18 @@ class PostgreSQLConnection extends SQLConnectionBase {
173
173
 
174
174
  async transaction(callback, _options) {
175
175
  let options = _options || {};
176
- let inheritedThis = Object.create(options.connection || this);
177
- let lockMode = this.getLockMode(options.lock);
176
+ let inheritedThis = Object.create(options.connection || this.getContextValue('connection', this));
177
+ let lockMode = inheritedThis.getLockMode(options.lock);
178
178
  let savePointName;
179
179
  let client;
180
180
  let lockStatement;
181
181
 
182
182
  if (lockMode && lockMode.lock) {
183
- let Model = this.getModel(lockMode.modelName);
183
+ let Model = inheritedThis.getModel(lockMode.modelName);
184
184
  if (!Model)
185
- throw new Error(`${this.constructor.name}::transaction: Request to lock table defined by model "${lockMode.modelName}", but model with that name can not be found.`);
185
+ throw new Error(`${inheritedThis.constructor.name}::transaction: Request to lock table defined by model "${lockMode.modelName}", but model with that name can not be found.`);
186
186
 
187
- let escapedTableName = this.escapeID(Model.getTableName());
187
+ let escapedTableName = inheritedThis.escapeID(Model.getTableName());
188
188
  let lockModeStr = (lockMode.mode) ? lockMode.mode : 'ACCESS EXCLUSIVE';
189
189
 
190
190
  if (!lockMode.mode) {
@@ -200,7 +200,7 @@ class PostgreSQLConnection extends SQLConnectionBase {
200
200
  if (!inheritedThis.inTransaction) {
201
201
  client = options.connection;
202
202
  if (!client)
203
- client = await this.pool.connect();
203
+ client = await inheritedThis.pool.connect();
204
204
 
205
205
  inheritedThis.inTransaction = client;
206
206
 
@@ -217,7 +217,7 @@ class PostgreSQLConnection extends SQLConnectionBase {
217
217
  throw error;
218
218
  }
219
219
  } else {
220
- savePointName = this.generateSavePointName();
220
+ savePointName = inheritedThis.generateSavePointName();
221
221
  inheritedThis.savePointName = savePointName;
222
222
  inheritedThis.isSavePoint = true;
223
223
 
@@ -225,7 +225,7 @@ class PostgreSQLConnection extends SQLConnectionBase {
225
225
  }
226
226
 
227
227
  try {
228
- let result = await callback.call(inheritedThis, inheritedThis);
228
+ let result = await inheritedThis.createContext(callback, inheritedThis, inheritedThis);
229
229
 
230
230
  if (savePointName)
231
231
  await inheritedThis.query(`RELEASE SAVEPOINT ${savePointName}`, options);
@@ -294,6 +294,7 @@ class PostgreSQLConnection extends SQLConnectionBase {
294
294
  return 'INTEGER';
295
295
  }
296
296
 
297
+ // eslint-disable-next-line no-unused-vars
297
298
  _blobTypeToString(type) {
298
299
  return 'BYTEA';
299
300
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mythix-orm-postgresql",
3
- "version": "1.6.2",
3
+ "version": "1.7.0",
4
4
  "description": "PostgreSQL driver for Mythix ORM",
5
5
  "main": "lib/index.js",
6
6
  "type": "commonjs",
@@ -33,8 +33,8 @@
33
33
  },
34
34
  "homepage": "https://github.com/th317erd/mythix-orm-postgresql#readme",
35
35
  "peerDependencies": {
36
- "mythix-orm": "^1.7.2",
37
- "mythix-orm-sql-base": "^1.6.2"
36
+ "mythix-orm": "^1.8.0",
37
+ "mythix-orm-sql-base": "^1.7.0"
38
38
  },
39
39
  "dependencies": {
40
40
  "luxon": "^3.0.4",