mythix-orm-postgresql 1.7.6 → 1.8.1

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.
@@ -22,6 +22,8 @@ function sleep(ms) {
22
22
  class PostgreSQLConnection extends SQLConnectionBase {
23
23
  static dialect = 'postgresql';
24
24
 
25
+ static DefaultQueryGenerator = PostgreSQLQueryGenerator;
26
+
25
27
  constructor(_options) {
26
28
  super(_options);
27
29
 
@@ -178,7 +180,7 @@ class PostgreSQLConnection extends SQLConnectionBase {
178
180
  }
179
181
 
180
182
  if (logger && sql.text)
181
- console.log('QUERY: ', sql.text);
183
+ logger.log('QUERY: ', sql.text);
182
184
 
183
185
  let result;
184
186
 
@@ -190,6 +192,13 @@ class PostgreSQLConnection extends SQLConnectionBase {
190
192
  if (client && hasOwnClient)
191
193
  await client.release();
192
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
+
193
202
  return this.formatResultsResponse(sql, result);
194
203
  } catch (error) {
195
204
  if (client && hasOwnClient)
@@ -206,6 +215,16 @@ class PostgreSQLConnection extends SQLConnectionBase {
206
215
  }
207
216
  }
208
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
+
209
228
  async transaction(callback, _options, _retryCount) {
210
229
  let options = _options || {};
211
230
  let inheritedThis = Object.create(options.connection || this.getContextValue('connection', this));
@@ -293,16 +312,6 @@ class PostgreSQLConnection extends SQLConnectionBase {
293
312
  }
294
313
  }
295
314
 
296
- formatResultsResponse(sqlStatement, result) {
297
- if (!result.rows || !result.fields)
298
- return result;
299
-
300
- return {
301
- rows: result.rows,
302
- columns: result.fields.map((field) => field.name),
303
- };
304
- }
305
-
306
315
  async truncate(Model, options) {
307
316
  let queryGenerator = this.getQueryGenerator();
308
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.7.6",
3
+ "version": "1.8.1",
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.8.3",
37
- "mythix-orm-sql-base": "^1.7.4"
36
+ "mythix-orm": "^1.10.2",
37
+ "mythix-orm-sql-base": "^1.8.0"
38
38
  },
39
39
  "dependencies": {
40
40
  "luxon": "^3.1.0",