mythix-orm-postgresql 1.8.0 → 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.
- package/lib/postgresql-connection.js +18 -11
- package/package.json +1 -1
|
@@ -180,7 +180,7 @@ class PostgreSQLConnection extends SQLConnectionBase {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
if (logger && sql.text)
|
|
183
|
-
|
|
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);
|