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
|
*/
|
|
@@ -20,7 +20,6 @@ const QueryResult_1 = require("../../query-runner/QueryResult");
|
|
|
20
20
|
const QueryLock_1 = require("../../query-runner/QueryLock");
|
|
21
21
|
const MetadataTableType_1 = require("../types/MetadataTableType");
|
|
22
22
|
const InstanceChecker_1 = require("../../util/InstanceChecker");
|
|
23
|
-
const util_1 = require("util");
|
|
24
23
|
/**
|
|
25
24
|
* Runs queries on a single SQL Server database connection.
|
|
26
25
|
*/
|
|
@@ -71,11 +70,6 @@ class SapQueryRunner extends BaseQueryRunner_1.BaseQueryRunner {
|
|
|
71
70
|
throw new TransactionAlreadyStartedError_1.TransactionAlreadyStartedError();
|
|
72
71
|
await this.broadcaster.broadcast("BeforeTransactionStart");
|
|
73
72
|
this.isTransactionActive = true;
|
|
74
|
-
/**
|
|
75
|
-
* Disable AUTOCOMMIT while running transaction.
|
|
76
|
-
* Otherwise, COMMIT/ROLLBACK doesn't work in autocommit mode.
|
|
77
|
-
*/
|
|
78
|
-
await this.setAutoCommit({ status: "off" });
|
|
79
73
|
if (isolationLevel) {
|
|
80
74
|
await this.query(`SET TRANSACTION ISOLATION LEVEL ${isolationLevel || ""}`);
|
|
81
75
|
}
|
|
@@ -93,7 +87,6 @@ class SapQueryRunner extends BaseQueryRunner_1.BaseQueryRunner {
|
|
|
93
87
|
await this.broadcaster.broadcast("BeforeTransactionCommit");
|
|
94
88
|
await this.query("COMMIT");
|
|
95
89
|
this.isTransactionActive = false;
|
|
96
|
-
await this.setAutoCommit({ status: "on" });
|
|
97
90
|
await this.broadcaster.broadcast("AfterTransactionCommit");
|
|
98
91
|
}
|
|
99
92
|
/**
|
|
@@ -108,25 +101,8 @@ class SapQueryRunner extends BaseQueryRunner_1.BaseQueryRunner {
|
|
|
108
101
|
await this.broadcaster.broadcast("BeforeTransactionRollback");
|
|
109
102
|
await this.query("ROLLBACK");
|
|
110
103
|
this.isTransactionActive = false;
|
|
111
|
-
await this.setAutoCommit({ status: "on" });
|
|
112
104
|
await this.broadcaster.broadcast("AfterTransactionRollback");
|
|
113
105
|
}
|
|
114
|
-
/**
|
|
115
|
-
* @description Switches on/off AUTOCOMMIT mode
|
|
116
|
-
* @link https://help.sap.com/docs/HANA_SERVICE_CF/7c78579ce9b14a669c1f3295b0d8ca16/d538d11053bd4f3f847ec5ce817a3d4c.html?locale=en-US
|
|
117
|
-
*/
|
|
118
|
-
async setAutoCommit(options) {
|
|
119
|
-
const connection = await this.connect();
|
|
120
|
-
const execute = (0, util_1.promisify)(connection.exec.bind(connection));
|
|
121
|
-
connection.setAutoCommit(options.status === "on");
|
|
122
|
-
const query = `SET TRANSACTION AUTOCOMMIT DDL ${options.status.toUpperCase()};`;
|
|
123
|
-
try {
|
|
124
|
-
await execute(query);
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
throw new error_1.QueryFailedError(query, [], error);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
106
|
/**
|
|
131
107
|
* Executes a given SQL query.
|
|
132
108
|
*/
|
|
@@ -138,6 +114,8 @@ class SapQueryRunner extends BaseQueryRunner_1.BaseQueryRunner {
|
|
|
138
114
|
const result = new QueryResult_1.QueryResult();
|
|
139
115
|
try {
|
|
140
116
|
const databaseConnection = await this.connect();
|
|
117
|
+
// we disable autocommit because ROLLBACK does not work in autocommit mode
|
|
118
|
+
databaseConnection.setAutoCommit(!this.isTransactionActive);
|
|
141
119
|
this.driver.connection.logger.logQuery(query, parameters, this);
|
|
142
120
|
const queryStartTime = +new Date();
|
|
143
121
|
const isInsertQuery = query.substr(0, 11) === "INSERT INTO";
|