@sap/xsodata 8.2.1 → 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 +10 -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 +9 -6
  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 +9 -11
  120. package/.npmignore +0 -40
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var edm = require('./../utils/typedObjects');
4
- var cloneContextWithNoAlias = edm.cloneContextWithNoAlias;
5
- var InternalError = require('./../utils/errors/internalError');
6
- var util = require('util');
3
+ const edm = require('./../utils/typedObjects');
4
+ const cloneContextWithNoAlias = edm.cloneContextWithNoAlias;
5
+ const InternalError = require('./../utils/errors/internalError');
6
+ const util = require('util');
7
7
 
8
8
  /**
9
9
  * Create a new SqlBuildHanaContext
@@ -15,7 +15,7 @@ var util = require('util');
15
15
  exports.SqlBuildHanaContext = function (context) {
16
16
  if (context) {
17
17
  this.oDataNullSupport = context.gModel.isNullSupported();
18
- var dbSeg = context.oData.dbSegmentLast;
18
+ const dbSeg = context.oData.dbSegmentLast;
19
19
  this.isNav = function (string) {
20
20
  return dbSeg._SelectedNavigations.indexOf(string) > -1;
21
21
  };
@@ -45,7 +45,7 @@ function getHanaCloudDbSetting(context) {
45
45
  }
46
46
 
47
47
  exports.SqlBuildHanaContext.prototype.clone = function () {
48
- var c = new exports.SqlBuildHanaContext();
48
+ const c = new exports.SqlBuildHanaContext();
49
49
  c.oDataNullSupport = this.oDataNullSupport;
50
50
  c.isNav = this.isNav;
51
51
  c.table = this.table; // used in Property.prototype.toSqlHana
@@ -126,25 +126,6 @@ exports.DeleteContainer = class DeleteContainer {
126
126
  }
127
127
  };
128
128
 
129
- /**
130
- * @Class Eq
131
- * @constructor
132
- * @param left
133
- * @param right
134
- */
135
-
136
- /*
137
- function Eq(left, right) {
138
- this.left = left;
139
- this.right = right;
140
- }
141
- exports.Eq = Eq;
142
- Eq.prototype.toSqlHana = function (context,parameter) {
143
- var ret = '';
144
- ret += '(' + this.left.toSqlHana(context,parameter) + ' = ' + this.right.toSqlHana(context,parameter) + ')';
145
- return ret;
146
- };*/
147
-
148
129
  /**
149
130
  * @Class Value
150
131
  * @constructor
@@ -174,7 +155,7 @@ function Exists(select) {
174
155
  exports.Exists = Exists;
175
156
 
176
157
  Exists.prototype.toSqlHana = function (context, parameter) {
177
- var ret = '';
158
+ let ret = '';
178
159
  ret += 'exists (' + this.exists.toSqlHana(context, parameter) + ')';
179
160
  return ret;
180
161
  };
@@ -198,8 +179,8 @@ function SelectProperty(table, property, propertyType, alias) {
198
179
  exports.SelectProperty = SelectProperty;
199
180
 
200
181
  SelectProperty.prototype.toSqlHana = function (context, parameter, hint) {
201
- var sql = [];
202
- var conversionFunction;
182
+ let sql = [];
183
+ let conversionFunction;
203
184
 
204
185
  if (!context.inOrderBy) {
205
186
  conversionFunction = getConversionFunction(this.propertyType);
@@ -253,7 +234,7 @@ exports.AggregateSelectProperty = AggregateSelectProperty;
253
234
 
254
235
 
255
236
  AggregateSelectProperty.prototype.toSqlHana = function (context, parameters) {
256
- var sql = this.aggregation +
237
+ let sql = this.aggregation +
257
238
  '(' +
258
239
  this.selectProperty.toSqlHana(context, parameters) +
259
240
  ')';
@@ -271,16 +252,7 @@ function ParameterSelectProperty(table, property, alias, value) {
271
252
  }
272
253
 
273
254
  ParameterSelectProperty.prototype.toSqlHana = function (context, parameter, hint) {
274
- var _alias = this.alias || this.property;
275
- /*
276
- if(!_alias){
277
- if (!withoutTable && this.table) {
278
- _alias = this.table + '.';
279
- }else{
280
- _alias = '';
281
- }
282
- _alias = this.property;
283
- }*/
255
+ const _alias = this.alias || this.property;
284
256
  if (this.value) {
285
257
  this.value.toSqlHana(context, parameter, hint);
286
258
  return util.format('? "%s"', _alias);
@@ -321,7 +293,7 @@ function SelectFormula(table, formula, alias) {
321
293
  exports.SelectFormula = SelectFormula;
322
294
 
323
295
  SelectFormula.prototype.toSqlHana = function () {
324
- var ret = '';
296
+ let ret = '';
325
297
  if (this.table) {
326
298
  ret += '"' + this.table + '".';
327
299
  }
@@ -350,18 +322,18 @@ OverFormula.prototype.addSortOrder = function (order) {
350
322
  };
351
323
 
352
324
  OverFormula.prototype.addSortOrders = function (orders) {
353
- for (var i = 0; i < orders.length; i++) {
354
- this.orders.push(orders[i]);
325
+ for (const order of orders) {
326
+ this.orders.push(order);
355
327
  }
356
328
  };
357
329
 
358
330
 
359
331
  OverFormula.prototype.toSqlHana = function (context, parameter) {
360
- var clonedContext = null;
361
- var sql = '';
332
+ let clonedContext = null;
333
+ let sql = '';
362
334
  sql += 'row_number() over(';
363
335
 
364
- var i;
336
+ let i;
365
337
  if (this.orders.length > 0) {
366
338
 
367
339
  clonedContext = cloneContextWithNoAlias(context);
@@ -453,9 +425,9 @@ Create.prototype.setAs = function (as) {
453
425
  };
454
426
 
455
427
  Create.prototype.toSqlHana = function (context, parameter) {
456
- var i;
428
+ let i;
457
429
 
458
- var sql = '';
430
+ let sql = '';
459
431
 
460
432
 
461
433
  sql += 'create ';
@@ -521,10 +493,10 @@ Insert.prototype.setSubSelect = function (subSelect) {
521
493
  };
522
494
 
523
495
  Insert.prototype.toSqlHana = function (context, parameter) {
524
- var sql = '';
496
+ let sql = '';
525
497
  sql += 'insert into ';
526
498
 
527
- if (this.intoTable.table.substr(0, 1) === '#') {
499
+ if (this.intoTable.table.substring(0, 1) === '#') {
528
500
  sql += ' "' + this.intoTable.table + '" ';
529
501
  if (this.intoTable.alias) {
530
502
  sql += ' as "' + this.intoTable.alias + '" ';
@@ -540,8 +512,8 @@ Insert.prototype.toSqlHana = function (context, parameter) {
540
512
  }
541
513
  }
542
514
 
543
- var i;
544
- var tmp = '';
515
+ let i;
516
+ let tmp = '';
545
517
  //sql += this.table + ' ';
546
518
  //collect names
547
519
  if (this.nv.length > 0) {
@@ -582,7 +554,6 @@ Insert.prototype.toSqlHana = function (context, parameter) {
582
554
  useDbType: this.nv[i].dbType
583
555
  }); // Ok
584
556
  } else {
585
- //console.log('--------------'+JSON.stringify(this.nv[i].value,null,4));
586
557
  tmp += '?';
587
558
  parameter.push(this.nv[i].value);
588
559
  }
@@ -599,8 +570,7 @@ Insert.prototype.toSqlHana = function (context, parameter) {
599
570
  * @param {(exports.Property)} names
600
571
  */
601
572
  Insert.prototype.addNames = function (names) {
602
- for (var i = 0; i < names.length; i++) {
603
- var n = names[i];
573
+ for (const n of names) {
604
574
  this.nv.push({
605
575
  name: n,
606
576
  value: undefined //null would be a valid OData value
@@ -609,8 +579,7 @@ Insert.prototype.addNames = function (names) {
609
579
  };
610
580
 
611
581
  Insert.prototype.setValue = function (name, value, dbType) {
612
- for (var i = 0; i < this.nv.length; i++) {
613
- var nv = this.nv[i];
582
+ for (const nv of this.nv) {
614
583
  if (nv.name.property === name) {
615
584
  nv.value = value;
616
585
  if (dbType) {
@@ -666,10 +635,10 @@ Select.prototype.addJoinTable = function (select, on, alias) {
666
635
  };
667
636
 
668
637
  Select.prototype.toSqlHana = function (context, parameter) {
669
- var i = 0;
670
- var clonedContext = null;
638
+ let i = 0;
639
+ let clonedContext = null;
671
640
 
672
- var sql = '';
641
+ let sql = '';
673
642
  sql += 'select ';
674
643
 
675
644
  for (i = 0; i < this.select.length; i++) {
@@ -687,7 +656,7 @@ Select.prototype.toSqlHana = function (context, parameter) {
687
656
  return '(' + from.subQuery.toSqlHana(context, parameter) + ')';
688
657
  }
689
658
 
690
- var fromString = '';
659
+ let fromString = '';
691
660
  if (from.table.substr(0, 1) !== '#' && from.schema) {
692
661
  fromString += '"' + from.schema + '".';
693
662
  }
@@ -695,7 +664,7 @@ Select.prototype.toSqlHana = function (context, parameter) {
695
664
  fromString += '"' + from.table + '"';
696
665
 
697
666
  if (from.placeholders) {
698
- var sql_placeholders = from.placeholders.map(function (ph) {
667
+ const sql_placeholders = from.placeholders.map(function (ph) {
699
668
  return ph.toSqlHana(context, parameter);
700
669
  });
701
670
  fromString += '(';
@@ -712,7 +681,7 @@ Select.prototype.toSqlHana = function (context, parameter) {
712
681
 
713
682
  this.joins.forEach(function (join) {
714
683
  if (join.table) {
715
- var table = join.table;
684
+ const table = join.table;
716
685
  sql += ' join ';
717
686
  if (table.schema) {
718
687
  sql += '"' + table.schema + '".';
@@ -789,7 +758,7 @@ Select.prototype.toSqlHana = function (context, parameter) {
789
758
  parameter.push(this.limit);
790
759
  }
791
760
 
792
- var hints = this.hints;
761
+ const hints = this.hints;
793
762
  if (hints) {
794
763
  if (hints.length > 0) {
795
764
  sql += ' with hint (' + hints.join(',') + ')';
@@ -840,7 +809,6 @@ Select.prototype.addFrom = function (from, inputParams) {
840
809
  return defaultResult;
841
810
  }
842
811
 
843
- //let localValue = value.substr(1, value.length - 2); // surrounding quotes from URI already removed by 'toSqlHana'
844
812
  let localValue = value;
845
813
 
846
814
  let stringArray = [];
@@ -906,9 +874,9 @@ Select.prototype.addFrom = function (from, inputParams) {
906
874
  key: kv.key,
907
875
  value: kv.value,
908
876
  toSqlHana: function (context, params) {
909
- var sql = util.format('placeholder."$$%s$$" => ?', kv.key); // placeholder."$$%s$$ == only for calc-views (not regular SQL)
910
- var localParams = [];
911
- var value;
877
+ let sql = util.format('placeholder."$$%s$$" => ?', kv.key); // placeholder."$$%s$$ == only for calc-views (not regular SQL)
878
+ const localParams = [];
879
+ let value;
912
880
 
913
881
  if (kv.value instanceof edm.EdmString) {
914
882
  //Edm.String
@@ -944,15 +912,11 @@ Select.prototype.addFrom = function (from, inputParams) {
944
912
  value = kv.value.value;
945
913
  value = value.substring(2, value.length - 1);
946
914
  params.push(value);
947
- //params.push(kv.value.value);
948
- } else if (kv.value instanceof edm.DateTime) {
949
- //Edm.DateTime(DATE,SECONDDATE,TIMESTAMP)
950
- kv.value.toSqlHana(context, localParams);
951
- params.push(localParams[0]); //e.g. "'1753-01-01'","'1753-01-01'","'1753-01-01'"
952
- } else if (kv.value instanceof edm.Time) {
953
- //Edm.Time(TIME)
954
- kv.value.toSqlHana(context, localParams);
955
- params.push(localParams[0]); //e.g. "'00:00:00'"
915
+ } else if (kv.value instanceof edm.DateTime || kv.value instanceof edm.Time) {
916
+ //Edm.DateTime(DATE,SECONDDATE,TIMESTAMP) e.g. "'1753-01-01'","'1753-01-01'","'1753-01-01'"
917
+ //Edm.Time(TIME) e.g. "'00:00:00'"
918
+ kv.value.toSqlHana(context, localParams);
919
+ params.push(localParams[0]);
956
920
  } else {
957
921
  throw new InternalError('Navigation to calc view expected after an Input path segment 3');
958
922
  }
@@ -1036,8 +1000,7 @@ Select.prototype.addUniqueSelects = function (selects) {
1036
1000
  * @param {{key : exports.Property, value: string}[]} keyValuePairs
1037
1001
  */
1038
1002
  Select.prototype.addWhereKeyValuePairs = function (keyValuePairs) {
1039
- for (var i = 0; i < keyValuePairs.length; i++) {
1040
- var kv = keyValuePairs[i];
1003
+ for (const kv of keyValuePairs) {
1041
1004
  this.whereAnded.push(new edm.BinaryOperator(edm.EQ, kv.key, kv.value, true /*strict*/));
1042
1005
  }
1043
1006
  return this;
@@ -1057,8 +1020,8 @@ Select.prototype.addWhereAnded = function (expression) {
1057
1020
  */
1058
1021
  Select.prototype.addSortOrders = function (orders) {
1059
1022
 
1060
- for (var i = 0; i < orders.length; i++) {
1061
- this.orders.push(orders[i]);
1023
+ for (const order of orders) {
1024
+ this.orders.push(order);
1062
1025
  }
1063
1026
  return this;
1064
1027
  };
@@ -1081,8 +1044,8 @@ Select.prototype.addSortOrder = function (order) {
1081
1044
  * @param {edm.OrderBy} orderBy
1082
1045
  */
1083
1046
  Select.prototype.addOrderBy = function (orderBy) {
1084
- for (var i = 0; i < orderBy.orders.length; i++) {
1085
- this.orders.push(orderBy.orders[i]);
1047
+ for (const order of orderBy.orders) {
1048
+ this.orders.push(order);
1086
1049
  }
1087
1050
  return this;
1088
1051
  };
@@ -1140,10 +1103,10 @@ Update.prototype.setFrom = function (from) {
1140
1103
  };
1141
1104
 
1142
1105
  Update.prototype.addSetCopyProperties = function (properties, fromAlias) {
1143
- var max = properties.length;
1106
+ const max = properties.length;
1144
1107
 
1145
- var p;
1146
- for (var i = 0; i < max; i++) {
1108
+ let p;
1109
+ for (let i = 0; i < max; i++) {
1147
1110
  p = {
1148
1111
  from: new SelectProperty(fromAlias, properties[i].property, null),
1149
1112
  to: properties[i]
@@ -1154,8 +1117,7 @@ Update.prototype.addSetCopyProperties = function (properties, fromAlias) {
1154
1117
 
1155
1118
 
1156
1119
  Update.prototype.addWhereKeyValuePairs = function (keyValuePairs) {
1157
- for (var i = 0; i < keyValuePairs.length; i++) {
1158
- var kv = keyValuePairs[i];
1120
+ for (const kv of keyValuePairs) {
1159
1121
  this.whereAnded.push(new edm.BinaryOperator(edm.EQ, kv.key, kv.value, true /*strict*/));
1160
1122
  }
1161
1123
  };
@@ -1172,7 +1134,7 @@ Update.prototype.toSqlHana = function (context, parameter) {
1172
1134
 
1173
1135
  Update.prototype.getHANACloudUpdateSql = function(context, parameter) {
1174
1136
 
1175
- var sql = '';
1137
+ let sql = '';
1176
1138
 
1177
1139
  sql += 'MERGE INTO ';
1178
1140
  if (this.update.table.substr(0, 1) === '#') {
@@ -1221,7 +1183,7 @@ Update.prototype.getHANACloudUpdateSql = function(context, parameter) {
1221
1183
 
1222
1184
  sql += ' SET ';
1223
1185
  for (let i = 0; i < this.copyFromTo.length; i++) {
1224
- var cft = this.copyFromTo[i];
1186
+ const cft = this.copyFromTo[i];
1225
1187
  sql += (i === 0 ? '' : ', ');
1226
1188
 
1227
1189
  sql += cft.to.toSqlHana(context, parameter, { withoutTable: true });
@@ -1234,9 +1196,9 @@ Update.prototype.getHANACloudUpdateSql = function(context, parameter) {
1234
1196
 
1235
1197
 
1236
1198
  Update.prototype.getHANAServiceUpdateSql = function(context, parameter) {
1237
- var i;
1199
+ let i;
1238
1200
 
1239
- var sql = '';
1201
+ let sql = '';
1240
1202
  sql += 'update ';
1241
1203
 
1242
1204
  if (this.update.table.substr(0, 1) === '#') {
@@ -1258,7 +1220,7 @@ Update.prototype.getHANAServiceUpdateSql = function(context, parameter) {
1258
1220
  sql += ' set ';
1259
1221
 
1260
1222
  for (i = 0; i < this.copyFromTo.length; i++) {
1261
- var cft = this.copyFromTo[i];
1223
+ const cft = this.copyFromTo[i];
1262
1224
  sql += (i === 0 ? '' : ', ');
1263
1225
 
1264
1226
  sql += cft.to.toSqlHana(context, parameter, { withoutTable: true });
@@ -1328,8 +1290,7 @@ Upsert.prototype.setSubSelect = function (subSelect) {
1328
1290
  };
1329
1291
 
1330
1292
  Upsert.prototype.addNames = function (names) {
1331
- for (var i = 0; i < names.length; i++) {
1332
- var n = names[i];
1293
+ for (const n of names) {
1333
1294
  this.nv.push({
1334
1295
  name: n,
1335
1296
  value: undefined //null would be a valid OData value
@@ -1338,8 +1299,7 @@ Upsert.prototype.addNames = function (names) {
1338
1299
  };
1339
1300
 
1340
1301
  Upsert.prototype.setValue = function (name, value) {
1341
- for (var i = 0; i < this.nv.length; i++) {
1342
- var nv = this.nv[i];
1302
+ for (const nv of this.nv) {
1343
1303
  if (nv.name.property === name) {
1344
1304
  nv.value = value;
1345
1305
  }
@@ -1347,17 +1307,14 @@ Upsert.prototype.setValue = function (name, value) {
1347
1307
  };
1348
1308
 
1349
1309
  Upsert.prototype.addWhereKeyValuePairs = function (keyValuePairs) {
1350
- for (var i = 0; i < keyValuePairs.length; i++) {
1351
- var kv = keyValuePairs[i];
1310
+ for (const kv of keyValuePairs) {
1352
1311
  this.whereAnded.push(new edm.BinaryOperator(edm.EQ, kv.key, kv.value, true /*strict*/));
1353
1312
  }
1354
1313
  };
1355
1314
 
1356
1315
 
1357
1316
  Upsert.prototype.toSqlHana = function (context, parameter) {
1358
- var i;
1359
-
1360
- var sql = '';
1317
+ let sql = '';
1361
1318
  sql += 'upsert ';
1362
1319
 
1363
1320
  if (this.upsert.table.substr(0, 1) === '#') {
@@ -1376,25 +1333,22 @@ Upsert.prototype.toSqlHana = function (context, parameter) {
1376
1333
  }
1377
1334
  }
1378
1335
 
1379
- var tmp = '';
1336
+ let tmp = '';
1380
1337
  if (this.subSelect) {
1381
- //sql += ' (';
1382
1338
  sql += ' ' + this.subSelect.toSqlHana(context, parameter);
1383
- //sql += ') ';
1384
1339
  } else {
1385
1340
  sql += ' values ';
1386
- tmp = '';
1387
- for (i = 0; i < this.nv.length; i++) {
1341
+ for (const element of this.nv) {
1388
1342
  tmp += (tmp.length > 0 ? ', ' : '');
1389
1343
 
1390
- if (this.nv[i].value && this.nv[i].value.toSqlHana) {
1391
- var pleaceholder = [];
1392
- this.nv[i].value.toSqlHana(context, pleaceholder, { withoutTable: true });
1344
+ if (element.value && element.value.toSqlHana) {
1345
+ const pleaceholder = [];
1346
+ element.value.toSqlHana(context, pleaceholder, { withoutTable: true });
1393
1347
 
1394
- tmp += this.nv[i].value.toSqlHana(context, parameter, { withoutTable: true });
1348
+ tmp += element.value.toSqlHana(context, parameter, { withoutTable: true });
1395
1349
  } else {
1396
1350
  tmp += '?';
1397
- parameter.push(this.nv[i].value);
1351
+ parameter.push(element.value);
1398
1352
  }
1399
1353
  }
1400
1354
  sql += '(' + tmp + ')';
@@ -1403,11 +1357,13 @@ Upsert.prototype.toSqlHana = function (context, parameter) {
1403
1357
 
1404
1358
  if (this.whereAnded.length > 0) {
1405
1359
  sql += '\n where ';
1406
- for (i = 0; i < this.whereAnded.length; i++) {
1407
- sql += (i === 0 ? '' : ' and ');
1360
+ let firstStatement = true;
1361
+ for (const elem of this.whereAnded) {
1362
+ sql += (firstStatement ? '' : ' and ');
1408
1363
  sql += '(';
1409
- sql += this.whereAnded[i].toSqlHana(context, parameter);
1364
+ sql += elem.toSqlHana(context, parameter);
1410
1365
  sql += ')';
1366
+ firstStatement = false;
1411
1367
  }
1412
1368
  }
1413
1369
 
@@ -1449,7 +1405,7 @@ function initializeDDLObject(target, tableName, schema) {
1449
1405
  *@private
1450
1406
  */
1451
1407
  function buildSimplePrefixedSql(options) {
1452
- var sql = options.prefix + " TABLE ";
1408
+ let sql = options.prefix + " TABLE ";
1453
1409
  if (options.schema) {
1454
1410
  sql += '"' + options.schema + '".';
1455
1411
  }
@@ -1525,16 +1481,13 @@ Delete.prototype.setFrom = function (from) {
1525
1481
 
1526
1482
 
1527
1483
  Delete.prototype.addWhereKeyValuePairs = function (keyValuePairs) {
1528
- for (var i = 0; i < keyValuePairs.length; i++) {
1529
- var kv = keyValuePairs[i];
1484
+ for (const kv of keyValuePairs) {
1530
1485
  this.whereAnded.push(new edm.BinaryOperator(edm.EQ, kv.key, kv.value, true /*strict*/));
1531
1486
  }
1532
1487
  };
1533
1488
 
1534
1489
  Delete.prototype.toSqlHana = function (context, parameter) {
1535
- var i = 0;
1536
-
1537
- var sql = '';
1490
+ let sql = '';
1538
1491
  sql += 'delete ';
1539
1492
 
1540
1493
  sql += 'from ';
@@ -1558,7 +1511,7 @@ Delete.prototype.toSqlHana = function (context, parameter) {
1558
1511
 
1559
1512
  if (this.whereAnded.length > 0) {
1560
1513
  sql += '\n where ';
1561
- for (i = 0; i < this.whereAnded.length; i++) {
1514
+ for (let i = 0; i < this.whereAnded.length; i++) {
1562
1515
  sql += (i === 0 ? '' : ' and ');
1563
1516
  sql += this.whereAnded[i].toSqlHana(context, parameter);
1564
1517
  }
@@ -1592,14 +1545,14 @@ exports._addETagToSelect = addETagToSelect;
1592
1545
  * which is used in the SELECT statement is different than the Alias property of the DBSegment (i.e. default alias).
1593
1546
  */
1594
1547
  function addETagToSelect(dbSegment, selectStmt, tableAlias) {
1595
- var concurrentProperties = dbSegment.entityType.getConcurrentProperties(),
1548
+ let concurrentProperties = dbSegment.entityType.getConcurrentProperties(),
1596
1549
  hashFunctionArguments,
1597
1550
  eTagExpression;
1598
1551
 
1599
1552
  tableAlias = tableAlias || dbSegment.getAlias();
1600
1553
 
1601
1554
  hashFunctionArguments = concurrentProperties.map(function (property) {
1602
- var dbColumnName = util.format('"%s"."%s"', tableAlias, property);
1555
+ const dbColumnName = util.format('"%s"."%s"', tableAlias, property);
1603
1556
  return util.format("ifnull(to_binary(%s), to_binary('')), case when %s is null then '01' else '00' end",
1604
1557
  dbColumnName, dbColumnName);
1605
1558
  });
@@ -1618,7 +1571,7 @@ exports.createSelectStmtForETag = createSelectStmtForETag;
1618
1571
  * @returns {Select}
1619
1572
  */
1620
1573
  function createSelectStmtForETag(dbSegment) {
1621
- var selectStmt = new Select();
1574
+ const selectStmt = new Select();
1622
1575
 
1623
1576
  addETagToSelect(dbSegment, selectStmt);
1624
1577
  selectStmt.addFrom(dbSegment.getAliasedTableName());
@@ -1633,9 +1586,9 @@ function createSelectStmtForETag(dbSegment) {
1633
1586
  * Currently supported is Truncate, Drop.
1634
1587
  * Examples:
1635
1588
  * <code>
1636
- * var sql = require("lib/.../sqlStatement");
1637
- * var truncate = sql.buildTableStatement(sql.Truncate, sqlContext, "yourTableName");
1638
- * var drop = sql.buildTableStatement(sql.Drop, sqlContext, "yourTableName");
1589
+ * let sql = require("lib/.../sqlStatement");
1590
+ * const truncate = sql.buildTableStatement(sql.Truncate, sqlContext, "yourTableName");
1591
+ * const drop = sql.buildTableStatement(sql.Drop, sqlContext, "yourTableName");
1639
1592
  * </code>
1640
1593
  *
1641
1594
  *@param type {Function} The type of statement you wnat to create
@@ -1675,7 +1628,7 @@ function TableColumn(table, property, alias) {
1675
1628
  exports.TableColumn = TableColumn;
1676
1629
 
1677
1630
  TableColumn.prototype.toSqlHana = function (context, parameter, hint) {
1678
- var sql = [];
1631
+ let sql = [];
1679
1632
 
1680
1633
  if (!(hint && hint.withoutTable) && this.table) {
1681
1634
  sql.push('"', this.table, '".');
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var sql = require('./sqlStatement');
3
+ const sql = require('./sqlStatement');
4
4
 
5
5
  //Code
6
6
  exports.rIdToTableName = function (reqId, rId) {
@@ -8,12 +8,10 @@ exports.rIdToTableName = function (reqId, rId) {
8
8
  };
9
9
 
10
10
  exports.rIdToNewTableName = function (name, netId, reqId, rId) {
11
- //return '#NEW_' + name + '_' + reqId + '_' + rId;
12
11
  return exports.rIdToAlteredTableName('#NEW', name, netId, reqId, rId);
13
12
  };
14
13
 
15
14
  exports.rIdToOldTableName = function (name, netId, reqId, rId) {
16
- //return '#OLD_' + name + '_' + reqId + '_' + rId;
17
15
  return exports.rIdToAlteredTableName('#OLD', name, netId, reqId, rId);
18
16
  };
19
17
 
@@ -30,7 +28,7 @@ exports.rIdToAlteredTableName = function (prefix, name, netId, reqId, rId) {
30
28
 
31
29
  exports.collectSqls = function (context,sqlContext) {
32
30
  context.logger.silly('sqlCollector', 'collectSqls');
33
- var containerAll = new sql.GetContainerAll();
31
+ const containerAll = new sql.GetContainerAll();
34
32
 
35
33
  addSqlsToContainer(sqlContext.dbSegLast, containerAll);
36
34
  return containerAll;
@@ -62,9 +60,7 @@ exports.collectSqls = function (context,sqlContext) {
62
60
  }
63
61
 
64
62
  //resource path chain
65
- var i;
66
- for (i = 0; i < dbSeg._ExpandedNavigations.length; i++) {
67
- var name = dbSeg._ExpandedNavigations[i];
63
+ for (const name of dbSeg._ExpandedNavigations) {
68
64
  addSqlsToContainer(dbSeg.getRelevantNavigationSegments()[name], container);
69
65
  }
70
66
  }
@@ -11,14 +11,12 @@ const NotFoundError = require('./../utils/errors/http/notFound');
11
11
  const execStmsDirectlyNoResult = function (context, stmsInput, asyncDone) {
12
12
  const stms = Array.isArray(stmsInput) ? stmsInput : [stmsInput];
13
13
  context.logger.silly('dataCollector', 'execParallelNoResult');
14
- //console.log('--------execStmsDirectlyNoResult----------', stms.length );
15
14
  async.mapSeries(
16
15
  stms,
17
16
  function (item, cb) {
18
17
  try {
19
- var p = [];
20
- var sql = item.toSqlHana(new sqlStatement.SqlBuildHanaContext(context), p);
21
- //console.log('---execStmsDirectlyNoResult',sql );
18
+ const p = [];
19
+ const sql = item.toSqlHana(new sqlStatement.SqlBuildHanaContext(context), p);
22
20
  if (p.length > 0) {
23
21
  return cb(new InternalError('No sql parameters expected'), context);
24
22
  }
@@ -40,12 +38,8 @@ const execStmsAsPreparedNoResult = function (context, stmsInput, asyncDone) {
40
38
  stms,
41
39
  function (item, cb) {
42
40
  try {
43
- var p = [];
44
- var sql = item.toSqlHana(new sqlStatement.SqlBuildHanaContext(context), p);
45
- //console.log('---execStmsAsPreparedNoResult',sql );
46
- //if (p.length > 0) {
47
- // return cb(new InternalError('No sql parameters expected'), context);
48
- //}
41
+ const p = [];
42
+ const sql = item.toSqlHana(new sqlStatement.SqlBuildHanaContext(context), p);
49
43
  dataCollector2.executeSqlAsPreparedStatementNoResult(context, sql, p, cb);
50
44
  } catch (ex) {
51
45
  cb(ex);
@@ -63,8 +57,8 @@ const execStmsAsPrepared = function (context,stmsInput, asyncDone) {
63
57
  stms,
64
58
  function (item, cb) {
65
59
  try {
66
- var p = [];
67
- var sql = item.toSqlHana(new sqlStatement.SqlBuildHanaContext(context), p);
60
+ const p = [];
61
+ const sql = item.toSqlHana(new sqlStatement.SqlBuildHanaContext(context), p);
68
62
  dataCollector2.executeSqlAsPreparedStatement(context, sql, p, cb);
69
63
  } catch (ex) {
70
64
  cb(ex);
@@ -113,7 +107,6 @@ const execCleanSessionStatements = (stms, context, asyncDone) => {
113
107
  'execCleanSessionStatements (connectionIsExternal: ' + context.db.isExternalHandledConnection + ')');
114
108
 
115
109
  if (context.db.isExternalHandledConnection === true) {
116
- //return dataCollector2.executeSqlAsPreparedStatementNoResult(context,stms, (err) => { asyncDone(err, context);});
117
110
  return module.exports.execStmsDirectlyNoResult(context, stms, asyncDone);
118
111
  }
119
112
 
@@ -131,7 +124,7 @@ const execCleanSessionStatements = (stms, context, asyncDone) => {
131
124
  */
132
125
  const execTempTableStatements = (context, stmsInput,asyncDone) => {
133
126
  const stms = Array.isArray(stmsInput) ? stmsInput : [stmsInput];
134
- var index;
127
+ let index;
135
128
  context.logger.silly('dataCollector', 'execTempTableStatements');
136
129
  context.logger.debug('dataCollector', 'execTempTableStatements statements', JSON.stringify(stms, null, ' '));
137
130
 
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var async = require('async');
3
+ const async = require('async');
4
4
 
5
5
  module.exports = function applyChecks(checks, context, callback) {
6
- var checksForKind = checks[context.oData.kind];
6
+ const checksForKind = checks[context.oData.kind];
7
7
 
8
8
  if (!checksForKind) { //no checks for odata.kind defined
9
9
  return callback(null, context);
10
10
  }
11
11
 
12
- var contextBoundChecks = checksForKind.map(function (check) {
12
+ const contextBoundChecks = checksForKind.map(function (check) {
13
13
  return check.bind(null, context);
14
14
  });
15
15