From 5e4d29da5598e420598e4e67c9b33d1fd757ded7 Mon Sep 17 00:00:00 2001 From: Javier De La Fuente Sales Date: Fri, 16 Feb 2024 12:11:54 +0100 Subject: [PATCH] chore: added logs to debug the query method --- package-lock.json | 2 +- package.json | 2 +- src/driver/spanner/SpannerQueryRunner.ts | 31 ++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 30c0663c55..c2986d9d0f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@streamyard/typeorm", - "version": "0.3.16-3", + "version": "0.3.16-4-beta", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 1f866d64b1..18e1832944 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@streamyard/typeorm", "private": true, - "version": "0.3.16-3", + "version": "0.3.16-4-beta", "description": "Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, MongoDB, Spanner databases.", "license": "MIT", "readmeFilename": "README.md", diff --git a/src/driver/spanner/SpannerQueryRunner.ts b/src/driver/spanner/SpannerQueryRunner.ts index 183782a887..9b5862cb2b 100644 --- a/src/driver/spanner/SpannerQueryRunner.ts +++ b/src/driver/spanner/SpannerQueryRunner.ts @@ -156,6 +156,11 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner { if (this.isReleased) throw new QueryRunnerAlreadyReleasedError() try { + this.driver.connection.logger.log( + "info", + "typeorm:query - start", + this, + ) const queryStartTime = +new Date() await this.connect() let rawResult: @@ -182,6 +187,11 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner { try { this.driver.connection.logger.logQuery(query, parameters, this) + this.driver.connection.logger.log( + "info", + "typeorm:query - before run", + this, + ) rawResult = await executor.run({ sql: query, params: parameters @@ -192,7 +202,18 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner { : undefined, json: true, }) + + this.driver.connection.logger.log( + "info", + "typeorm:query - after run", + this, + ) if (!this.isTransactionActive && !isSelect) { + this.driver.connection.logger.log( + "info", + "typeorm:query -commit", + this, + ) await this.sessionTransaction.commit() } } catch (error) { @@ -220,6 +241,11 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner { this, ) + this.driver.connection.logger.log( + "info", + "typeorm:query - preparing result", + this, + ) const result = new QueryResult() result.raw = rawResult @@ -232,6 +258,11 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner { return result.records } + this.driver.connection.logger.log( + "info", + "typeorm:query - end", + this, + ) return result } catch (err) { this.driver.connection.logger.logQueryError(