@sap/xsodata 7.3.5 → 7.4.5

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 CHANGED
@@ -8,11 +8,34 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
8
8
 
9
9
  ## Unreleased
10
10
 
11
+ ## [7.4.5] - 2021-12-15
12
+
13
+ * Suppress $metadata annotation <code>sap:aggregation-role="dimension"</code> on calculation view property if it is used as description property referenced by annotation <code>sap:text</code> by another property of the calulation view. The annotation is only supressed if the corresponding xsodata-file has <code>settings</code> containing this: <code>noDimensionAnnoOnTextProperty true;</code>
14
+ * Improvements on URI parsing errors:
15
+ * reporting URI resource path character position on parsing error, if possible
16
+ * Invalid navigation property on <code>$expand</code> system query option returns 400 (Bad Request) instead of 500 (Internal Server Error)
17
+ * Removed support for NodeJS version 10
18
+
19
+ ## [7.4.4] - 2021-07-20
20
+
21
+ * HANA client API usage changed: 'execQuery' used for read requests, change requests remain on 'exec'
22
+
23
+ ## [7.4.2] - 2021-05-05
24
+
25
+ * Quote reserve for calcview "in" formula
26
+ * node version support: 10, 12, 14
27
+
28
+ ## [7.3.7] - 2021-02-24
29
+
30
+ ### Fixed
31
+
32
+ For Edm.String typed properties, all single quotes must be preserved.
33
+
11
34
  ## [7.3.5] - 2020-11-23
12
35
 
13
36
  ### Fixed
14
37
 
15
- Authoization header parsing conform to RFC6750
38
+ Authorization header parsing conform to RFC6750
16
39
 
17
40
  ## [7.3.4] - 2020-10-14
18
41
 
@@ -31,7 +54,7 @@ Commit on drop of temporary tables added.
31
54
 
32
55
  ## [7.3.1] - 2020-09-29
33
56
 
34
- ### Changed
57
+ ### Changed
35
58
 
36
59
  * Improved error messages.
37
60
 
@@ -40,34 +63,34 @@ Commit on drop of temporary tables added.
40
63
  * Aggregation for "count":
41
64
  * For explicit application the aggregation type "count" was not supported in the xsodata file. When
42
65
  "aggregates always (COUNT of "Amount");" was used, a syntax error was thrown.
43
- * For implicit aggregation, where the aggregation information is loaded from the calcviews measures (e.g.
66
+ * For implicit aggregation, where the aggregation information is loaded from the calcviews measures (e.g.
44
67
  using "aggregates always;" without a property list in the *.xsodata file), wrongly "avg" was used as measure
45
68
  type instead of "count".
46
69
  * With this fix aggregation type "count" is now properly supported
47
- * For explicit application: "aggregates always (COUNT of "Amount");"
48
- * For implicit aggregation: calcview measures "count" and "avg" are now supported property
49
-
50
- * Fix: If a temporary table is not properly dropped by the DB, a second drop step is performed to avoid errors
70
+ * For explicit application: "aggregates always (COUNT of "Amount");"
71
+ * For implicit aggregation: calcview measures "count" and "avg" are now supported property
72
+
73
+ * Fix: If a temporary table is not properly dropped by the DB, a second drop step is performed to avoid errors
51
74
  when recreating the table.
52
-
75
+
53
76
  ## [7.2.0] - 2020-08-19
54
77
 
55
78
  * Improve logging infrastructure
56
79
 
57
80
  ## [7.1.0] - 2020-08-11
58
81
 
59
- * OData type Edm.Time is mapped to hana types 'TIME' (due to backward compatiblity) which stores only hour, minutes
60
- and seconds, so only the uri format **time'PT0H0M0S'** was supported. With this fix also the full representation
61
- like time'P2010Y12M30DT01H02M03S' can be used (some UIs generated it) if the parts of year, mounth and day are zero.
62
-
63
- * Fix for missing annotations (e.g. "sap:label") if an calcview without input parameters is exposed as normal view
82
+ * OData type Edm.Time is mapped to hana types 'TIME' (due to backward compatiblity) which stores only hour, minutes
83
+ and seconds, so only the uri format **time'PT0H0M0S'** was supported. With this fix also the full representation
84
+ like time'P2010Y12M30DT01H02M03S' can be used (some UIs generated it) if the parts of year, mounth and day are zero.
85
+
86
+ * Fix for missing annotations (e.g. "sap:label") if an calcview without input parameters is exposed as normal view
64
87
  (this is without the "parameter via" keyword in the xsodata file)
65
88
 
66
89
  * Fixes for create, update, delete operations via user-exits on calculation views without input parameters.
67
- Please note: if the input parameters are omitted and "via keys" is used, then the input parameter must be set in
68
- the exit functions since they are rendered in the output.
90
+ Please note: if the input parameters are omitted and "via keys" is used, then the input parameter must be set in
91
+ the exit functions since they are rendered in the output.
69
92
 
70
- * Explicitly drop prepared statements immediately instead at request end
93
+ * Explicitly drop prepared statements immediately instead at request end
71
94
 
72
95
  ## [7.0.3] - 2020-06-30
73
96
 
@@ -78,20 +101,20 @@ Commit on drop of temporary tables added.
78
101
 
79
102
  * Add support for create, update, delete operations via user-exits on calculation views without input parameters.
80
103
  Work for both, calculation views without input parameters exposed as normal view and exposed as calcview.
81
-
104
+
82
105
  ## [7.0.1] - 2020-05-12
83
106
 
84
- * Add support for calculation views without input parameters.
85
- Before release 7.0.0 calcviews without input parameters have not been supported, but worked accidentally if a calcview
86
- was wrongly exposed as normal view. After the major release 7.0.0 this wrong exposure of a calcview resulted in an error.
107
+ * Add support for calculation views without input parameters.
108
+ Before release 7.0.0 calcviews without input parameters have not been supported, but worked accidentally if a calcview
109
+ was wrongly exposed as normal view. After the major release 7.0.0 this wrong exposure of a calcview resulted in an error.
87
110
  Because calcviews without input parameters are used more often, the support for this calcviews is now supported.
88
111
  You can either expose a calcview as normal view or as proper calcview, for the latter an input parameter entityset with
89
- parenthesis must be used.
112
+ parenthesis must be used.
90
113
 
91
114
  ## [7.0.0] - 2020-04-23
92
115
 
93
116
  * Add support for NodeJS version 12
94
- * Removed support for NodeJS version 6
117
+ * Removed support for NodeJS version 6
95
118
  * Fix bug when using a view with explicit key in combination with concurrency token using default properties for ETag.
96
119
  Now key properties are not considered for etag generation as written in the "SAP HANA Developer Guide":
97
120
  _If you specify concurrency token only, then all properties, except the key properties, are used to calculate
@@ -113,7 +136,7 @@ Requirements:
113
136
  * input parameters in the calculation view of type ALPHANUM, BLOB, DECIMAL, NVARCHAR, VARBINARY, VARCHAR must have length restriction
114
137
  * input parameters in the calculation view of type DECIMAL must have scale restriction
115
138
  * all key semantics also apply to keys coming from input parameters
116
- * **IMPORTANT** By default, now a maximum body size of "10mb" per request is allowed. More payload leads to an "413 Payload Too Large" error. This value of 10mb can be changed with the odata settings in the *.xsodata file
139
+ * **IMPORTANT** By default, now a maximum body size of "10mb" per request is allowed. More payload leads to an "413 Payload Too Large" error. This value of 10mb can be changed with the odata settings in the *.xsodata file
117
140
  [see **XSOdata Settings**](/documentation/xsodataSettings.md)
118
141
 
119
142
  ## [5.0.0] - 2019-12-17
@@ -123,21 +146,21 @@ Requirements:
123
146
  * Removed lock when opening a db connection
124
147
  The new native hana-client driver used by xsjs is thread save, so the lock for retrieving a new db connection is not required anymore.
125
148
  **IMPORTANT** If a custom open function is used, then this function must be reentrant or implement an own lock inside.
126
-
149
+
127
150
  ### Fixed
128
151
 
129
- * When using $count to determine the number of records of an entity set in junction with the limit feature, the
130
- returned number was also capped by the limit, this was wrong. Now the correct full number of records is returned.
152
+ * When using $count to determine the number of records of an entity set in junction with the limit feature, the
153
+ returned number was also capped by the limit, this was wrong. Now the correct full number of records is returned.
131
154
  * Fixed typeError if a stored procedure used as custom exit does not return a proper error structure.
132
-
155
+
133
156
  ## [4.7.0] - 2019-10-28
134
157
 
135
- ### Fixed
158
+ ### Fixed
136
159
 
137
160
  Fixed error causing duplicate properties and property references in the metadata document. Prerequisites:
138
161
  * The error occurs if an calculation view has been used as source for an entityset
139
162
  * This calculation view contains an input parameter which is used in more than one measures
140
- * Example: Input parameter "Input_Currency" (a calcview variable) is used in the currency conversion for the measures "VALUE" and "TAX"
163
+ * Example: Input parameter "Input_Currency" (a calcview variable) is used in the currency conversion for the measures "VALUE" and "TAX"
141
164
 
142
165
  ## [4.6.0] - 2019-10-11
143
166
 
@@ -180,8 +203,8 @@ Fixed error "Error while executing a DB query" when using an navigation property
180
203
 
181
204
  - Update module dependencies
182
205
  - The code field inside an OData error response (error.code) is now correctly send as string (not as number)
183
- - For calcviews the columns type length is determined from the COLUMN_SQL_TYPE if LENGTH is not set.
184
- - Fixed error while parsing multipart/mixed batch requests
206
+ - For calcviews the columns type length is determined from the COLUMN_SQL_TYPE if LENGTH is not set.
207
+ - Fixed error while parsing multipart/mixed batch requests
185
208
 
186
209
  ## [4.3.0] - 2018-10-19
187
210
 
@@ -189,12 +212,12 @@ Fixed error "Error while executing a DB query" when using an navigation property
189
212
 
190
213
  - Minimal required @sap/hana-client version is 2.3.123
191
214
  - Improved test exits
192
- - **IMPORTANT** Conversion: When converting TIMESTAMP db type to OData V2 json payload, only the first 3 digits
193
- of the fractional part are used (OData V2 type DateTime does only supports millisecond precision). With the old
194
- hdb db driver the xsodata library got already only millisecond precision, with the new hana-client db-driver the xsodata
195
- library itself has to remove any digits and use only the millisecond part. The check if the digits for micro- or nanoseconds
215
+ - **IMPORTANT** Conversion: When converting TIMESTAMP db type to OData V2 json payload, only the first 3 digits
216
+ of the fractional part are used (OData V2 type DateTime does only supports millisecond precision). With the old
217
+ hdb db driver the xsodata library got already only millisecond precision, with the new hana-client db-driver the xsodata
218
+ library itself has to remove any digits and use only the millisecond part. The check if the digits for micro- or nanoseconds
196
219
  are zero and throwing an error if not (added with release 4.0.0) has been removed due to backward compatibility reasons.
197
-
220
+
198
221
  ## [4.2.0] - 2018-09-18
199
222
 
200
223
  ### Changed
@@ -215,8 +238,8 @@ Fixed error "Error while executing a DB query" when using an navigation property
215
238
 
216
239
  ### Added
217
240
 
218
- - **IMPORTANT**|**INCOMPATIBLE** Added limit feature to restrict the amount of records loaded from the database.
219
- There are defaults for the limit values [see **XSOdata Settings**](/documentation/xsodataSettings.md) which need to
241
+ - **IMPORTANT**|**INCOMPATIBLE** Added limit feature to restrict the amount of records loaded from the database.
242
+ There are defaults for the limit values [see **XSOdata Settings**](/documentation/xsodataSettings.md) which need to
220
243
  be validated before using this version.
221
244
  - Support for hana-client database connector
222
245
  - **IMPORTANT**|**INCOMPATIBLE** Switched default database connector from hdb to hana-client
@@ -224,13 +247,13 @@ Fixed error "Error while executing a DB query" when using an navigation property
224
247
 
225
248
  ### Fixed
226
249
 
227
- - Use always the original DB property ordering when copying data into temporary tables for use
250
+ - Use always the original DB property ordering when copying data into temporary tables for use
228
251
  in exits in the insert and update steps.
229
-
252
+
230
253
 
231
254
  ## [3.7.0] - 2018-05-22
232
255
 
233
- ### Fixed
256
+ ### Fixed
234
257
 
235
258
  - Update dependencies
236
259
 
@@ -243,17 +266,17 @@ in exits in the insert and update steps.
243
266
 
244
267
  ## New features with xsodata 3.6.0:
245
268
 
246
- ### Fixed
269
+ ### Fixed
247
270
 
248
- - Extended DB-Version check to avoid unnecessary cleanup of temporary tables
249
- - Commands for cleanup of temporary tables don't stop the request processing if tables are truncated/dropped already
250
- - Fixed error which leads to an unclosed db connection. This error occurred only if
271
+ - Extended DB-Version check to avoid unnecessary cleanup of temporary tables
272
+ - Commands for cleanup of temporary tables don't stop the request processing if tables are truncated/dropped already
273
+ - Fixed error which leads to an unclosed db connection. This error occurred only if
251
274
  - the xsdata library is used without the xsjs layer (which is not recommended) and
252
275
  - the db connection information was provided via host, port, user,... to the OdataHandler
253
- - as request options for the processRequest method a string containing the uriPrefix is used
254
- (not an RequestOptions object).
276
+ - as request options for the processRequest method a string containing the uriPrefix is used
277
+ (not an RequestOptions object).
255
278
  - $batch processing is used
256
- - Fixed wrong decoding of OData strings of type Edm.String in $filter and $orderby expressions if the string contained
279
+ - Fixed wrong decoding of OData strings of type Edm.String in $filter and $orderby expressions if the string contained
257
280
  exactly one single quote (e.g. '''' have been decoded wrongly to Json "" not to the correct "'")
258
281
  - Parsing milliseconds for Edm.DateTime works now as expected for hana column type TIMESTAMP.
259
282
  Sample: HANA value "9999-12-31T23:59:59.99" is parsed now to have 990 ms instead of just 99ms
@@ -264,35 +287,35 @@ exactly one single quote (e.g. '''' have been decoded wrongly to Json "" not to
264
287
 
265
288
  ## New features with xsodata 3.5.0:
266
289
 
267
- ### Fixed
290
+ ### Fixed
268
291
 
269
292
  - Proper pattern escaping for substringof, startswith and endswith operations on $filter or $orderby.
270
293
  - Fixed SQL error when retrieving the row count of calculation views with transparent filters.
271
294
 
272
295
  ### Added:
273
296
 
274
- - Added new SQL error class to pass all errors related to DB query execution
297
+ - Added new SQL error class to pass all errors related to DB query execution
275
298
 
276
299
  ## New features with xsodata 3.4.0:
277
300
 
278
- ### Added:
301
+ ### Added:
279
302
 
280
303
  - Support for points "." in HANA table column names and consistently in OData property names.
281
- This feature has been added for backward compatibility reasons only. The OData V2 specification does not allow the usage
304
+ This feature has been added for backward compatibility reasons only. The OData V2 specification does not allow the usage
282
305
  of points for property names as points are used to separate namespace parts and names.
283
306
  So please consider not using it.
284
-
307
+
285
308
  ### Changed
286
-
309
+
287
310
  - Upgraded @sap/xssec and @sap/xsenv module dependencies
288
-
311
+
289
312
  ## New features with xsodata 3.3.0:
290
313
 
291
- ### Fixed:
314
+ ### Fixed:
292
315
 
293
316
  - Removed failing sql calls to cleanup temporary tables, which become unnecessary with db patch 2.00.030.00.1515544046.
294
317
  - Numbers of type Edm.Int64 must be represented as string (e.g. "123") in json format even if they are within in the range of JS Number.
295
-
318
+
296
319
  ## New features with xsodata 3.0.0:
297
320
 
298
321
  ### Added
@@ -300,7 +323,7 @@ exactly one single quote (e.g. '''' have been decoded wrongly to Json "" not to
300
323
  - Support Node.js 4.x.x, 6.x.x and newly 8.x.x
301
324
 
302
325
  ### Changed
303
-
326
+
304
327
  - Updated dependencies
305
328
  - Improved content id handling in batch requests
306
329
 
@@ -328,13 +351,13 @@ exactly one single quote (e.g. '''' have been decoded wrongly to Json "" not to
328
351
  - Rollback performed also for non batch modifications
329
352
 
330
353
  ### Changed
331
-
354
+
332
355
  - Updated dependencies
333
356
 
334
357
  ### Fixed
335
-
358
+
336
359
  - Fixed __metadata Uri in payload: name/value key pairs are now correct
337
-
360
+
338
361
  ## Modifications with SAP HANA XSA 2.0 SPS 2:
339
362
 
340
363
  ### Added
package/README.md CHANGED
@@ -14,6 +14,9 @@ Note: XSOData was developed to provide XS Classic users using XSOData the possib
14
14
  For node.js we also provide an OData V4 solution. The development of the OData V4 node.js Library already started in 2016.
15
15
  It is also planned that a generic CDS-Odata provider will be deliverd.
16
16
 
17
+ If you are developing an OData service for SAP Business Technology Platform, it is recommended to move to the SAP Cloud Application Programming Model (CP).
18
+ The XSODATA solution supports HANA as a service, but does **NOT** support SAP HANA Cloud Services (see also SAP note 3013788).
19
+
17
20
  ## Usage
18
21
 
19
22
  * This module is used in the XSJS shim for SAP HANA XSC Engine applications to
package/lib/db/connect.js CHANGED
@@ -238,10 +238,10 @@ function _connectInternal(context, asyncDone) {
238
238
  exports.connect = function (context, asyncDone) {
239
239
  context.db = context.db || {};
240
240
  if (context.db.client && (context.db.connectionInitialized === true)) {
241
- context.logger.debug('connect - db', 'connect already done');
241
+ context.logger.info('connect - db', 'connect already done');
242
242
  return asyncDone(null, context);
243
243
  }
244
- context.logger.debug('connect - db', 'connect');
244
+ context.logger.info('connect - db', 'connect');
245
245
 
246
246
  return _connectInternal(context, function (err) {
247
247
  if (err) {
@@ -268,7 +268,12 @@ exports.disconnect = function (context, cb) {
268
268
  if (context.db.openedConnection) {
269
269
  context.logger.info('connect - db', 'disconnect done');
270
270
  if (context.db.client) {
271
- context.db.client.end();
271
+ context.db.client.end((err) => {
272
+ if (err) {
273
+ context.logger.error('connect - db', `disconnect failed (callback): ${err}`);
274
+ }
275
+ context.logger.info('connect - db', 'disconnect done (callback)');
276
+ });
272
277
  }
273
278
  context.db.openedConnection = false;
274
279
  return cb();
@@ -247,7 +247,7 @@ DbSegment.prototype.setRecordFromPostPayload = function (context, record) {
247
247
  (modifyBy && key === 'MODIFIED_BY') ||
248
248
  (modifyAt && key === 'MODIFIED_AT'))
249
249
  ) {
250
- throw new BadRequest('The serialized resource has an missing value for member ' + key);
250
+ throw new BadRequest('The serialized resource has a missing value for member ' + key);
251
251
  }
252
252
  }
253
253
  dbValue = null;
@@ -336,7 +336,7 @@ DbSegment.prototype.setRecordFromPutPayload = function (context, record) {
336
336
  // skip optional calc view parameters
337
337
  (this.entityType.propertiesMap[property] && this.entityType.propertiesMap[property].MANDATORY === 0)
338
338
  )) {
339
- throw new BadRequest('The serialized resource has an missing value for member ' + property);
339
+ throw new BadRequest('The serialized resource has a missing value for member ' + property);
340
340
  }
341
341
 
342
342
  }
@@ -613,7 +613,7 @@ settingscontent = sl:( OWS settingsconfig OWS ";")*
613
613
  return ret;
614
614
  }
615
615
  settingsconfig = s:(settings_meta_cache / settings_content / settings_enable / settings_support /
616
- settings_hints / settings_admindata / settings_limits )
616
+ settings_hints / settings_admindata / settings_limits / settings_noDimensionAnnoOnTextProperty )
617
617
  { return s; }
618
618
  settings_meta_cache = "metadata" MWS ( "cache.control" / "cache-control") MWS qs:quotedstring
619
619
  { return {
@@ -635,6 +635,15 @@ settings_enable = "enable" MWS string
635
635
  { return { name : "enable", value : s }; }
636
636
  settings_support = "support" MWS s:string
637
637
  { return { name : "support", value : s }; }
638
+
639
+ settings_noDimensionAnnoOnTextProperty = "noDimensionAnnoOnTextProperty" MWS s:string
640
+ {
641
+ return {
642
+ name : "noDimensionAnnoOnTextProperty",
643
+ value : s
644
+ };
645
+ }
646
+
638
647
  settings_hints = "hints" MWS hl:("null" / hintlist)
639
648
  {
640
649
  var value = hl === 'null' ? [] : hl
@@ -120,6 +120,9 @@ function setPropertyAggregationRole(entityType, property, propertyAnnotations) {
120
120
  (entityType.kind !== EntityType.entityKind.inputParameters &&
121
121
  (entityType.hasAggregates() || entityType.hasMeasureProperties())
122
122
  ) && entityType.isInBimcDimensionView(property.COLUMN_NAME)) {
123
+ if (property.suppressAnnotationDimension && property.suppressAnnotationDimension === true) {
124
+ return; // property is used as description text for other property: do not add annotation
125
+ }
123
126
  propertyAnnotations["sap:aggregation-role"] = "dimension";
124
127
  }
125
128
  }
@@ -189,6 +189,19 @@ function loadCalcViewInfo(context, entityType, cb) {
189
189
  entityType.setCalculationViewDimensionData(rows, { cube: cubeName }, context.logger); // e.g. sap:label is fill with calculation view dimension data
190
190
  entityType.resolveAggregates();
191
191
 
192
+ entityType.properties.forEach((property) => {
193
+
194
+ // suppressing annotation "sap:aggregation-role" depends on xsodata-file "setting"
195
+ if (entityType._settings.noDimensionAnnoOnTextProperty && entityType._settings.noDimensionAnnoOnTextProperty === 'true') {
196
+ if (property.DESC_NAME && property.DESC_NAME !== property.COLUMN_NAME) {
197
+ for (let i = 0; i < entityType.properties.length; i++) {
198
+ if (entityType.properties[i].COLUMN_NAME === property.DESC_NAME) {
199
+ entityType.properties[i].suppressAnnotationDimension = true;
200
+ }
201
+ }
202
+ }
203
+ }
204
+ });
192
205
 
193
206
  var parameters = entityType.getParameters();
194
207
  if (!parameters) {
@@ -292,10 +305,13 @@ function _getLength(columnSqlType) {
292
305
  exports._getLength = _getLength;
293
306
 
294
307
  function _getType(type, defaultType = null) {
308
+
295
309
  if (type) {
296
310
  const i = type.indexOf('(');
297
311
  if (i > -1) {
298
312
  return type.substr(0, i);
313
+ } else {
314
+ return type;
299
315
  }
300
316
  }
301
317
 
@@ -241,7 +241,7 @@ parse: function parse(input) {
241
241
  }
242
242
  action = table[state] && table[state][symbol];
243
243
  }
244
- if (typeof action === 'undefined' || !action.length || !action[0]) {
244
+ if (typeof action === 'undefined' || !action.length || !action[0]) {
245
245
  var errStr = '';
246
246
  expected = [];
247
247
  for (p in table[state]) {