1
- import { QueryResult } from "../../query-runner/QueryResult"
2
- import { QueryRunner } from "../../query-runner/QueryRunner"
3
1
import { ObjectLiteral } from "../../common/ObjectLiteral"
2
+ import { TypeORMError } from "../../error"
3
+ import { QueryFailedError } from "../../error/QueryFailedError"
4
+ import { QueryRunnerAlreadyReleasedError } from "../../error/QueryRunnerAlreadyReleasedError"
4
5
import { TransactionNotStartedError } from "../../error/TransactionNotStartedError"
5
- import { TableColumn } from "../../schema-builder/table/TableColumn"
6
+ import { ReadStream } from "../../platform/PlatformTools"
7
+ import { BaseQueryRunner } from "../../query-runner/BaseQueryRunner"
8
+ import { QueryResult } from "../../query-runner/QueryResult"
9
+ import { QueryRunner } from "../../query-runner/QueryRunner"
10
+ import { TableIndexOptions } from "../../schema-builder/options/TableIndexOptions"
6
11
import { Table } from "../../schema-builder/table/Table"
12
+ import { TableCheck } from "../../schema-builder/table/TableCheck"
13
+ import { TableColumn } from "../../schema-builder/table/TableColumn"
14
+ import { TableExclusion } from "../../schema-builder/table/TableExclusion"
7
15
import { TableForeignKey } from "../../schema-builder/table/TableForeignKey"
8
16
import { TableIndex } from "../../schema-builder/table/TableIndex"
9
- import { QueryRunnerAlreadyReleasedError } from "../../error/QueryRunnerAlreadyReleasedError"
10
- import { View } from "../../schema-builder/view/View"
11
- import { Query } from "../Query"
12
- import { MysqlDriver } from "./MysqlDriver"
13
- import { ReadStream } from "../../platform/PlatformTools"
14
- import { OrmUtils } from "../../util/OrmUtils"
15
- import { QueryFailedError } from "../../error/QueryFailedError"
16
- import { TableIndexOptions } from "../../schema-builder/options/TableIndexOptions"
17
17
import { TableUnique } from "../../schema-builder/table/TableUnique"
18
- import { BaseQueryRunner } from "../../query-runner/BaseQueryRunner "
18
+ import { View } from "../../schema-builder/view/View "
19
19
import { Broadcaster } from "../../subscriber/Broadcaster"
20
+ import { BroadcasterResult } from "../../subscriber/BroadcasterResult"
21
+ import { InstanceChecker } from "../../util/InstanceChecker"
22
+ import { OrmUtils } from "../../util/OrmUtils"
23
+ import { VersionUtils } from "../../util/VersionUtils"
24
+ import { Query } from "../Query"
20
25
import { ColumnType } from "../types/ColumnTypes"
21
- import { TableCheck } from "../../schema-builder/table/TableCheck"
22
26
import { IsolationLevel } from "../types/IsolationLevel"
23
- import { TableExclusion } from "../../schema-builder/table/TableExclusion"
24
- import { VersionUtils } from "../../util/VersionUtils"
25
- import { ReplicationMode } from "../types/ReplicationMode"
26
- import { TypeORMError } from "../../error"
27
27
import { MetadataTableType } from "../types/MetadataTableType"
28
- import { InstanceChecker } from "../../util/InstanceChecker "
29
- import { BroadcasterResult } from "../../subscriber/BroadcasterResult "
28
+ import { ReplicationMode } from "../types/ReplicationMode "
29
+ import { MysqlDriver } from "./MysqlDriver "
30
30
31
31
/**
32
32
* Runs queries on a single mysql database connection.
@@ -187,18 +187,16 @@ export class MysqlQueryRunner extends BaseQueryRunner implements QueryRunner {
187
187
) : Promise < any > {
188
188
if ( this . isReleased ) throw new QueryRunnerAlreadyReleasedError ( )
189
189
190
- return new Promise ( async ( ok , fail ) => {
191
- const broadcasterResult = new BroadcasterResult ( )
190
+ const databaseConnection = await this . connect ( )
192
191
193
- try {
194
- const databaseConnection = await this . connect ( )
192
+ this . driver . connection . logger . logQuery ( query , parameters , this )
193
+ await this . broadcaster . broadcast ( "BeforeQuery" , query , parameters )
195
194
196
- this . driver . connection . logger . logQuery ( query , parameters , this )
197
- this . broadcaster . broadcastBeforeQueryEvent (
198
- broadcasterResult ,
199
- query ,
200
- parameters ,
201
- )
195
+ const broadcasterResult = new BroadcasterResult ( )
196
+ const queryStartTime = Date . now ( )
197
+
198
+ return new Promise ( async ( ok , fail ) => {
199
+ try {
202
200
const enableQueryTimeout =
203
201
this . driver . options . enableQueryTimeout
204
202
const maxQueryExecutionTime =
@@ -207,7 +205,6 @@ export class MysqlQueryRunner extends BaseQueryRunner implements QueryRunner {
207
205
enableQueryTimeout && maxQueryExecutionTime
208
206
? { sql : query , timeout : maxQueryExecutionTime }
209
207
: query
210
- const queryStartTime = Date . now ( )
211
208
databaseConnection . query (
212
209
queryPayload ,
213
210
parameters ,
0 commit comments