@sap/xsodata 8.3.1 → 8.3.2
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/CHANGELOG.md +4 -0
- package/documentation/annotations.md +1 -1
- package/index.js +0 -5
- package/lib/configuration.js +8 -12
- package/lib/db/connect.js +126 -74
- package/lib/db/dbSegment.js +598 -283
- package/lib/db/dbVersionChecks.js +47 -12
- package/lib/handlerConfiguration.js +5 -2
- package/lib/http/conditionalHttpHandler.js +401 -299
- package/lib/http/simpleHttpRequest.js +18 -16
- package/lib/http/simpleHttpResponse.js +17 -15
- package/lib/http/uriParser.js +49 -25
- package/lib/http/validator/httpRequestValidator.js +46 -25
- package/lib/model/annotationFactory.js +64 -41
- package/lib/model/association.js +8 -6
- package/lib/model/entityType.js +161 -101
- package/lib/model/metadataReader.js +562 -280
- package/lib/model/model.js +28 -18
- package/lib/model/validator/xsoDataConcurrencyTokenValidator.js +62 -39
- package/lib/model/xsodataReader.js +226 -133
- package/lib/processor/authorizationProcessor.js +227 -188
- package/lib/processor/batchProcessor.js +101 -73
- package/lib/processor/contentIdHelper.js +42 -13
- package/lib/processor/errorProcessor.js +15 -12
- package/lib/processor/eventActionHandler.js +212 -0
- package/lib/processor/exitProcessor.js +83 -39
- package/lib/processor/processor.js +58 -18
- package/lib/processor/resourceProcessor.js +149 -58
- package/lib/processor/resourceProcessorDelete.js +44 -70
- package/lib/processor/resourceProcessorDeleteLinks.js +97 -121
- package/lib/processor/resourceProcessorGet.js +20 -6
- package/lib/processor/resourceProcessorPost.js +101 -111
- package/lib/processor/resourceProcessorPut.js +74 -85
- package/lib/processor/resourceProcessorPutPostLinks.js +143 -130
- package/lib/security/securityContext.js +53 -33
- package/lib/serializer/atomSerializer.js +238 -87
- package/lib/serializer/atomXmlToJsonSerializer.js +108 -115
- package/lib/serializer/content.js +8 -9
- package/lib/serializer/json.js +99 -51
- package/lib/serializer/jsonSerializer.js +5 -3
- package/lib/serializer/metadataSerializer.js +166 -72
- package/lib/serializer/serializer.js +50 -24
- package/lib/serializer/serviceSerializer.js +38 -13
- package/lib/serializer/value.js +5 -10
- package/lib/serializer/xmlToJsonSerializer.js +26 -37
- package/lib/sql/createDeleteLinksStatements.js +27 -13
- package/lib/sql/createDeleteStatements.js +77 -28
- package/lib/sql/createGetStatements.js +413 -169
- package/lib/sql/createLinksSQLStatements_1_n.js +287 -94
- package/lib/sql/createPostStatements.js +83 -22
- package/lib/sql/createPutPostLinksStatements.js +29 -15
- package/lib/sql/createPutStatements.js +111 -32
- package/lib/sql/dataCollector2.js +47 -20
- package/lib/sql/dataCollectorDelete.js +49 -23
- package/lib/sql/dataCollectorDeleteLinks.js +10 -5
- package/lib/sql/dataCollectorGet.js +149 -72
- package/lib/sql/dataCollectorLinks.js +134 -59
- package/lib/sql/dataCollectorPost.js +76 -56
- package/lib/sql/dataCollectorPut.js +111 -58
- package/lib/sql/dataCollectorPutPostLinks.js +16 -7
- package/lib/sql/sqlStatement.js +344 -296
- package/lib/sql/sqlTools.js +25 -11
- package/lib/sql/statementProcessor.js +131 -61
- package/lib/uri/applyChecks.js +2 -1
- package/lib/uri/checks/checkAllowedMethod.js +4 -8
- package/lib/uri/checks/checkAllowedMethodForBatch.js +7 -2
- package/lib/uri/checks/checkAllowedMethodsForResourcePath.js +89 -53
- package/lib/uri/checks/checkFilterOnAggregatedColumn.js +6 -9
- package/lib/uri/checks/checkFilterOrderByOnGenKeyColumn.js +9 -9
- package/lib/uri/checks/checkGenKeyRestrictions.js +3 -3
- package/lib/uri/checks/checkModificationForbidden.js +14 -7
- package/lib/uri/checks/checkPostPutDeleteChecks.js +28 -9
- package/lib/uri/checks/checkSystemQueryOptions.js +170 -155
- package/lib/uri/checks.js +5 -11
- package/lib/uri/expandSelectTreeBuilder.js +10 -13
- package/lib/uri/oDataUriParser.js +39 -16
- package/lib/uri/queryParameterParser.js +5 -12
- package/lib/uri/resourcePathParser.js +480 -225
- package/lib/uri/uriSegmentTypes.js +2 -9
- package/lib/uri/uriType.js +69 -57
- package/lib/utils/associations.js +44 -16
- package/lib/utils/batch/batchConst.js +4 -5
- package/lib/utils/batch/batchExecutor.js +117 -41
- package/lib/utils/batch/batchObjects.js +12 -11
- package/lib/utils/batch/batchParser.js +44 -20
- package/lib/utils/batch/batchWriter.js +1 -1
- package/lib/utils/checkContentType.js +44 -25
- package/lib/utils/debugView.js +166 -90
- package/lib/utils/errors/debugInfo.js +0 -1
- package/lib/utils/errors/http/badRequest.js +1 -2
- package/lib/utils/errors/http/forbidden.js +1 -2
- package/lib/utils/errors/http/methodNotAllowed.js +1 -2
- package/lib/utils/errors/http/notAcceptable.js +1 -2
- package/lib/utils/errors/http/notFound.js +1 -2
- package/lib/utils/errors/http/notImplemented.js +1 -2
- package/lib/utils/errors/http/notModified.js +1 -1
- package/lib/utils/errors/http/notSupported.js +1 -2
- package/lib/utils/errors/http/preconditionFailed.js +1 -1
- package/lib/utils/errors/http/preconditionRequired.js +1 -1
- package/lib/utils/errors/http/unauthorized.js +1 -2
- package/lib/utils/errors/http/unsupportedMediaType.js +1 -2
- package/lib/utils/errors/httpError.js +1 -2
- package/lib/utils/errors/modelFileError.js +2 -2
- package/lib/utils/errors/sqlError.js +1 -1
- package/lib/utils/errors/typeError.js +4 -4
- package/lib/utils/errors/xsODataError.js +2 -4
- package/lib/utils/keyGenerator.js +1 -1
- package/lib/utils/logger.js +129 -41
- package/lib/utils/measurement.js +3 -4
- package/lib/utils/networkContext.js +3 -2
- package/lib/utils/requestContext.js +11 -15
- package/lib/utils/stateMaschine.js +16 -17
- package/lib/utils/tableCleanup.js +42 -18
- package/lib/utils/typeConverter.js +87 -80
- package/lib/utils/typeConverters/converterTools.js +122 -90
- package/lib/utils/typeConverters/dbToJson.js +50 -24
- package/lib/utils/typeConverters/dbToUri.js +22 -24
- package/lib/utils/typeConverters/dbToXml.js +24 -8
- package/lib/utils/typeConverters/jsonToDb.js +26 -18
- package/lib/utils/typeConverters/uriToDb.js +53 -29
- package/lib/utils/typeConverters/xmlValueToJson.js +36 -30
- package/lib/utils/typedObjects.js +292 -198
- package/lib/utils/utils.js +49 -39
- package/lib/xsodata.js +202 -74
- package/package.json +10 -4
package/CHANGELOG.md
CHANGED
|
@@ -34,7 +34,7 @@ If the annotations are enabled for an XSOData service, the following XML namespa
|
|
|
34
34
|
of the $metadata document:
|
|
35
35
|
|
|
36
36
|
```
|
|
37
|
-
xmlns:sap="
|
|
37
|
+
xmlns:sap="https://www.sap.com/Protocols/SAPData"
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
The sections below describe the annotations (annotation attributes), which are supported by the XSOData XS2. Only the
|
package/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
//Includes
|
|
5
4
|
const xsodata = require('./lib/xsodata');
|
|
6
5
|
const configuration = require('./lib/configuration');
|
|
@@ -11,7 +10,3 @@ module.exports.ODataHandler = xsodata.ODataHandler;
|
|
|
11
10
|
|
|
12
11
|
module.exports.RequestOptions = configuration.RequestOptions;
|
|
13
12
|
module.exports.HandlerOptions = configuration.HandlerOptions;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
package/lib/configuration.js
CHANGED
|
@@ -5,18 +5,16 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
exports.modes = {
|
|
8
|
-
development:
|
|
9
|
-
productive:
|
|
8
|
+
development: 'development',
|
|
9
|
+
productive: 'productive',
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
/**
|
|
14
13
|
* Exposed in index.js and used by xsjs or other application to set options for a hole OData handler
|
|
15
14
|
* @param init
|
|
16
15
|
* @constructor
|
|
17
16
|
*/
|
|
18
17
|
exports.HandlerOptions = function HandlerOptions(init) {
|
|
19
|
-
|
|
20
18
|
/**
|
|
21
19
|
* serviceConfiguration may be a directory containing *.xsodata files (the directory name MUST NOT end with ".xsodata")
|
|
22
20
|
* Usage: When pathPrefix is "/sub1/sub2" and serviceConfiguration is directory "./services" then the request to
|
|
@@ -61,7 +59,6 @@ exports.HandlerOptions = function HandlerOptions(init) {
|
|
|
61
59
|
check(this);
|
|
62
60
|
};
|
|
63
61
|
|
|
64
|
-
|
|
65
62
|
/**
|
|
66
63
|
* RequestOptions encapsulate all options witch can be set on a per request basis
|
|
67
64
|
* Exposed in index.js and used by xsjs or other application when calling "processRequest"
|
|
@@ -80,7 +77,6 @@ exports.RequestOptions = function RequestOptions(init) {
|
|
|
80
77
|
*/
|
|
81
78
|
this.uriPrefix = init.uriPrefix;
|
|
82
79
|
|
|
83
|
-
|
|
84
80
|
this.dbClient = init.dbClient || null;
|
|
85
81
|
|
|
86
82
|
/** Function to open the db connection lazy
|
|
@@ -122,7 +118,6 @@ exports.RequestOptions = function RequestOptions(init) {
|
|
|
122
118
|
*/
|
|
123
119
|
this.functionExecutor = init.functionExecutor || null;
|
|
124
120
|
|
|
125
|
-
|
|
126
121
|
/**
|
|
127
122
|
* Function called for loading a module. The module is a bag for functions used at exit points
|
|
128
123
|
* The function must support an object like {"package" : string, "file": string, "ext": string} as input parameter
|
|
@@ -142,12 +137,13 @@ exports.RequestOptions = function RequestOptions(init) {
|
|
|
142
137
|
this.logger = init.logger;
|
|
143
138
|
|
|
144
139
|
this.locale = init.locale;
|
|
145
|
-
|
|
146
140
|
};
|
|
147
141
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
142
|
+
function check(target) {
|
|
143
|
+
if (
|
|
144
|
+
target.mode !== exports.modes.development &&
|
|
145
|
+
target.mode !== exports.modes.productive
|
|
146
|
+
) {
|
|
147
|
+
throw new Error('Invalid mode. See xsodata.modes for possible values.');
|
|
152
148
|
}
|
|
153
149
|
}
|
package/lib/db/connect.js
CHANGED
|
@@ -41,7 +41,6 @@ function execSQL(sql, context, asyncDone) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function loadDbVersion(context, asyncDone) {
|
|
44
|
-
|
|
45
44
|
if (!context.gModel) {
|
|
46
45
|
return asyncDone(null, context);
|
|
47
46
|
}
|
|
@@ -51,45 +50,59 @@ function loadDbVersion(context, asyncDone) {
|
|
|
51
50
|
return asyncDone(null, context);
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
return context.db.client.exec(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
return context.db.client.exec(
|
|
54
|
+
'select version from "SYS"."M_DATABASE"',
|
|
55
|
+
function (err, rows) {
|
|
56
|
+
if (err) {
|
|
57
|
+
return asyncDone(new SqlError(context, err), context);
|
|
58
|
+
}
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
if (rows && rows[0] && rows[0].VERSION) {
|
|
61
|
+
const version = rows[0].VERSION;
|
|
62
|
+
context.logger.info('xsodata', 'db version: ' + version);
|
|
63
|
+
context.gModel.setDbVersion(version);
|
|
64
|
+
} else {
|
|
65
|
+
context.gModel.setDbVersion(null); // don't try reload
|
|
66
|
+
}
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
return asyncDone(null, context);
|
|
69
|
+
}
|
|
70
|
+
);
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
function setHanaCloudContext(context, asyncDone) {
|
|
74
|
+
return context.db.client.exec(
|
|
75
|
+
'select version from "SYS"."M_DATABASE"',
|
|
76
|
+
function (err, rows) {
|
|
77
|
+
if (err) {
|
|
78
|
+
return asyncDone(new SqlError(context, err), context);
|
|
79
|
+
}
|
|
72
80
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
81
|
+
if (rows && rows[0] && rows[0].VERSION) {
|
|
82
|
+
const version = rows[0].VERSION;
|
|
83
|
+
context.logger.info('xsodata', 'db version: ' + version);
|
|
84
|
+
context.db.isHanaCloudDb = isHanaCloudDb(
|
|
85
|
+
context,
|
|
86
|
+
rows[0].VERSION
|
|
87
|
+
);
|
|
88
|
+
context.logger.info(
|
|
89
|
+
'xsodata',
|
|
90
|
+
`isHanaCloud: ${context.db.isHanaCloudDb} (DB version based)`
|
|
91
|
+
);
|
|
92
|
+
} else {
|
|
93
|
+
// 06/2022:
|
|
94
|
+
// Currently all SQL from Hana Cloud work also on Hana Service, i.e. take that version as default;
|
|
95
|
+
// could be changed in the future, i.e. using the context setting of 'context.db.isHanaCloudDb'
|
|
96
|
+
context.db.isHanaCloudDb = true;
|
|
97
|
+
context.logger.info(
|
|
98
|
+
'xsodata',
|
|
99
|
+
`isHanaCloud: ${context.db.isHanaCloudDb} (default)`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
77
102
|
|
|
78
|
-
|
|
79
|
-
const version = rows[0].VERSION;
|
|
80
|
-
context.logger.info('xsodata', 'db version: ' + version);
|
|
81
|
-
context.db.isHanaCloudDb = isHanaCloudDb(context, rows[0].VERSION);
|
|
82
|
-
context.logger.info('xsodata', `isHanaCloud: ${context.db.isHanaCloudDb} (DB version based)`);
|
|
83
|
-
} else {
|
|
84
|
-
// 06/2022:
|
|
85
|
-
// Currently all SQL from Hana Cloud work also on Hana Service, i.e. take that version as default;
|
|
86
|
-
// could be changed in the future, i.e. using the context setting of 'context.db.isHanaCloudDb'
|
|
87
|
-
context.db.isHanaCloudDb = true;
|
|
88
|
-
context.logger.info('xsodata', `isHanaCloud: ${context.db.isHanaCloudDb} (default)`);
|
|
103
|
+
return asyncDone(null, context);
|
|
89
104
|
}
|
|
90
|
-
|
|
91
|
-
return asyncDone(null, context);
|
|
92
|
-
});
|
|
105
|
+
);
|
|
93
106
|
}
|
|
94
107
|
|
|
95
108
|
function isHanaCloudDb(context, version) {
|
|
@@ -97,10 +110,10 @@ function isHanaCloudDb(context, version) {
|
|
|
97
110
|
let result = version.match(regex);
|
|
98
111
|
|
|
99
112
|
if (result && result[1]) {
|
|
100
|
-
return
|
|
113
|
+
return result[1] >= 4;
|
|
101
114
|
} else {
|
|
102
115
|
context.logger.error(`DB Version parsing failed: ${version}`);
|
|
103
|
-
return true;
|
|
116
|
+
return true; // default: Hana Cloud
|
|
104
117
|
}
|
|
105
118
|
}
|
|
106
119
|
|
|
@@ -118,31 +131,43 @@ function getDbClientType(dbClient) {
|
|
|
118
131
|
* @param asyncDone
|
|
119
132
|
*/
|
|
120
133
|
function prepareConnection(context, asyncDone) {
|
|
121
|
-
context.logger.debug(
|
|
134
|
+
context.logger.debug(
|
|
135
|
+
'connect - db',
|
|
136
|
+
'prepare connection via ' +
|
|
137
|
+
(getDbClientType(context.db.client) === 'hdb'
|
|
138
|
+
? 'hdb'
|
|
139
|
+
: 'hana-client')
|
|
140
|
+
);
|
|
122
141
|
|
|
123
|
-
let executeList = [
|
|
124
|
-
utils.injectContext(context)
|
|
125
|
-
];
|
|
142
|
+
let executeList = [utils.injectContext(context)];
|
|
126
143
|
|
|
127
144
|
// Set the default schema
|
|
128
145
|
if (context.defaultSchema) {
|
|
129
|
-
executeList.push(
|
|
146
|
+
executeList.push(
|
|
147
|
+
utils.tryAndMeasure(
|
|
148
|
+
execSQL,
|
|
149
|
+
'SET SCHEMA ' + context.defaultSchema,
|
|
150
|
+
'execSQL (default schema)'
|
|
151
|
+
)
|
|
152
|
+
);
|
|
130
153
|
}
|
|
131
154
|
|
|
132
|
-
|
|
133
155
|
// Set the isolation level
|
|
134
|
-
executeList.push(
|
|
156
|
+
executeList.push(
|
|
157
|
+
utils.tryAndMeasure(
|
|
158
|
+
execSQL,
|
|
159
|
+
'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ',
|
|
160
|
+
'execSQL (isolation level)'
|
|
161
|
+
)
|
|
162
|
+
);
|
|
135
163
|
executeList.push(loadDbVersion);
|
|
136
164
|
// Set Hana Cloud indicator in context
|
|
137
165
|
executeList.push(setHanaCloudContext);
|
|
138
166
|
|
|
139
|
-
async.waterfall(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
asyncDone(err, context);
|
|
144
|
-
}
|
|
145
|
-
);
|
|
167
|
+
async.waterfall(executeList, function (err) {
|
|
168
|
+
context.db.client.setAutoCommit(false);
|
|
169
|
+
asyncDone(err, context);
|
|
170
|
+
});
|
|
146
171
|
}
|
|
147
172
|
|
|
148
173
|
/**
|
|
@@ -154,17 +179,22 @@ function prepareConnection(context, asyncDone) {
|
|
|
154
179
|
*/
|
|
155
180
|
exports._openConnection = function (context, asyncDone) {
|
|
156
181
|
context.logger.debug('connect - db', '_openConnection');
|
|
157
|
-
context.db.opener(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
182
|
+
context.db.opener(
|
|
183
|
+
context.handlerConfiguration.dbConfiguration,
|
|
184
|
+
function (err, newClient) {
|
|
185
|
+
if (err) {
|
|
186
|
+
return asyncDone(
|
|
187
|
+
new ApplicationError('Internal error occurred', err),
|
|
188
|
+
context
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
context.db.client = newClient;
|
|
162
192
|
|
|
163
|
-
|
|
164
|
-
|
|
193
|
+
return asyncDone(null, context);
|
|
194
|
+
}
|
|
195
|
+
);
|
|
165
196
|
};
|
|
166
197
|
|
|
167
|
-
|
|
168
198
|
/**
|
|
169
199
|
* Connects to a database, there are 3 way to define which database
|
|
170
200
|
* 1. By providing a hdbClient via requestOptions.dbClient
|
|
@@ -199,7 +229,6 @@ function _connectInternal(context, asyncDone) {
|
|
|
199
229
|
}
|
|
200
230
|
}
|
|
201
231
|
|
|
202
|
-
|
|
203
232
|
try {
|
|
204
233
|
let db_module = null;
|
|
205
234
|
|
|
@@ -217,17 +246,25 @@ function _connectInternal(context, asyncDone) {
|
|
|
217
246
|
context.logger.silly('connect - db', 'use hana-client');
|
|
218
247
|
}
|
|
219
248
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
249
|
+
client = Measurement.measureSync(
|
|
250
|
+
db_module.createClient,
|
|
251
|
+
context.handlerConfiguration.dbConfiguration,
|
|
252
|
+
'hdb.createClient'
|
|
253
|
+
);
|
|
223
254
|
} catch (exception) {
|
|
224
|
-
context.logger.error(
|
|
255
|
+
context.logger.error(
|
|
256
|
+
'connect - db',
|
|
257
|
+
'createClient failed: ' + JSON.stringify(exception)
|
|
258
|
+
);
|
|
225
259
|
return asyncDone(exception, context);
|
|
226
260
|
}
|
|
227
261
|
|
|
228
262
|
if (getDbClientType(client) === 'hdb') {
|
|
229
263
|
client.on('error', function (err) {
|
|
230
|
-
context.logger.error(
|
|
264
|
+
context.logger.error(
|
|
265
|
+
'connect - db',
|
|
266
|
+
'client error event: ' + JSON.stringify(err)
|
|
267
|
+
);
|
|
231
268
|
return asyncDone(new InternalError(err, context), context);
|
|
232
269
|
});
|
|
233
270
|
}
|
|
@@ -249,7 +286,10 @@ function _connectInternal(context, asyncDone) {
|
|
|
249
286
|
}
|
|
250
287
|
|
|
251
288
|
if (err) {
|
|
252
|
-
context.logger.error(
|
|
289
|
+
context.logger.error(
|
|
290
|
+
'connect - db',
|
|
291
|
+
'connect failed: ' + JSON.stringify(err)
|
|
292
|
+
);
|
|
253
293
|
client.end();
|
|
254
294
|
return asyncDone(new InternalError(err, context), context);
|
|
255
295
|
}
|
|
@@ -257,10 +297,8 @@ function _connectInternal(context, asyncDone) {
|
|
|
257
297
|
context.db.client = client;
|
|
258
298
|
context.db.openedConnection = true;
|
|
259
299
|
|
|
260
|
-
|
|
261
300
|
context.logger.info('connect - db', 'connection opened');
|
|
262
301
|
|
|
263
|
-
|
|
264
302
|
return prepareConnection(context, asyncDone);
|
|
265
303
|
});
|
|
266
304
|
}
|
|
@@ -274,7 +312,7 @@ function _connectInternal(context, asyncDone) {
|
|
|
274
312
|
*/
|
|
275
313
|
exports.connect = function (context, asyncDone) {
|
|
276
314
|
context.db = context.db || {};
|
|
277
|
-
if (context.db.client &&
|
|
315
|
+
if (context.db.client && context.db.connectionInitialized === true) {
|
|
278
316
|
context.logger.info('connect - db', 'connect already done');
|
|
279
317
|
return asyncDone(null, context);
|
|
280
318
|
}
|
|
@@ -282,18 +320,24 @@ exports.connect = function (context, asyncDone) {
|
|
|
282
320
|
|
|
283
321
|
return _connectInternal(context, function (err) {
|
|
284
322
|
if (err) {
|
|
285
|
-
context.logger.debug(
|
|
323
|
+
context.logger.debug(
|
|
324
|
+
'connect - db',
|
|
325
|
+
'connect error ' + err.toString
|
|
326
|
+
? err.toString()
|
|
327
|
+
: JSON.stringify(err)
|
|
328
|
+
);
|
|
286
329
|
return asyncDone(err, context);
|
|
287
330
|
}
|
|
288
331
|
context.logger.debug('connect - db', 'connection is usable');
|
|
289
332
|
context.db.connectionInitialized = true;
|
|
290
|
-
context.logger.debug(
|
|
333
|
+
context.logger.debug(
|
|
334
|
+
'connect - context setting - Is Hana Cloud used?',
|
|
335
|
+
`${context.db.isHanaCloudDb}`
|
|
336
|
+
);
|
|
291
337
|
return asyncDone(null, context);
|
|
292
|
-
|
|
293
338
|
});
|
|
294
339
|
};
|
|
295
340
|
|
|
296
|
-
|
|
297
341
|
/**
|
|
298
342
|
* Ends the db connection
|
|
299
343
|
*
|
|
@@ -308,9 +352,15 @@ exports.disconnect = function (context, cb) {
|
|
|
308
352
|
if (context.db.client) {
|
|
309
353
|
context.db.client.end((err) => {
|
|
310
354
|
if (err) {
|
|
311
|
-
context.logger.error(
|
|
355
|
+
context.logger.error(
|
|
356
|
+
'connect - db',
|
|
357
|
+
`disconnect failed (callback): ${err}`
|
|
358
|
+
);
|
|
312
359
|
}
|
|
313
|
-
context.logger.info(
|
|
360
|
+
context.logger.info(
|
|
361
|
+
'connect - db',
|
|
362
|
+
'disconnect done (callback)'
|
|
363
|
+
);
|
|
314
364
|
});
|
|
315
365
|
}
|
|
316
366
|
context.db.openedConnection = false;
|
|
@@ -325,7 +375,6 @@ exports.disconnect = function (context, cb) {
|
|
|
325
375
|
return cb();
|
|
326
376
|
};
|
|
327
377
|
|
|
328
|
-
|
|
329
378
|
exports.dbRollback = (context, dbClient, cb) => {
|
|
330
379
|
context.logger.info('connect - db', 'dbRollback');
|
|
331
380
|
return dbClient.rollback(function (errDB) {
|
|
@@ -335,7 +384,10 @@ exports.dbRollback = (context, dbClient, cb) => {
|
|
|
335
384
|
}
|
|
336
385
|
|
|
337
386
|
if (dbVersionChecks.shouldNotCleanTmpTables(context)) {
|
|
338
|
-
context.logger.info(
|
|
387
|
+
context.logger.info(
|
|
388
|
+
'connect - db',
|
|
389
|
+
'no tmp table delete due to rollback'
|
|
390
|
+
);
|
|
339
391
|
tableCleanup.emptyLists(context);
|
|
340
392
|
}
|
|
341
393
|
|