typeorm 0.3.7-dev.a748f3c → 0.3.7-dev.bcdddc3
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/browser/driver/sap/SapQueryRunner.d.ts +0 -7
- package/browser/driver/sap/SapQueryRunner.js +2 -24
- package/browser/driver/sap/SapQueryRunner.js.map +1 -1
- package/driver/sap/SapQueryRunner.d.ts +0 -7
- package/driver/sap/SapQueryRunner.js +2 -24
- package/driver/sap/SapQueryRunner.js.map +1 -1
- package/package.json +1 -1
|
@@ -52,13 +52,6 @@ export declare class SapQueryRunner extends BaseQueryRunner implements QueryRunn
|
|
|
52
52
|
* Error will be thrown if transaction was not started.
|
|
53
53
|
*/
|
|
54
54
|
rollbackTransaction(): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* @description Switches on/off AUTOCOMMIT mode
|
|
57
|
-
* @link https://help.sap.com/docs/HANA_SERVICE_CF/7c78579ce9b14a669c1f3295b0d8ca16/d538d11053bd4f3f847ec5ce817a3d4c.html?locale=en-US
|
|
58
|
-
*/
|
|
59
|
-
setAutoCommit(options: {
|
|
60
|
-
status: "on" | "off";
|
|
61
|
-
}): Promise<void>;
|
|
62
55
|
/**
|
|
63
56
|
* Executes a given SQL query.
|
|
64
57
|
*/
|
|
@@ -17,7 +17,6 @@ import { QueryResult } from "../../query-runner/QueryResult";
|
|
|
17
17
|
import { QueryLock } from "../../query-runner/QueryLock";
|
|
18
18
|
import { MetadataTableType } from "../types/MetadataTableType";
|
|
19
19
|
import { InstanceChecker } from "../../util/InstanceChecker";
|
|
20
|
-
import { promisify } from "util";
|
|
21
20
|
/**
|
|
22
21
|
* Runs queries on a single SQL Server database connection.
|
|
23
22
|
*/
|
|
@@ -68,11 +67,6 @@ export class SapQueryRunner extends BaseQueryRunner {
|
|
|
68
67
|
throw new TransactionAlreadyStartedError();
|
|
69
68
|
await this.broadcaster.broadcast("BeforeTransactionStart");
|
|
70
69
|
this.isTransactionActive = true;
|
|
71
|
-
/**
|
|
72
|
-
* Disable AUTOCOMMIT while running transaction.
|
|
73
|
-
* Otherwise, COMMIT/ROLLBACK doesn't work in autocommit mode.
|
|
74
|
-
*/
|
|
75
|
-
await this.setAutoCommit({ status: "off" });
|
|
76
70
|
if (isolationLevel) {
|
|
77
71
|
await this.query(`SET TRANSACTION ISOLATION LEVEL ${isolationLevel || ""}`);
|
|
78
72
|
}
|
|
@@ -90,7 +84,6 @@ export class SapQueryRunner extends BaseQueryRunner {
|
|
|
90
84
|
await this.broadcaster.broadcast("BeforeTransactionCommit");
|
|
91
85
|
await this.query("COMMIT");
|
|
92
86
|
this.isTransactionActive = false;
|
|
93
|
-
await this.setAutoCommit({ status: "on" });
|
|
94
87
|
await this.broadcaster.broadcast("AfterTransactionCommit");
|
|
95
88
|
}
|
|
96
89
|
/**
|
|
@@ -105,25 +98,8 @@ export class SapQueryRunner extends BaseQueryRunner {
|
|
|
105
98
|
await this.broadcaster.broadcast("BeforeTransactionRollback");
|
|
106
99
|
await this.query("ROLLBACK");
|
|
107
100
|
this.isTransactionActive = false;
|
|
108
|
-
await this.setAutoCommit({ status: "on" });
|
|
109
101
|
await this.broadcaster.broadcast("AfterTransactionRollback");
|
|
110
102
|
}
|
|
111
|
-
/**
|
|
112
|
-
* @description Switches on/off AUTOCOMMIT mode
|
|
113
|
-
* @link https://help.sap.com/docs/HANA_SERVICE_CF/7c78579ce9b14a669c1f3295b0d8ca16/d538d11053bd4f3f847ec5ce817a3d4c.html?locale=en-US
|
|
114
|
-
*/
|
|
115
|
-
async setAutoCommit(options) {
|
|
116
|
-
const connection = await this.connect();
|
|
117
|
-
const execute = promisify(connection.exec.bind(connection));
|
|
118
|
-
connection.setAutoCommit(options.status === "on");
|
|
119
|
-
const query = `SET TRANSACTION AUTOCOMMIT DDL ${options.status.toUpperCase()};`;
|
|
120
|
-
try {
|
|
121
|
-
await execute(query);
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
throw new QueryFailedError(query, [], error);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
103
|
/**
|
|
128
104
|
* Executes a given SQL query.
|
|
129
105
|
*/
|
|
@@ -135,6 +111,8 @@ export class SapQueryRunner extends BaseQueryRunner {
|
|
|
135
111
|
const result = new QueryResult();
|
|
136
112
|
try {
|
|
137
113
|
const databaseConnection = await this.connect();
|
|
114
|
+
// we disable autocommit because ROLLBACK does not work in autocommit mode
|
|
115
|
+
databaseConnection.setAutoCommit(!this.isTransactionActive);
|
|
138
116
|
this.driver.connection.logger.logQuery(query, parameters, this);
|
|
139
117
|
const queryStartTime = +new Date();
|
|
140
118
|
const isInsertQuery = query.substr(0, 11) === "INSERT INTO";
|