mythix-orm-postgresql 1.1.0 → 1.2.2

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.
@@ -185,7 +185,7 @@ class PostgreSQLConnection extends SQLConnectionBase {
185
185
  inheritedThis.inTransaction = client;
186
186
 
187
187
  try {
188
- await inheritedThis.query(`BEGIN${(options.mode) ? ` ${options.mode}` : ''}`);
188
+ await inheritedThis.query(`BEGIN${(options.mode) ? ` ${options.mode}` : ' DEFERRABLE'}`, options);
189
189
  } catch (error) {
190
190
  if (!options.connection)
191
191
  await client.release();
@@ -197,23 +197,23 @@ class PostgreSQLConnection extends SQLConnectionBase {
197
197
  inheritedThis.savePointName = savePointName;
198
198
  inheritedThis.isSavePoint = true;
199
199
 
200
- await inheritedThis.query(`SAVEPOINT ${savePointName}`);
200
+ await inheritedThis.query(`SAVEPOINT ${savePointName}`, options);
201
201
  }
202
202
 
203
203
  try {
204
204
  let result = await callback.call(inheritedThis, inheritedThis);
205
205
 
206
206
  if (savePointName)
207
- await inheritedThis.query(`RELEASE SAVEPOINT ${savePointName}`);
207
+ await inheritedThis.query(`RELEASE SAVEPOINT ${savePointName}`, options);
208
208
  else
209
- await inheritedThis.query('COMMIT');
209
+ await inheritedThis.query('COMMIT', options);
210
210
 
211
211
  return result;
212
212
  } catch (error) {
213
213
  if (savePointName)
214
- await inheritedThis.query(`ROLLBACK TO SAVEPOINT ${savePointName}`);
214
+ await inheritedThis.query(`ROLLBACK TO SAVEPOINT ${savePointName}`, options);
215
215
  else if (inheritedThis.inTransaction)
216
- await inheritedThis.query('ROLLBACK');
216
+ await inheritedThis.query('ROLLBACK', options);
217
217
 
218
218
  throw error;
219
219
  } finally {
@@ -34,11 +34,6 @@ class PostgreSQLQueryGenerator extends SQLQueryGeneratorBase {
34
34
  ')',
35
35
  ];
36
36
 
37
- if (options.deferred === true) {
38
- sqlParts.push(' ');
39
- sqlParts.push('DEFERRABLE INITIALLY DEFERRED');
40
- }
41
-
42
37
  if (options.onDelete) {
43
38
  sqlParts.push(' ');
44
39
  sqlParts.push(`ON DELETE ${options.onDelete.toUpperCase()}`);
@@ -49,6 +44,15 @@ class PostgreSQLQueryGenerator extends SQLQueryGeneratorBase {
49
44
  sqlParts.push(`ON UPDATE ${options.onUpdate.toUpperCase()}`);
50
45
  }
51
46
 
47
+ if (options.deferred !== false) {
48
+ sqlParts.push(' ');
49
+
50
+ if (Nife.instanceOf(options.deferred, 'string'))
51
+ sqlParts.push(options.deferred);
52
+ else
53
+ sqlParts.push('DEFERRABLE INITIALLY DEFERRED');
54
+ }
55
+
52
56
  return sqlParts.join('');
53
57
  }
54
58
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mythix-orm-postgresql",
3
- "version": "1.1.0",
3
+ "version": "1.2.2",
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.2.0",
37
- "mythix-orm-sql-base": "^1.1.0"
36
+ "mythix-orm": "^1.3.0",
37
+ "mythix-orm-sql-base": "^1.1.1"
38
38
  },
39
39
  "dependencies": {
40
40
  "nife": "^1.11.3",