@sap/xsodata 8.3.0 → 8.3.1

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.
Files changed (120) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/index.js +2 -2
  3. package/lib/configuration.js +1 -1
  4. package/lib/db/connect.js +1 -1
  5. package/lib/db/dbSegment.js +68 -123
  6. package/lib/db/dbVersionChecks.js +2 -8
  7. package/lib/handlerConfiguration.js +2 -2
  8. package/lib/http/conditionalHttpHandler.js +27 -34
  9. package/lib/http/simpleHttpRequest.js +14 -18
  10. package/lib/http/simpleHttpResponse.js +4 -4
  11. package/lib/http/uriParser.js +9 -9
  12. package/lib/http/validator/httpRequestValidator.js +9 -9
  13. package/lib/model/annotationFactory.js +11 -11
  14. package/lib/model/association.js +3 -3
  15. package/lib/model/entityType.js +33 -67
  16. package/lib/model/metadataReader.js +31 -52
  17. package/lib/model/model.js +0 -1
  18. package/lib/model/validator/xsoDataConcurrencyTokenValidator.js +6 -6
  19. package/lib/model/xsodataReader.js +36 -28
  20. package/lib/processor/authorizationProcessor.js +22 -33
  21. package/lib/processor/batchProcessor.js +22 -33
  22. package/lib/processor/errorProcessor.js +4 -4
  23. package/lib/processor/exitProcessor.js +19 -19
  24. package/lib/processor/processor.js +9 -9
  25. package/lib/processor/resourceProcessor.js +31 -61
  26. package/lib/processor/resourceProcessorDelete.js +16 -16
  27. package/lib/processor/resourceProcessorDeleteLinks.js +25 -25
  28. package/lib/processor/resourceProcessorGet.js +5 -5
  29. package/lib/processor/resourceProcessorPost.js +43 -45
  30. package/lib/processor/resourceProcessorPut.js +35 -39
  31. package/lib/processor/resourceProcessorPutPostLinks.js +38 -39
  32. package/lib/security/securityContext.js +5 -5
  33. package/lib/serializer/atomSerializer.js +54 -55
  34. package/lib/serializer/atomXmlToJsonSerializer.js +32 -44
  35. package/lib/serializer/content.js +5 -5
  36. package/lib/serializer/json.js +31 -33
  37. package/lib/serializer/jsonSerializer.js +4 -4
  38. package/lib/serializer/metadataSerializer.js +32 -35
  39. package/lib/serializer/serializer.js +29 -43
  40. package/lib/serializer/serviceSerializer.js +19 -24
  41. package/lib/serializer/value.js +1 -2
  42. package/lib/serializer/xmlToJsonSerializer.js +18 -18
  43. package/lib/sql/createDeleteLinksStatements.js +10 -10
  44. package/lib/sql/createDeleteStatements.js +12 -12
  45. package/lib/sql/createGetStatements.js +49 -107
  46. package/lib/sql/createLinksSQLStatements_1_n.js +27 -27
  47. package/lib/sql/createPutPostLinksStatements.js +9 -9
  48. package/lib/sql/createPutStatements.js +0 -1
  49. package/lib/sql/dataCollectorDelete.js +9 -9
  50. package/lib/sql/dataCollectorDeleteLinks.js +3 -3
  51. package/lib/sql/dataCollectorGet.js +9 -17
  52. package/lib/sql/dataCollectorLinks.js +23 -27
  53. package/lib/sql/dataCollectorPost.js +20 -20
  54. package/lib/sql/dataCollectorPut.js +36 -36
  55. package/lib/sql/dataCollectorPutPostLinks.js +3 -3
  56. package/lib/sql/sqlStatement.js +81 -128
  57. package/lib/sql/sqlTools.js +3 -7
  58. package/lib/sql/statementProcessor.js +7 -14
  59. package/lib/uri/applyChecks.js +3 -3
  60. package/lib/uri/checks/checkAllowedMethod.js +3 -3
  61. package/lib/uri/checks/checkAllowedMethodForBatch.js +2 -2
  62. package/lib/uri/checks/checkAllowedMethodsForResourcePath.js +3 -3
  63. package/lib/uri/checks/checkFilterOnAggregatedColumn.js +5 -5
  64. package/lib/uri/checks/checkFilterOrderByOnGenKeyColumn.js +6 -6
  65. package/lib/uri/checks/checkGenKeyRestrictions.js +2 -2
  66. package/lib/uri/checks/checkModificationForbidden.js +3 -3
  67. package/lib/uri/checks/checkPostPutDeleteChecks.js +5 -5
  68. package/lib/uri/checks/checkSystemQueryOptions.js +10 -10
  69. package/lib/uri/checks.js +15 -15
  70. package/lib/uri/expandSelectTreeBuilder.js +12 -16
  71. package/lib/uri/oDataUriParser.js +20 -20
  72. package/lib/uri/queryParameterParser.js +25 -33
  73. package/lib/uri/resourcePathParser.js +47 -62
  74. package/lib/uri/uriType.js +4 -4
  75. package/lib/utils/associations.js +4 -4
  76. package/lib/utils/batch/batchExecutor.js +49 -51
  77. package/lib/utils/batch/batchObjects.js +10 -10
  78. package/lib/utils/batch/batchParser.js +27 -28
  79. package/lib/utils/batch/batchWriter.js +1 -1
  80. package/lib/utils/checkContentType.js +34 -39
  81. package/lib/utils/debugView.js +35 -36
  82. package/lib/utils/errors/applicationError.js +2 -2
  83. package/lib/utils/errors/debugInfo.js +2 -2
  84. package/lib/utils/errors/http/badRequest.js +2 -2
  85. package/lib/utils/errors/http/forbidden.js +2 -2
  86. package/lib/utils/errors/http/methodNotAllowed.js +2 -2
  87. package/lib/utils/errors/http/notAcceptable.js +2 -2
  88. package/lib/utils/errors/http/notFound.js +2 -2
  89. package/lib/utils/errors/http/notImplemented.js +2 -2
  90. package/lib/utils/errors/http/notModified.js +2 -2
  91. package/lib/utils/errors/http/notSupported.js +2 -2
  92. package/lib/utils/errors/http/preconditionFailed.js +2 -2
  93. package/lib/utils/errors/http/preconditionRequired.js +2 -2
  94. package/lib/utils/errors/http/unauthorized.js +2 -2
  95. package/lib/utils/errors/http/unsupportedMediaType.js +2 -2
  96. package/lib/utils/errors/httpError.js +2 -2
  97. package/lib/utils/errors/internalError.js +2 -2
  98. package/lib/utils/errors/modelFileError.js +2 -2
  99. package/lib/utils/errors/sqlError.js +2 -2
  100. package/lib/utils/errors/testError.js +2 -2
  101. package/lib/utils/errors/typeError.js +5 -5
  102. package/lib/utils/errors/xsODataError.js +1 -1
  103. package/lib/utils/logger.js +21 -32
  104. package/lib/utils/measurement.js +14 -13
  105. package/lib/utils/requestContext.js +2 -2
  106. package/lib/utils/stateMaschine.js +6 -6
  107. package/lib/utils/tableCleanup.js +3 -3
  108. package/lib/utils/typeConverter.js +21 -21
  109. package/lib/utils/typeConverters/converterTools.js +25 -331
  110. package/lib/utils/typeConverters/dbToJson.js +3 -3
  111. package/lib/utils/typeConverters/dbToUri.js +7 -7
  112. package/lib/utils/typeConverters/dbToXml.js +9 -9
  113. package/lib/utils/typeConverters/jsonToDb.js +20 -27
  114. package/lib/utils/typeConverters/uriToDb.js +45 -92
  115. package/lib/utils/typeConverters/xmlValueToJson.js +9 -13
  116. package/lib/utils/typedObjects.js +11 -79
  117. package/lib/utils/utils.js +20 -23
  118. package/lib/xsodata.js +37 -47
  119. package/package.json +3 -5
  120. package/.npmignore +0 -40
@@ -16,15 +16,15 @@ EntityType.entityKind = {
16
16
  module.exports = EntityType;
17
17
 
18
18
 
19
- var utils = require('./../utils/utils');
20
- var generatedKey = require('../utils/keyGenerator');
21
- var typeConverter = require('./../utils/typeConverter');
22
- var concurrencyTokenValidator = require('./../model/validator/xsoDataConcurrencyTokenValidator');
23
- var annotationFactory = require('./annotationFactory');
24
- var util = require('util');
19
+ const utils = require('./../utils/utils');
20
+ const generatedKey = require('../utils/keyGenerator');
21
+ const typeConverter = require('./../utils/typeConverter');
22
+ const concurrencyTokenValidator = require('./../model/validator/xsoDataConcurrencyTokenValidator');
23
+ const annotationFactory = require('./annotationFactory');
24
+ const util = require('util');
25
25
 
26
26
  // see https://help.sap.com/viewer/88fe5f56472e40cca6ef3c3dcab4855b/2.0.05/en-US/d336ea064c0948ffa3ef84dd516d69af.html
27
- var CV_AGGREGATE_FUNCTIONS = {
27
+ const CV_AGGREGATE_FUNCTIONS = {
28
28
  1: "sum",
29
29
  2: "count", // was avg before that was a bug
30
30
  3: "min",
@@ -141,21 +141,7 @@ function prepareAdmindata(settingsAdmindata, entityTypeAdmindata) {
141
141
  return ret;
142
142
  }
143
143
 
144
- /*
145
- EntityType.prototype.getName = function () {
146
- return this.name;
147
- };*/
148
-
149
144
  EntityType.prototype.getUriName = function () {
150
- /*
151
- if (this._entityType.parameters) {
152
- if (this._entityType.parameters.entity) {
153
- return this._entityType.parameters.entity;
154
- } else {
155
- return this.name + 'Parameters';
156
- }
157
-
158
- }*/
159
145
  return this.name;
160
146
  };
161
147
 
@@ -229,7 +215,7 @@ EntityType.prototype.getNavigation = function (propertyName) {
229
215
  };
230
216
 
231
217
  function determineKeys(entityType) {
232
- var keys = {
218
+ const keys = {
233
219
  names: entityType.keys || []
234
220
  };
235
221
 
@@ -267,8 +253,7 @@ EntityType.prototype.calcKeyNamesOrdered = function () {
267
253
  return;
268
254
  }
269
255
 
270
- for (var i = 0; i < this.propertyNames.length; i++) {
271
- var propertyName = this.propertyNames[i];
256
+ for (const propertyName of this.propertyNames) {
272
257
  if (this.keys.names.indexOf(propertyName) > -1) {
273
258
  this.keyNamesOrdered.push(propertyName);
274
259
  }
@@ -284,7 +269,7 @@ EntityType.prototype.init = function (metadata, kind, tableStoreType, logger) {
284
269
  this.kind = kind;
285
270
 
286
271
  this.isInitialised = true;
287
- var i;
272
+ let i;
288
273
 
289
274
  /**
290
275
  * List of this entities property names (according to with and without filter)
@@ -324,11 +309,11 @@ EntityType.prototype.init = function (metadata, kind, tableStoreType, logger) {
324
309
  this.converterMapToXMLPayload = {};
325
310
 
326
311
 
327
- var dbColumns;
312
+ let dbColumns;
328
313
 
329
314
  //fill propertyNames
330
- var propertyName;
331
- var withh = this._entityType.properties.with;
315
+ let propertyName;
316
+ const withh = this._entityType.properties.with;
332
317
  if (withh) {
333
318
  dbColumns = this.__metadata.getColumnsMap();
334
319
  for (i = 0; i < withh.length; i++) {
@@ -339,15 +324,15 @@ EntityType.prototype.init = function (metadata, kind, tableStoreType, logger) {
339
324
  this.propertiesMap[propertyName] = dbColumns[propertyName];
340
325
  } else {
341
326
  logger.error('Unknown property: ' + propertyName);
342
- throw('Unknown property');
327
+ throw(new Error('Unknown property'));
343
328
  }
344
329
  }
345
330
  } else {
346
331
  dbColumns = this.__metadata.getColumns();
347
- var without = this._entityType.properties.without;
332
+ const without = this._entityType.properties.without;
348
333
  //Loop over all existing columns
349
334
  for (i = 0; i < dbColumns.length; i++) {
350
- var column = dbColumns[i];
335
+ const column = dbColumns[i];
351
336
 
352
337
  if (without && without.indexOf(column.COLUMN_NAME) > -1) {
353
338
  continue;
@@ -363,8 +348,8 @@ EntityType.prototype.init = function (metadata, kind, tableStoreType, logger) {
363
348
  this.resolveAggregates();
364
349
 
365
350
  //
366
- var navigates = this._entityType.navigates;
367
- for (var navName in navigates) {
351
+ const navigates = this._entityType.navigates;
352
+ for (const navName in navigates) {
368
353
  if (navigates.hasOwnProperty(navName)) {
369
354
  this.navPropertyNames.push(navName);
370
355
  this.navProperties.push(navigates[navName]);
@@ -394,7 +379,7 @@ EntityType.prototype.addProperty = function (colProperty, isKey) {
394
379
  this.propertiesMap[colProperty.COLUMN_NAME] = colProperty;
395
380
  this._addConverter(colProperty);
396
381
  if (isKey) {
397
- var keys = this.keys || {};
382
+ const keys = this.keys || {};
398
383
  keys.names.unshift(colProperty.COLUMN_NAME);
399
384
  this.calcKeyNamesOrdered();
400
385
  }
@@ -403,7 +388,7 @@ EntityType.prototype.addProperty = function (colProperty, isKey) {
403
388
  EntityType.prototype.resolveAggregates = function () {
404
389
  this._aggregates = this._entityType.aggregates;
405
390
  if (this._aggregates && !Array.isArray(this._aggregates)) {
406
- var _aggr_props = this.properties.filter(function (p) {
391
+ const _aggr_props = this.properties.filter(function (p) {
407
392
  return !!p.aggregate;
408
393
  });
409
394
  this._aggregates = _aggr_props.map(function (p) {
@@ -421,16 +406,15 @@ EntityType.prototype.setCalculationViewDimensionData = function (rows, calcView,
421
406
 
422
407
  this.calcView = calcView;
423
408
 
424
- //var cv_properties = [];
425
- var cv_propertiesMap = {};
426
- var new_propertiesMap = {};
409
+ const cv_propertiesMap = {};
410
+ const new_propertiesMap = {};
427
411
 
428
412
  rows.forEach(function (row) {
429
413
  cv_propertiesMap[row.COLUMN_NAME] = row;
430
414
  });
431
415
 
432
416
  this.properties.forEach(function (p) {
433
- var cvp = cv_propertiesMap[p.COLUMN_NAME];
417
+ const cvp = cv_propertiesMap[p.COLUMN_NAME];
434
418
 
435
419
  p.KIND = EntityType.entityKind.calculationView;
436
420
  new_propertiesMap[p.COLUMN_NAME] = p;
@@ -447,19 +431,6 @@ EntityType.prototype.setCalculationViewDimensionData = function (rows, calcView,
447
431
  }
448
432
  });
449
433
 
450
- /*
451
- rows.forEach(function (row) {
452
- var property = self.propertiesMap[row.COLUMN_NAME];
453
- if (!property) {
454
- return;
455
- }
456
- property.aggregate = row.MEASURE_AGGREGATOR ? CV_AGGREGATE_FUNCTIONS[row.MEASURE_AGGREGATOR] : null;
457
- property.KIND = EntityType.entityKind.calculationView;
458
- cv_properties.push(property);
459
- cv_propertiesMap[row.COLUMN_NAME] = property;
460
- });
461
- */
462
-
463
434
  this.propertiesMap = new_propertiesMap;
464
435
  };
465
436
 
@@ -471,20 +442,15 @@ EntityType.prototype.getParameters = function () {
471
442
  return this._entityType.parameters;
472
443
  };
473
444
 
474
- /*
475
- EntityType.prototype.getPropertyNames = function () {
476
- return this.propertyNames;
477
- };*/
478
-
479
445
  EntityType.prototype._addGenKeyConverter = function () {
480
- var genKey = this.keys.generatedKey;
446
+ const genKey = this.keys.generatedKey;
481
447
  if (genKey) {
482
448
  this._addConverter(generatedKey.createGenKeyProperty(genKey));
483
449
  }
484
450
  };
485
451
 
486
452
  EntityType.prototype.getKeysOrGenKey = function () {
487
- var genKey = this.keys.generatedKey;
453
+ const genKey = this.keys.generatedKey;
488
454
  if (genKey) {
489
455
  return [genKey];
490
456
  }
@@ -493,8 +459,8 @@ EntityType.prototype.getKeysOrGenKey = function () {
493
459
  };
494
460
 
495
461
  EntityType.prototype.getPropertiesWithGenKey = function getPropertiesWithGenKey() {
496
- var genKey = this.keys.generatedKey;
497
- var properties = this.properties;
462
+ const genKey = this.keys.generatedKey;
463
+ let properties = this.properties;
498
464
 
499
465
  if (genKey) {
500
466
  properties = [generatedKey.createGenKeyProperty(genKey)].concat(properties);
@@ -553,7 +519,7 @@ EntityType.prototype.getEntitySetAnnotations = function getEntitySetAnnotations(
553
519
  * }
554
520
  */
555
521
  EntityType.prototype.getPropertyAnnotations = function getPropertyAnnotations(propertyName) {
556
- var property = this.getProperty(propertyName);
522
+ const property = this.getProperty(propertyName);
557
523
 
558
524
  if (!property._annotations) {
559
525
  property._annotations = annotationFactory.createPropertyAnnotations(this, property);
@@ -574,7 +540,7 @@ EntityType.prototype.getPropertyAnnotations = function getPropertyAnnotations(pr
574
540
  * }
575
541
  */
576
542
  EntityType.prototype.getNavigationPropertyAnnotations = function getNavigationPropertyAnnotations(navPropertyName) {
577
- var navProperty = this.getNavigation(navPropertyName);
543
+ const navProperty = this.getNavigation(navPropertyName);
578
544
 
579
545
  if (!navProperty._annotations) {
580
546
  navProperty._annotations = annotationFactory.createNavigationPropertyAnnotations();
@@ -607,7 +573,7 @@ EntityType.prototype.getNavigationPropertyAnnotations = function getNavigationPr
607
573
  * @throws {Error} if propertyName is empty or there is no property with the specified name in the entity type
608
574
  */
609
575
  EntityType.prototype.getProperty = function getProperty(propertyName) {
610
- var property;
576
+ let property;
611
577
 
612
578
  if (!propertyName) {
613
579
  throw new Error("Property name must be specified");
@@ -635,7 +601,7 @@ EntityType.prototype.getProperty = function getProperty(propertyName) {
635
601
  * @returns {boolean} If the property has attr. DIMENSION_TYPE with is set if there is an entry in BIMC_DIMENSION_VIEW
636
602
  */
637
603
  EntityType.prototype.isInBimcDimensionView = function isInBimcDimensionView(propertyName) {
638
- var property = this.getProperty(propertyName);
604
+ const property = this.getProperty(propertyName);
639
605
  if (!property) {
640
606
  return false;
641
607
  }
@@ -651,7 +617,7 @@ EntityType.prototype.isInBimcDimensionView = function isInBimcDimensionView(prop
651
617
  * @returns {boolean} <code>true<code/> if the property is an aggregate property; otherwise - <code>false<code/>.
652
618
  */
653
619
  EntityType.prototype.isAggregateProperty = function isAggregateProperty(propertyName) {
654
- var property = this.getProperty(propertyName),
620
+ let property = this.getProperty(propertyName),
655
621
  aggregates,
656
622
  aggregate,
657
623
  i;
@@ -692,7 +658,7 @@ function isMeasureProperty(property) {
692
658
  * @returns {boolean} <code>true<code/> if the entity type has measure properties; otherwise - <code>false<code/>.
693
659
  */
694
660
  EntityType.prototype.hasMeasureProperties = function hasMeasureProperties() {
695
- var i,
661
+ let i,
696
662
  property;
697
663
 
698
664
  // only calculation views can have measure properties
@@ -25,7 +25,7 @@ const dataCollector2 = require('./../sql/dataCollector2');
25
25
  function loadKeysForTable(context, entityType, cb) {
26
26
  context.logger.silly('model', 'loadKeysForTable for entity ' + entityType.name);
27
27
 
28
- var processRows = function (err, rows) {
28
+ const processRows = function (err, rows) {
29
29
  if (logMetadata) {
30
30
  context.logger.silly('model', 'rows\n' + JSON.stringify(rows, null, 4));
31
31
  }
@@ -60,7 +60,7 @@ function loadKeysForTable(context, entityType, cb) {
60
60
  function loadTableInfo(context, entityType, tableStoreType, cb) {
61
61
  context.logger.silly("model", "loadTableInfo");
62
62
 
63
- var processRows = function (err, rows) {
63
+ const processRows = function (err, rows) {
64
64
  try {
65
65
  if (logMetadata) {
66
66
  context.logger.silly('model', 'rows\n' + JSON.stringify(rows, null, 4));
@@ -83,15 +83,15 @@ function loadTableInfo(context, entityType, tableStoreType, cb) {
83
83
  return loadKeysForTable(context, entityType, cb);
84
84
  }
85
85
  } else {
86
- var genKey = entityType.keys.generatedKey;
86
+ const genKey = entityType.keys.generatedKey;
87
87
  if (!genKey && entityType.keys.names.length === 0) {
88
88
  return cb(new InternalError("Missing specification of keys for view.", context, null), context);
89
89
  } else {
90
90
  if (genKey) {
91
- var overwrittenColumn = entityType.propertiesMap[entityType.keys.generatedKey];
91
+ const overwrittenColumn = entityType.propertiesMap[entityType.keys.generatedKey];
92
92
  if (!!overwrittenColumn) {
93
93
  // Provided generated key overwrites an existing column
94
- var msg = "Invalid generated key property '" + genKey + "'";
94
+ let msg = "Invalid generated key property '" + genKey + "'";
95
95
  msg += " in definition '" + overwrittenColumn.TABLE_NAME + "'.";
96
96
  msg += " The generated key would overwrite an existing property";
97
97
  return cb(
@@ -179,7 +179,7 @@ function loadCalcViewInfo(context, entityType, cb) {
179
179
  "where SCHEMA_NAME = ? AND QUALIFIED_NAME = ? " +
180
180
  'order by "ORDER"';
181
181
 
182
- function processRows(err, rows) {
182
+ const processRows = function (err, rows) {
183
183
  if (logMetadata) {
184
184
  context.logger.silly('metadataReader', 'rows\n' + JSON.stringify(rows, null, 4));
185
185
  }
@@ -192,7 +192,7 @@ function loadCalcViewInfo(context, entityType, cb) {
192
192
  return cb(null, null);
193
193
  }
194
194
 
195
- var cubeName = rows[0].CUBE_NAME;
195
+ const cubeName = rows[0].CUBE_NAME;
196
196
 
197
197
  entityType.setCalculationViewDimensionData(rows, { cube: cubeName }, context.logger); // e.g. sap:label is fill with calculation view dimension data
198
198
  entityType.resolveAggregates();
@@ -202,16 +202,16 @@ function loadCalcViewInfo(context, entityType, cb) {
202
202
  // suppressing annotation "sap:aggregation-role" depends on xsodata-file "setting"
203
203
  if (entityType._settings.noDimensionAnnoOnTextProperty && entityType._settings.noDimensionAnnoOnTextProperty === 'true') {
204
204
  if (property.DESC_NAME && property.DESC_NAME !== property.COLUMN_NAME) {
205
- for (let i = 0; i < entityType.properties.length; i++) {
206
- if (entityType.properties[i].COLUMN_NAME === property.DESC_NAME) {
207
- entityType.properties[i].suppressAnnotationDimension = true;
205
+ for (const entityProperty of entityType.properties) {
206
+ if (entityProperty.COLUMN_NAME === property.DESC_NAME) {
207
+ entityProperty.suppressAnnotationDimension = true;
208
208
  }
209
209
  }
210
210
  }
211
211
  }
212
212
  });
213
213
 
214
- var parameters = entityType.getParameters();
214
+ const parameters = entityType.getParameters();
215
215
  if (!parameters) {
216
216
  // entity not exposed as calcview
217
217
  return cb(null, entityType);
@@ -225,8 +225,7 @@ function loadCalcViewInfo(context, entityType, cb) {
225
225
  }
226
226
  return cb(null, entityType);
227
227
  });
228
-
229
- }
228
+ };
230
229
 
231
230
  /*
232
231
  Example mapping :
@@ -296,10 +295,10 @@ function loadInputParameters(parameters, entityType, context, cb) {
296
295
  });
297
296
 
298
297
  try {
299
- var paramEntityType = loadInputParametersEntity(parameters, entityType, context, rows);
298
+ const paramEntityType = loadInputParametersEntity(parameters, entityType, context, rows);
300
299
  if (parameters.viaKey) {
301
300
  /*this is called */
302
- loadInputParametersViaKey(entityType, paramEntityType, context);
301
+ loadInputParametersViaKey(entityType, paramEntityType);
303
302
  }
304
303
  } catch (err_process) {
305
304
  err = err_process;
@@ -312,7 +311,7 @@ function loadInputParameters(parameters, entityType, context, cb) {
312
311
 
313
312
 
314
313
  function _getLength(columnSqlType) {
315
- const n = columnSqlType.match(/^\w+\(([0-9]+)\)$/);
314
+ const n = columnSqlType.match(/^\w+\((\d+)\)$/);
316
315
  if (n) {
317
316
  return Number.parseInt(n[1]);
318
317
  }
@@ -338,37 +337,17 @@ function _getType(type, defaultType = null) {
338
337
 
339
338
  exports._getType = _getType;
340
339
 
341
- /*
342
- function _getTypeLengthScale(type, defaultType = null) {
343
- if (type) {
344
- const n = type.match(/^(\w+)(\(([0-9]+)(,([0-9]+))?\))?$/);
345
- if (n) {
346
- return {
347
- type: n[1],
348
- length: Number.parseInt(n[3]) || null,
349
- scale : Number.parseInt(n[5]) || null
350
- };
351
- }
352
- }
353
- return {
354
- type: defaultType|| 'NVARCHAR',
355
- length: null,
356
- scale: null
357
- };
358
- }
359
- */
360
-
361
340
  function loadInputParametersEntity(parameters, entityType, context, rows) {
362
- var paramEntityName = parameters.entity;
341
+ let paramEntityName = parameters.entity;
363
342
  if (!paramEntityName || paramEntityName.trim() === '') {
364
343
  //No name, use default naming
365
344
  paramEntityName = entityType.name + 'Parameters';
366
345
  }
367
346
 
368
- var resultsProp = parameters.resultProperty || 'Results';
369
- var assocName = paramEntityName + '_to_' + entityType.name;
347
+ const resultsProp = parameters.resultProperty || 'Results';
348
+ let assocName = paramEntityName + '_to_' + entityType.name;
370
349
 
371
- var _et = {
350
+ const _et = {
372
351
  name: paramEntityName,
373
352
  properties: {},
374
353
  navigates: {},
@@ -385,10 +364,9 @@ function loadInputParametersEntity(parameters, entityType, context, rows) {
385
364
  }
386
365
  };
387
366
 
388
- var paramEntityType = new EntityType(_et);
367
+ const paramEntityType = new EntityType(_et);
389
368
 
390
- var mrows = rows.map(function (row) {
391
- //const typeLengthScale = _getTypeLengthScale(row.COLUMN_SQL_TYPE, row.COLUMN_TYPE_D );
369
+ const mrows = rows.map(function (row) {
392
370
  const type = _getType(row.COLUMN_SQL_TYPE, row.COLUMN_TYPE_D);
393
371
  const metadata = {
394
372
  KIND: model.entityKind.inputParameters,
@@ -410,7 +388,7 @@ function loadInputParametersEntity(parameters, entityType, context, rows) {
410
388
  });
411
389
 
412
390
  assocName = paramEntityName + '_to_' + entityType.name;
413
- var association = new Association({
391
+ const association = new Association({
414
392
  name: assocName,
415
393
  principal: {
416
394
  type: paramEntityName,
@@ -434,7 +412,7 @@ function loadInputParametersEntity(parameters, entityType, context, rows) {
434
412
 
435
413
 
436
414
  function loadInputParametersViaKey(entityType, paramEntityType) {
437
- var pvalues = _.values(paramEntityType.propertiesMap);
415
+ const pvalues = _.values(paramEntityType.propertiesMap);
438
416
  pvalues.forEach(function (pv) {
439
417
  entityType.addProperty(pv, true);
440
418
  });
@@ -611,7 +589,7 @@ function processSynonymTableType(context, entityType, tableName, callback) {
611
589
  * @param {Function} callback - callback function, which is called when the operation is completed.
612
590
  */
613
591
  function processTableType(error, dbRows, context, tableName, callback) {
614
- var isColumnStoreType,
592
+ let isColumnStoreType,
615
593
  tableStoreType;
616
594
 
617
595
  if (error) {
@@ -642,7 +620,7 @@ function createLockeEntityID(context, entityType) {
642
620
 
643
621
 
644
622
  function loadEntityTypeOnce(context, entityType, cbErr) {
645
- var lockEntityID = createLockeEntityID(context, entityType);
623
+ const lockEntityID = createLockeEntityID(context, entityType);
646
624
 
647
625
  if (entityType.isInitialised) {
648
626
  //access to __metadata is writelooked, so __metadata is definitively filled here
@@ -660,7 +638,7 @@ function loadEntityTypeOnce(context, entityType, cbErr) {
660
638
  return cbErr();
661
639
  }
662
640
 
663
- var load = function (err, context) {
641
+ const load = function (err, context) {
664
642
  if (err) {
665
643
  release();
666
644
  return cbErr(err);
@@ -673,7 +651,7 @@ function loadEntityTypeOnce(context, entityType, cbErr) {
673
651
  };
674
652
  try {
675
653
  if (Measurement.isActive()) {
676
- var callConnect = utils.tryAndMeasure(db.connect, 'dbConnect');
654
+ const callConnect = utils.tryAndMeasure(db.connect, 'dbConnect');
677
655
  return callConnect(context, load);
678
656
  } else {
679
657
  return db.connect(context, load);
@@ -689,16 +667,17 @@ exports.loadModelMetadata = function (context, asyncDone) {
689
667
 
690
668
  context.logger.silly('model', 'load metadata');
691
669
 
692
- var entityTypes = context.gModel.getEntityTypes();
670
+ const entityTypes = context.gModel.getEntityTypes();
671
+ let parent;
693
672
 
694
673
  if (Measurement.isActive()) { // perform an explicit measurement
695
- var parent = Measurement.getRunningMeasurement();
674
+ parent = Measurement.getRunningMeasurement();
696
675
  }
697
676
 
698
677
  async.mapSeries(
699
678
  entityTypes,
700
679
  function (entityType, cbMapLimit) {
701
- var child;
680
+ let child;
702
681
  try {
703
682
  if (Measurement.isActive() && !context.batchContext) {
704
683
  child = parent.newChild(entityType.name);
@@ -36,7 +36,6 @@ let Model = function Model(xsodata) {
36
36
  this._entityTypesMap = {};
37
37
  this._entityTypesMapUriId = {};
38
38
 
39
- //var entityTypeName = '';
40
39
  for (property in this._service.entityTypes) {
41
40
  if (this._service.entityTypes.hasOwnProperty(property)) {
42
41
  let entityType = new EntityType(this._service.entityTypes[property], this._settings);
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var lodash = require('lodash');
3
+ const lodash = require('lodash');
4
4
 
5
5
  /**
6
6
  * Exports the api
@@ -21,7 +21,7 @@ module.exports = {
21
21
  */
22
22
  function validate(context, callback) {
23
23
 
24
- var entityTypes = context.gModel._entityTypesMap;
24
+ const entityTypes = context.gModel._entityTypesMap;
25
25
 
26
26
  try {
27
27
  validateDefaults(entityTypes);
@@ -88,7 +88,7 @@ function validateHasNotKeyPropertyTokenKey(entityTypes) {
88
88
 
89
89
  findConcurrencyTokenConflicts(entityTypes, "keys.names", function (entityType, intersection) {
90
90
 
91
- var isInvalidKey = entityType.hasConcurrentProperties() &&
91
+ const isInvalidKey = entityType.hasConcurrentProperties() &&
92
92
  entityType.isConcurrentProperty(entityType.keys.generatedKey);
93
93
 
94
94
  if (isInvalidKey) {
@@ -120,9 +120,9 @@ function findConcurrencyTokenConflicts(entityTypes, comparableChildPropertyPath,
120
120
 
121
121
  return lodash.chain(entityTypes)
122
122
  .reduce(function (result, entityType) {
123
- var comparableKeys;
124
- var intersection;
125
- var tokenKeys;
123
+ let comparableKeys;
124
+ let intersection;
125
+ let tokenKeys;
126
126
 
127
127
  comparableKeys = lodash.chain(entityType).get(comparableChildPropertyPath).value();
128
128
  if (comparableKeys && !Array.isArray(comparableKeys)) {