mythix-orm-postgresql 1.8.0 → 1.9.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.
@@ -76,11 +76,11 @@ class PostgreSQLConnection extends SQLConnectionBase {
76
76
  },
77
77
  options,
78
78
  {
79
- statement_timeout: options.statementTimeout || DEFAULT_TIMEOUT_MS,
80
- query_timeout: options.queryTimeout || DEFAULT_TIMEOUT_MS,
81
- connectionTimeoutMillis: options.connectionTimeout || 60000,
82
- idle_in_transaction_session_timeout: options.idleTransactionTimeout,
83
- max: options.maxPoolConnections,
79
+ statement_timeout: options.statementTimeout || DEFAULT_TIMEOUT_MS,
80
+ query_timeout: options.queryTimeout || DEFAULT_TIMEOUT_MS,
81
+ connectionTimeoutMillis: options.connectionTimeout || 60000,
82
+ idle_in_transaction_session_timeout: options.idleTransactionTimeout,
83
+ max: options.maxPoolConnections,
84
84
  },
85
85
  );
86
86
 
@@ -180,7 +180,7 @@ class PostgreSQLConnection extends SQLConnectionBase {
180
180
  }
181
181
 
182
182
  if (logger && sql.text)
183
- console.log('QUERY: ', sql.text);
183
+ logger.log('QUERY: ', sql.text);
184
184
 
185
185
  let result;
186
186
 
@@ -192,6 +192,13 @@ class PostgreSQLConnection extends SQLConnectionBase {
192
192
  if (client && hasOwnClient)
193
193
  await client.release();
194
194
 
195
+ if (logger && options.logResponse) {
196
+ logger.log('QUERY RESULT: ', {
197
+ columns: (result.fields) ? result.fields.map((field) => field.name) : [],
198
+ result: (result.rows) ? result.rows : result,
199
+ });
200
+ }
201
+
195
202
  return this.formatResultsResponse(sql, result);
196
203
  } catch (error) {
197
204
  if (client && hasOwnClient)
@@ -208,6 +215,16 @@ class PostgreSQLConnection extends SQLConnectionBase {
208
215
  }
209
216
  }
210
217
 
218
+ formatResultsResponse(sqlStatement, result) {
219
+ if (!result.rows || !result.fields)
220
+ return result;
221
+
222
+ return {
223
+ rows: result.rows,
224
+ columns: result.fields.map((field) => field.name),
225
+ };
226
+ }
227
+
211
228
  async transaction(callback, _options, _retryCount) {
212
229
  let options = _options || {};
213
230
  let inheritedThis = Object.create(options.connection || this.getContextValue('connection', this));
@@ -295,16 +312,6 @@ class PostgreSQLConnection extends SQLConnectionBase {
295
312
  }
296
313
  }
297
314
 
298
- formatResultsResponse(sqlStatement, result) {
299
- if (!result.rows || !result.fields)
300
- return result;
301
-
302
- return {
303
- rows: result.rows,
304
- columns: result.fields.map((field) => field.name),
305
- };
306
- }
307
-
308
315
  async truncate(Model, options) {
309
316
  let queryGenerator = this.getQueryGenerator();
310
317
  let sqlStatement = queryGenerator.generateTruncateTableStatement(Model, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mythix-orm-postgresql",
3
- "version": "1.8.0",
3
+ "version": "1.9.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.10.2",
37
- "mythix-orm-sql-base": "^1.8.0"
36
+ "mythix-orm": "^1.11.0",
37
+ "mythix-orm-sql-base": "^1.9.0"
38
38
  },
39
39
  "dependencies": {
40
40
  "luxon": "^3.1.0",