@sap/cds-compiler 3.4.4 → 3.5.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.
Files changed (129) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +1 -0
  3. package/bin/cds_update_identifiers.js +5 -5
  4. package/bin/cdsc.js +12 -12
  5. package/doc/CHANGELOG_ARCHIVE.md +1 -1
  6. package/doc/CHANGELOG_BETA.md +9 -1
  7. package/doc/CHANGELOG_DEPRECATED.md +2 -0
  8. package/lib/api/main.js +58 -59
  9. package/lib/api/options.js +4 -2
  10. package/lib/api/validate.js +2 -2
  11. package/lib/base/cleanSymbols.js +2 -3
  12. package/lib/base/dictionaries.js +6 -6
  13. package/lib/base/error.js +2 -2
  14. package/lib/base/keywords.js +6 -6
  15. package/lib/base/location.js +11 -12
  16. package/lib/base/message-registry.js +124 -28
  17. package/lib/base/messages.js +247 -179
  18. package/lib/base/model.js +14 -11
  19. package/lib/base/node-helpers.js +9 -10
  20. package/lib/base/optionProcessorHelper.js +138 -129
  21. package/lib/checks/actionsFunctions.js +5 -5
  22. package/lib/checks/annotationsOData.js +4 -4
  23. package/lib/checks/arrayOfs.js +1 -1
  24. package/lib/checks/cdsPersistence.js +1 -1
  25. package/lib/checks/checkForTypes.js +3 -3
  26. package/lib/checks/defaultValues.js +3 -3
  27. package/lib/checks/elements.js +7 -7
  28. package/lib/checks/emptyOrOnlyVirtual.js +2 -2
  29. package/lib/checks/foreignKeys.js +1 -1
  30. package/lib/checks/invalidTarget.js +4 -4
  31. package/lib/checks/managedInType.js +1 -1
  32. package/lib/checks/managedWithoutKeys.js +1 -1
  33. package/lib/checks/nonexpandableStructured.js +5 -3
  34. package/lib/checks/nullableKeys.js +1 -1
  35. package/lib/checks/onConditions.js +5 -6
  36. package/lib/checks/parameters.js +1 -1
  37. package/lib/checks/queryNoDbArtifacts.js +2 -2
  38. package/lib/checks/selectItems.js +4 -4
  39. package/lib/checks/sql-snippets.js +4 -4
  40. package/lib/checks/types.js +7 -7
  41. package/lib/checks/utils.js +4 -4
  42. package/lib/checks/validator.js +16 -13
  43. package/lib/compiler/.eslintrc.json +1 -1
  44. package/lib/compiler/assert-consistency.js +0 -1
  45. package/lib/compiler/builtins.js +1 -1
  46. package/lib/compiler/checks.js +73 -15
  47. package/lib/compiler/define.js +3 -7
  48. package/lib/compiler/extend.js +212 -32
  49. package/lib/compiler/finalize-parse-cdl.js +7 -2
  50. package/lib/compiler/index.js +17 -14
  51. package/lib/compiler/populate.js +2 -5
  52. package/lib/compiler/propagator.js +2 -0
  53. package/lib/compiler/shared.js +23 -12
  54. package/lib/compiler/tweak-assocs.js +5 -6
  55. package/lib/compiler/utils.js +6 -0
  56. package/lib/edm/annotations/genericTranslation.js +553 -319
  57. package/lib/edm/annotations/preprocessAnnotations.js +39 -35
  58. package/lib/edm/csn2edm.js +88 -75
  59. package/lib/edm/edm.js +17 -3
  60. package/lib/edm/edmAnnoPreprocessor.js +5 -5
  61. package/lib/edm/edmPreprocessor.js +106 -76
  62. package/lib/edm/edmUtils.js +41 -2
  63. package/lib/gen/Dictionary.json +34 -0
  64. package/lib/gen/language.checksum +1 -1
  65. package/lib/gen/language.interp +66 -63
  66. package/lib/gen/language.tokens +81 -81
  67. package/lib/gen/languageLexer.interp +4 -10
  68. package/lib/gen/languageLexer.js +854 -869
  69. package/lib/gen/languageLexer.tokens +79 -81
  70. package/lib/gen/languageParser.js +14360 -14146
  71. package/lib/inspect/inspectModelStatistics.js +2 -2
  72. package/lib/inspect/inspectPropagation.js +6 -6
  73. package/lib/inspect/inspectUtils.js +2 -2
  74. package/lib/json/from-csn.js +82 -40
  75. package/lib/json/to-csn.js +82 -157
  76. package/lib/language/.eslintrc.json +1 -4
  77. package/lib/language/genericAntlrParser.js +59 -38
  78. package/lib/language/language.g4 +1508 -1490
  79. package/lib/language/multiLineStringParser.js +1 -1
  80. package/lib/main.js +3 -3
  81. package/lib/model/csnUtils.js +130 -122
  82. package/lib/model/revealInternalProperties.js +1 -1
  83. package/lib/model/sortViews.js +4 -6
  84. package/lib/modelCompare/utils/filter.js +4 -3
  85. package/lib/optionProcessor.js +5 -0
  86. package/lib/render/DuplicateChecker.js +1 -1
  87. package/lib/render/manageConstraints.js +12 -12
  88. package/lib/render/toCdl.js +225 -159
  89. package/lib/render/toHdbcds.js +63 -63
  90. package/lib/render/toRename.js +5 -5
  91. package/lib/render/toSql.js +55 -65
  92. package/lib/render/utils/common.js +20 -37
  93. package/lib/render/utils/delta.js +3 -3
  94. package/lib/render/utils/sql.js +22 -6
  95. package/lib/render/utils/stringEscapes.js +3 -3
  96. package/lib/transform/db/applyTransformations.js +3 -3
  97. package/lib/transform/db/assertUnique.js +13 -12
  98. package/lib/transform/db/associations.js +5 -5
  99. package/lib/transform/db/cdsPersistence.js +10 -8
  100. package/lib/transform/db/constraints.js +14 -14
  101. package/lib/transform/db/expansion.js +20 -22
  102. package/lib/transform/db/flattening.js +24 -42
  103. package/lib/transform/db/groupByOrderBy.js +3 -3
  104. package/lib/transform/db/temporal.js +6 -6
  105. package/lib/transform/db/transformExists.js +23 -23
  106. package/lib/transform/db/views.js +16 -16
  107. package/lib/transform/draft/db.js +10 -10
  108. package/lib/transform/draft/odata.js +2 -2
  109. package/lib/transform/forOdataNew.js +12 -40
  110. package/lib/transform/forRelationalDB.js +17 -7
  111. package/lib/transform/localized.js +2 -2
  112. package/lib/transform/odata/toFinalBaseType.js +41 -27
  113. package/lib/transform/odata/typesExposure.js +106 -62
  114. package/lib/transform/parseExpr.js +209 -106
  115. package/lib/transform/transformUtilsNew.js +2 -2
  116. package/lib/transform/translateAssocsToJoins.js +24 -19
  117. package/lib/transform/universalCsn/coreComputed.js +10 -10
  118. package/lib/transform/universalCsn/universalCsnEnricher.js +26 -26
  119. package/lib/transform/universalCsn/utils.js +3 -3
  120. package/lib/utils/file.js +5 -5
  121. package/lib/utils/moduleResolve.js +13 -13
  122. package/lib/utils/objectUtils.js +6 -6
  123. package/lib/utils/term.js +5 -2
  124. package/lib/utils/timetrace.js +51 -24
  125. package/package.json +5 -7
  126. package/share/messages/check-proper-type-of.md +1 -1
  127. package/share/messages/message-explanations.json +1 -1
  128. package/share/messages/redirected-to-complex.md +4 -4
  129. package/share/messages/{syntax-expecting-integer.md → syntax-expecting-unsigned-int.md} +7 -4
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const {
4
- getUtils, walkCsnPath,
4
+ getUtils,
5
5
  applyTransformations, applyTransformationsOnNonDictionary,
6
6
  isBuiltinType, cloneCsnNonDict,
7
7
  copyAnnotations, implicitAs, isDeepEqual,
@@ -16,7 +16,7 @@ const { forEach } = require('../../utils/objectUtils');
16
16
  *
17
17
  * @param {CSN.Model} csn
18
18
  */
19
- function removeLeadingSelf(csn) {
19
+ function removeLeadingSelf( csn ) {
20
20
  const magicVars = [ '$now', '$self', '$projection', '$user', '$session', '$at' ];
21
21
  applyTransformations(csn, {
22
22
  elements: (parent, prop, elements) => {
@@ -46,7 +46,7 @@ function removeLeadingSelf(csn) {
46
46
  * @param {string} pathDelimiter
47
47
  * @param {object} iterateOptions
48
48
  */
49
- function resolveTypeReferences(csn, options, resolved, pathDelimiter, iterateOptions = {}) {
49
+ function resolveTypeReferences( csn, options, resolved, pathDelimiter, iterateOptions = {} ) {
50
50
  /**
51
51
  * Remove .localized from the element and any sub-elements
52
52
  *
@@ -55,7 +55,7 @@ function resolveTypeReferences(csn, options, resolved, pathDelimiter, iterateOpt
55
55
  *
56
56
  * @param {object} obj
57
57
  */
58
- function removeLocalized(obj) {
58
+ function removeLocalized( obj ) {
59
59
  const stack = [ obj ];
60
60
  while (stack.length > 0) {
61
61
  const current = stack.pop();
@@ -151,7 +151,7 @@ function resolveTypeReferences(csn, options, resolved, pathDelimiter, iterateOpt
151
151
  * @param {CSN.Path} path
152
152
  * @returns {boolean}
153
153
  */
154
- function isODataV4BuiltinFromService(typeName, path) {
154
+ function isODataV4BuiltinFromService( typeName, path ) {
155
155
  if (!options.toOdata || (options.odataVersion === 'v2') || typeof typeName !== 'string')
156
156
  return false;
157
157
 
@@ -170,7 +170,7 @@ function resolveTypeReferences(csn, options, resolved, pathDelimiter, iterateOpt
170
170
  * @param {string} typeName
171
171
  * @returns {boolean}
172
172
  */
173
- function isODataItems(typeName) {
173
+ function isODataItems( typeName ) {
174
174
  const typeDef = csn.definitions[typeName];
175
175
  return !!(options.toOdata && typeDef && typeDef.items);
176
176
  }
@@ -183,7 +183,7 @@ function resolveTypeReferences(csn, options, resolved, pathDelimiter, iterateOpt
183
183
  * @param {string} pathDelimiter
184
184
  * @param {object} iterateOptions
185
185
  */
186
- function flattenAllStructStepsInRefs(csn, options, resolved, pathDelimiter, iterateOptions = {}) {
186
+ function flattenAllStructStepsInRefs( csn, options, resolved, pathDelimiter, iterateOptions = {} ) {
187
187
  const { inspectRef, effectiveType } = csnRefs(csn);
188
188
  const { flattenStructStepsInRef } = transformUtils.getTransformers(csn, options, pathDelimiter);
189
189
  const adaptRefs = [];
@@ -196,7 +196,7 @@ function flattenAllStructStepsInRefs(csn, options, resolved, pathDelimiter, iter
196
196
  * @todo seems too hacky
197
197
  * @returns {WeakMap} A WeakMap where a link is the key and the type is the value
198
198
  */
199
- function resolveLinkTypes(links = []) {
199
+ function resolveLinkTypes( links = [] ) {
200
200
  const resolvedLinkTypes = new WeakMap();
201
201
  links.forEach((link) => {
202
202
  const { art } = link;
@@ -244,7 +244,7 @@ function flattenAllStructStepsInRefs(csn, options, resolved, pathDelimiter, iter
244
244
  * @param {CSN.Path} path
245
245
  * @returns {boolean}
246
246
  */
247
- function insideColumns(path) {
247
+ function insideColumns( path ) {
248
248
  return path.length >= 3 && (path[path.length - 3] === 'SELECT' || path[path.length - 3] === 'projection') && path[path.length - 2] === 'columns';
249
249
  }
250
250
  /**
@@ -253,7 +253,7 @@ function flattenAllStructStepsInRefs(csn, options, resolved, pathDelimiter, iter
253
253
  * @param {CSN.Path} path
254
254
  * @returns {boolean}
255
255
  */
256
- function insideKeys(path) {
256
+ function insideKeys( path ) {
257
257
  return path.length >= 3 && path[path.length - 2] === 'keys' && typeof path[path.length - 1] === 'number';
258
258
  }
259
259
  }
@@ -265,7 +265,7 @@ function flattenAllStructStepsInRefs(csn, options, resolved, pathDelimiter, iter
265
265
  * @param {Function} error
266
266
  * @param {object} iterateOptions
267
267
  */
268
- function flattenElements(csn, options, pathDelimiter, error, iterateOptions = {}) {
268
+ function flattenElements( csn, options, pathDelimiter, error, iterateOptions = {} ) {
269
269
  const { flattenStructuredElement, csnUtils } = transformUtils.getTransformers(csn, options, pathDelimiter);
270
270
  const { isAssocOrComposition, effectiveType } = csnUtils;
271
271
  const transformers = {
@@ -285,7 +285,7 @@ function flattenElements(csn, options, pathDelimiter, error, iterateOptions = {}
285
285
  * @param {object} dict
286
286
  * @param {CSN.Path} path
287
287
  */
288
- function flatten(parent, prop, dict, path) {
288
+ function flatten( parent, prop, dict, path ) {
289
289
  if (!parent[prop].$orderedElements)
290
290
  setProp(parent[prop], '$orderedElements', []);
291
291
  forEach(dict, (elementName, element) => {
@@ -367,7 +367,7 @@ function flattenElements(csn, options, pathDelimiter, error, iterateOptions = {}
367
367
  * @param {string} elementName Name of the structured element
368
368
  * @returns {object} Returns a dictionary, where the key is the flat name of the branch and the value is an array of element-steps.
369
369
  */
370
- function getBranches(element, elementName) {
370
+ function getBranches( element, elementName ) {
371
371
  const branches = {};
372
372
  const subbranchNames = [];
373
373
  const subbranchElements = [];
@@ -378,7 +378,7 @@ function flattenElements(csn, options, pathDelimiter, error, iterateOptions = {}
378
378
  * @param {object} e
379
379
  * @param {string} name
380
380
  */
381
- function walkElements(e, name) {
381
+ function walkElements( e, name ) {
382
382
  if (isBuiltinType(e.type)) {
383
383
  branches[subbranchNames.concat(name).join(pathDelimiter)] = subbranchElements.concat(e);
384
384
  }
@@ -411,7 +411,7 @@ function flattenElements(csn, options, pathDelimiter, error, iterateOptions = {}
411
411
  * @param {boolean} flattenKeyRefs
412
412
  * @param {object} iterateOptions
413
413
  */
414
- function handleManagedAssociationsAndCreateForeignKeys(csn, options, error, pathDelimiter, flattenKeyRefs, iterateOptions = {}) {
414
+ function handleManagedAssociationsAndCreateForeignKeys( csn, options, error, pathDelimiter, flattenKeyRefs, iterateOptions = {} ) {
415
415
  const { isManagedAssociation, inspectRef, isStructured } = getUtils(csn);
416
416
  const { flattenStructStepsInRef, flattenStructuredElement } = transformUtils.getTransformers(csn, options, pathDelimiter);
417
417
  if (flattenKeyRefs) {
@@ -445,7 +445,7 @@ function handleManagedAssociationsAndCreateForeignKeys(csn, options, error, path
445
445
  * @param {*} assocName
446
446
  * @param {*} path
447
447
  */
448
- function flattenFKs(assoc, assocName, path) {
448
+ function flattenFKs( assoc, assocName, path ) {
449
449
  let finished = false;
450
450
  while (!finished) {
451
451
  const newKeys = [];
@@ -460,7 +460,7 @@ function handleManagedAssociationsAndCreateForeignKeys(csn, options, error, path
460
460
  * @param {object[]} collector New keys array to collect the flattened stuff in
461
461
  * @returns {boolean} True if all keys are scalar - false if there are things that still need to be processed.
462
462
  */
463
- function processKeys(collector) {
463
+ function processKeys( collector ) {
464
464
  const inferredAlias = '$inferredAlias';
465
465
 
466
466
  let done = true;
@@ -538,7 +538,7 @@ function handleManagedAssociationsAndCreateForeignKeys(csn, options, error, path
538
538
  * @param {Array} ref
539
539
  * @returns {object} The clone of base
540
540
  */
541
- function cloneAndExtendRef(key, base, ref) {
541
+ function cloneAndExtendRef( key, base, ref ) {
542
542
  const clone = cloneCsnNonDict(base, options);
543
543
  if (key.ref) {
544
544
  // We build a ref that contains the aliased fk - that element will be created later on, so this ref is not resolvable yet
@@ -590,12 +590,12 @@ function handleManagedAssociationsAndCreateForeignKeys(csn, options, error, path
590
590
  * @param {object} dict The params or elements thing
591
591
  * @param {CSN.Path} path
592
592
  */
593
- function createFks(parent, prop, dict, path) {
593
+ function createFks( parent, prop, dict, path ) {
594
594
  const orderedElements = [];
595
595
  Object.entries(dict).forEach(([ elementName, element ]) => {
596
596
  orderedElements.push([ elementName, element ]);
597
597
  const eltPath = path.concat(prop, elementName);
598
- const fks = createForeignKeysInternal(eltPath, element, elementName, csn, options, pathDelimiter);
598
+ const fks = createForeignKeys(eltPath, element, elementName, csn, options, pathDelimiter);
599
599
 
600
600
  // finalize the generated foreign keys
601
601
  const refCount = fks.reduce((acc, fk) => {
@@ -671,13 +671,12 @@ function handleManagedAssociationsAndCreateForeignKeys(csn, options, error, path
671
671
  * @param {number} lvl
672
672
  * @returns {Array[]} First element of every sub-array is the foreign key name, second is the foreign key definition
673
673
  */
674
- function createForeignKeysInternal(path, element, prefix, csn, options, pathDelimiter, lvl = 0) {
674
+ function createForeignKeys( path, element, prefix, csn, options, pathDelimiter, lvl = 0 ) {
675
675
  const {
676
676
  effectiveType,
677
677
  inspectRef,
678
678
  } = getUtils(csn);
679
679
 
680
-
681
680
  const isInspectRefResult = !Array.isArray(path);
682
681
 
683
682
  let fks = [];
@@ -719,7 +718,7 @@ function createForeignKeysInternal(path, element, prefix, csn, options, pathDeli
719
718
  const continuePath = getContinuePath([ 'keys', keyIndex ]);
720
719
  const alias = key.as || implicitAs(key.ref);
721
720
  const result = inspectRef(continuePath);
722
- fks = fks.concat(createForeignKeysInternal(result, result.art, alias, csn, options, pathDelimiter, lvl + 1));
721
+ fks = fks.concat(createForeignKeys(result, result.art, alias, csn, options, pathDelimiter, lvl + 1));
723
722
  });
724
723
  if (!hasKeys)
725
724
  delete finalElement.keys;
@@ -743,7 +742,7 @@ function createForeignKeysInternal(path, element, prefix, csn, options, pathDeli
743
742
  // Skip already produced foreign keys
744
743
  if (!elem['@odata.foreignKey4']) {
745
744
  const continuePath = getContinuePath([ 'elements', elemName ]);
746
- fks = fks.concat(createForeignKeysInternal(continuePath, elem, elemName, csn, options, pathDelimiter, lvl + 1));
745
+ fks = fks.concat(createForeignKeys(continuePath, elem, elemName, csn, options, pathDelimiter, lvl + 1));
747
746
  }
748
747
  });
749
748
  }
@@ -759,7 +758,7 @@ function createForeignKeysInternal(path, element, prefix, csn, options, pathDeli
759
758
  * @param {Array} additions
760
759
  * @returns {CSN.Path}
761
760
  */
762
- function getContinuePath(additions) {
761
+ function getContinuePath( additions ) {
763
762
  if (csn.definitions[finalElement.type])
764
763
  return [ 'definitions', finalElement.type, ...additions ];
765
764
  else if (finalTypeName)
@@ -790,27 +789,10 @@ function createForeignKeysInternal(path, element, prefix, csn, options, pathDeli
790
789
  return fks;
791
790
  }
792
791
 
793
- /**
794
- * This is the public createForeignKeys function that has no side effects
795
- *
796
- * @param {CSN.Path} path Path to the managed association
797
- * @param {CSN.Model} csn
798
- * @param {string} pathDelimiter
799
- * @returns {Array}
800
- */
801
- function createForeignKeys(path, csn, pathDelimiter = '_') {
802
- if (!path || !Array.isArray(path))
803
- throw Error('path must be a CSN path array');
804
- if (!csn || typeof csn !== 'object')
805
- throw Error('csn not provided');
806
- return createForeignKeysInternal(path, walkCsnPath(csn, path), path[path.length - 1], csn, {}, pathDelimiter);
807
- }
808
-
809
792
  module.exports = {
810
793
  resolveTypeReferences,
811
794
  flattenAllStructStepsInRefs,
812
795
  flattenElements,
813
796
  removeLeadingSelf,
814
797
  handleManagedAssociationsAndCreateForeignKeys,
815
- createForeignKeys,
816
798
  };
@@ -13,7 +13,7 @@ const { ModelError } = require('../../base/error');
13
13
  * @param {Function} error
14
14
  * @param {CSN.Path} path
15
15
  */
16
- function replaceAssociationsInGroupByOrderBy(inputQuery, options, inspectRef, error, path) {
16
+ function replaceAssociationsInGroupByOrderBy( inputQuery, options, inspectRef, error, path ) {
17
17
  const query = inputQuery.SET || inputQuery.SELECT;
18
18
 
19
19
  if (query.groupBy) {
@@ -29,7 +29,7 @@ function replaceAssociationsInGroupByOrderBy(inputQuery, options, inspectRef, er
29
29
  if (options.transformation === 'hdbcds' && options.sqlMapping === 'hdbcds') {
30
30
  error(null, groupByPath,
31
31
  { $reviewed: true },
32
- 'Unexpected managed association in GROUP BY for naming mode “hdbcds');
32
+ 'Unexpected managed association in GROUP BY for naming mode “hdbcds');
33
33
  continue;
34
34
  }
35
35
  const pathPrefix = query.groupBy[i].ref.slice(0, -1);
@@ -88,7 +88,7 @@ function replaceAssociationsInGroupByOrderBy(inputQuery, options, inspectRef, er
88
88
  * @param {CSN.Element} assoc
89
89
  * @returns {object[]}
90
90
  */
91
- function getForeignKeyRefs(assoc) {
91
+ function getForeignKeyRefs( assoc ) {
92
92
  return assoc.keys.map((fk) => {
93
93
  if (!fk.$generatedFieldName)
94
94
  throw new ModelError(`Expecting generated field name for foreign key: ${JSON.stringify(fk)}`);
@@ -22,7 +22,7 @@ const validFromString = '@cds.valid.from';
22
22
  * @param {Function} messageFunctions.info
23
23
  * @returns {(artifact: CSN.Artifact, artifactName: string) => void} Callback for forEachDefinition applying the where-condition to views.
24
24
  */
25
- function getViewDecorator(csn, messageFunctions) {
25
+ function getViewDecorator( csn, messageFunctions ) {
26
26
  const { info } = messageFunctions;
27
27
  const { get$combined } = getUtils(csn);
28
28
  return addTemporalWhereConditionToView;
@@ -37,7 +37,7 @@ function getViewDecorator(csn, messageFunctions) {
37
37
  * @param {CSN.Artifact} artifact
38
38
  * @param {string} artifactName
39
39
  */
40
- function addTemporalWhereConditionToView(artifact, artifactName) {
40
+ function addTemporalWhereConditionToView( artifact, artifactName ) {
41
41
  const normalizedQuery = getNormalizedQuery(artifact);
42
42
  if (normalizedQuery && normalizedQuery.query && normalizedQuery.query.SELECT) {
43
43
  // BLOCKER: We need information to handle $combined
@@ -101,7 +101,7 @@ function getViewDecorator(csn, messageFunctions) {
101
101
  * @param {any} combined union of all entities of the from-clause
102
102
  * @returns {Array[]} Array where first field is array of elements with @cds.valid.from, second field is array of elements with @cds.valid.to.
103
103
  */
104
- function getFromToElements(combined) {
104
+ function getFromToElements( combined ) {
105
105
  const from = [];
106
106
  const to = [];
107
107
  for (const name in combined) {
@@ -129,7 +129,7 @@ function getViewDecorator(csn, messageFunctions) {
129
129
  * @param {object} to
130
130
  * @returns {boolean} True if both are present and false.
131
131
  */
132
- function hasFalsyTemporalAnnotations(SELECT, elements, from, to) {
132
+ function hasFalsyTemporalAnnotations( SELECT, elements, from, to ) {
133
133
  let fromElement = elements[from.name];
134
134
  let toElement = elements[to.name];
135
135
 
@@ -166,7 +166,7 @@ function getViewDecorator(csn, messageFunctions) {
166
166
  * @param {Function} messageFunctions.error
167
167
  * @returns {(artifact: CSN.Artifact, artifactName: string) => void} Callback for forEachDefinition processing the annotations.
168
168
  */
169
- function getAnnotationHandler(csn, options, pathDelimiter, messageFunctions) {
169
+ function getAnnotationHandler( csn, options, pathDelimiter, messageFunctions ) {
170
170
  const { error } = messageFunctions;
171
171
  const {
172
172
  extractValidFromToKeyElement, checkAssignment, checkMultipleAssignments, recurseElements,
@@ -177,7 +177,7 @@ function getAnnotationHandler(csn, options, pathDelimiter, messageFunctions) {
177
177
  * @param {CSN.Artifact} artifact
178
178
  * @param {string} artifactName
179
179
  */
180
- function handleTemporalAnnotations(artifact, artifactName) {
180
+ function handleTemporalAnnotations( artifact, artifactName ) {
181
181
  const validFrom = [];
182
182
  const validTo = [];
183
183
  const validKey = [];
@@ -48,7 +48,7 @@ const { ModelError } = require('../../base/error');
48
48
  * @param {CSN.Options} options
49
49
  * @param {Function} error
50
50
  */
51
- function handleExists(csn, options, error) {
51
+ function handleExists( csn, options, error ) {
52
52
  let { inspectRef } = csnRefs(csn);
53
53
  const generatedExists = new WeakMap();
54
54
  forEachDefinition(csn, (artifact, artifactName) => {
@@ -103,7 +103,7 @@ function handleExists(csn, options, error) {
103
103
  * @param {Array} args Join args
104
104
  * @returns {object}
105
105
  */
106
- function getJoinSources(args) {
106
+ function getJoinSources( args ) {
107
107
  let sources = Object.create(null);
108
108
  for (const join of args) {
109
109
  if (join.as) {
@@ -127,7 +127,7 @@ function handleExists(csn, options, error) {
127
127
  * @param {CSN.Query} query
128
128
  * @returns {object}
129
129
  */
130
- function getQuerySources(query) {
130
+ function getQuerySources( query ) {
131
131
  const sources = Object.create(null);
132
132
  if (query.from.as)
133
133
  sources[query.from.as] = query.from.as;
@@ -147,7 +147,7 @@ function handleExists(csn, options, error) {
147
147
  * @param {object[]} links links for a ref, produced by inspectRef
148
148
  * @returns {number|null} Null if no association was found
149
149
  */
150
- function getFirstAssocIndex(startIndex, links) {
150
+ function getFirstAssocIndex( startIndex, links ) {
151
151
  for (let i = startIndex; i < links.length; i++) {
152
152
  if (links[i] && links[i].art && links[i].art.target)
153
153
  return i;
@@ -174,7 +174,7 @@ function handleExists(csn, options, error) {
174
174
  * @param {CSN.Path} path to the overall ref where _main is contained
175
175
  * @returns {Array} Return the now-nested ref-array
176
176
  */
177
- function nestFilters(startIndex, startAssoc, startRest, path) {
177
+ function nestFilters( startIndex, startAssoc, startRest, path ) {
178
178
  let revert;
179
179
  if (!startAssoc.where) { // initialize first filter if not present
180
180
  if (typeof startAssoc === 'string') {
@@ -253,7 +253,7 @@ function handleExists(csn, options, error) {
253
253
  * @param {CSN.Path} exprPath
254
254
  * @returns {void}
255
255
  */
256
- function forbidAssocInExists(exprPath) {
256
+ function forbidAssocInExists( exprPath ) {
257
257
  const expr = walkCsnPath(csn, exprPath);
258
258
  for (let i = 0; i < expr.length; i++) {
259
259
  if (i < expr.length - 1 && expr[i] === 'exists' && expr[i + 1].ref) {
@@ -272,7 +272,7 @@ function handleExists(csn, options, error) {
272
272
  /**
273
273
  * @param {object[]} assocs Array of refs of assocs - possibly with a .where to check
274
274
  */
275
- function checkForInvalidAssoc(assocs) {
275
+ function checkForInvalidAssoc( assocs ) {
276
276
  for (const assoc of assocs) {
277
277
  if (assoc.where) {
278
278
  for (let i = 0; i < assoc.where.length; i++) {
@@ -311,7 +311,7 @@ function handleExists(csn, options, error) {
311
311
  * @param {CSN.Path} exprPath
312
312
  * @returns {Array}
313
313
  */
314
- function nestExists(exprPath) {
314
+ function nestExists( exprPath ) {
315
315
  const expr = walkCsnPath(csn, exprPath);
316
316
  for (let i = 0; i < expr.length; i++) {
317
317
  if (i < expr.length - 1 && expr[i] === 'exists' && expr[i + 1].ref) {
@@ -344,7 +344,7 @@ function handleExists(csn, options, error) {
344
344
  * @param {CSN.Path} exprPath Path to the expression-array to process
345
345
  * @returns {{result: TokenStream, leftovers: Array[]}} result: A new token stream expression - the same as expr, but with the expanded EXISTS, leftovers: path-tuples to further subqueries to process.
346
346
  */
347
- function processExists(queryPath, exprPath) {
347
+ function processExists( queryPath, exprPath ) {
348
348
  const toContinue = [];
349
349
  const newExpr = [];
350
350
  const query = walkCsnPath(csn, queryPath);
@@ -427,7 +427,7 @@ function handleExists(csn, options, error) {
427
427
  * @param {Token} current
428
428
  * @returns {object[]} The stuff to add to the where
429
429
  */
430
- function translateManagedAssocToWhere(root, target, isPrefixedWithTableAlias, base, current) {
430
+ function translateManagedAssocToWhere( root, target, isPrefixedWithTableAlias, base, current ) {
431
431
  if (current.$scope === '$self') {
432
432
  error('ref-unexpected-exists-self', current.$path, { id: current.ref[0], name: 'exists' }, 'With $(NAME), path steps must not start with $(ID)');
433
433
  return [];
@@ -453,7 +453,7 @@ function handleExists(csn, options, error) {
453
453
  * @param {Array} ref Array of strings or objects with `id`
454
454
  * @returns {string[]}
455
455
  */
456
- function toRawRef(ref) {
456
+ function toRawRef( ref ) {
457
457
  return ref.map(r => (r.id ? r.id : r));
458
458
  }
459
459
 
@@ -475,7 +475,7 @@ function handleExists(csn, options, error) {
475
475
  * @param {Token} current
476
476
  * @returns {object[]} The stuff to add to the where
477
477
  */
478
- function translateUnmanagedAssocToWhere(root, target, isPrefixedWithTableAlias, base, current) {
478
+ function translateUnmanagedAssocToWhere( root, target, isPrefixedWithTableAlias, base, current ) {
479
479
  const whereExtension = [];
480
480
  for (let j = 0; j < root.on.length; j++) {
481
481
  const part = root.on[j];
@@ -532,7 +532,7 @@ function handleExists(csn, options, error) {
532
532
  * @param {...any} args
533
533
  * @returns {object} The merged args without an .as property
534
534
  */
535
- function assignAndDeleteAs(...args) {
535
+ function assignAndDeleteAs( ...args ) {
536
536
  const obj = Object.assign.apply(null, args);
537
537
  delete obj.as;
538
538
  return obj;
@@ -546,7 +546,7 @@ function handleExists(csn, options, error) {
546
546
  * @param {object} obj
547
547
  * @returns {object}
548
548
  */
549
- function translateToSourceSide(obj) {
549
+ function translateToSourceSide( obj ) {
550
550
  if (obj.ref) {
551
551
  if (obj.$scope === '$self') { // TODO: Check with this way down, do we keep the links?
552
552
  const column = obj._art._column;
@@ -580,7 +580,7 @@ function handleExists(csn, options, error) {
580
580
  * @param {CSN.Path} pathRight
581
581
  * @returns {boolean}
582
582
  */
583
- function isValidDollarSelf(leftSide, pathLeft, middle, rightSide, pathRight) {
583
+ function isValidDollarSelf( leftSide, pathLeft, middle, rightSide, pathRight ) {
584
584
  if (leftSide && leftSide.ref && rightSide && rightSide.ref && middle === '=') {
585
585
  const right = inspectRef(pathRight);
586
586
  const left = inspectRef(pathLeft);
@@ -606,7 +606,7 @@ function handleExists(csn, options, error) {
606
606
  * @param {CSN.Path} path
607
607
  * @returns {{head: Array, root: CSN.Element, ref: string|object, tail: Array}} The first assoc (root), the corresponding ref (ref), anything before the ref (head) and the rest of the ref (tail).
608
608
  */
609
- function getFirstAssoc(xprPart, path) {
609
+ function getFirstAssoc( xprPart, path ) {
610
610
  const { links, art } = inspectRef(path);
611
611
  for (let i = 0; i < xprPart.ref.length - 1; i++) {
612
612
  if (links[i].art && links[i].art.target) {
@@ -627,7 +627,7 @@ function handleExists(csn, options, error) {
627
627
  * @param {CSN.Path} path
628
628
  * @returns {{head: Array, root: CSN.Element, ref: string|object, tail: Array}} The last assoc (root), the corresponding ref (ref), anything before the ref (head) and the rest of the ref (tail).
629
629
  */
630
- function getLastAssoc(xprPart, path) {
630
+ function getLastAssoc( xprPart, path ) {
631
631
  const { links, art } = inspectRef(path);
632
632
  for (let i = xprPart.ref.length - 1; i > -1; i--) {
633
633
  if (links[i].art && links[i].art.target) {
@@ -647,7 +647,7 @@ function handleExists(csn, options, error) {
647
647
  * @param {CSN.Path} path
648
648
  * @returns {boolean}
649
649
  */
650
- function firstLinkIsEntityOrQuerySource(path) {
650
+ function firstLinkIsEntityOrQuerySource( path ) {
651
651
  const { links } = inspectRef(path);
652
652
  return links && (links[0].art.kind === 'entity' || links[0].art.query || links[0].art.from);
653
653
  }
@@ -675,7 +675,7 @@ function handleExists(csn, options, error) {
675
675
  * @todo $env is going to be removed from CSN, but csnRefs will provide it
676
676
  */
677
677
  // eslint-disable-next-line consistent-return
678
- function getParent(xpr, path) {
678
+ function getParent( xpr, path ) {
679
679
  if (firstLinkIsEntityOrQuerySource(path)) {
680
680
  return xpr.ref[0];
681
681
  }
@@ -704,7 +704,7 @@ function handleExists(csn, options, error) {
704
704
  * @param {object} _sources Object containing the names of the query sources of the current query
705
705
  * @returns {CSN.Query}
706
706
  */
707
- function getSubselect(target, assocRef, _sources) {
707
+ function getSubselect( target, assocRef, _sources ) {
708
708
  let subselectAlias = `_${assocRef.id ? assocRef.id : assocRef}_exists`;
709
709
 
710
710
  while (_sources[subselectAlias])
@@ -741,7 +741,7 @@ function handleExists(csn, options, error) {
741
741
  * @param {CSN.Path} path
742
742
  * @returns {string}
743
743
  */
744
- function getBase(queryBase, isPrefixedWithTableAlias, current, path) {
744
+ function getBase( queryBase, isPrefixedWithTableAlias, current, path ) {
745
745
  if (typeof queryBase === 'string') // alias
746
746
  return queryBase;
747
747
  else if (queryBase) // ref
@@ -761,7 +761,7 @@ function handleExists(csn, options, error) {
761
761
  * @param {TokenStream} where
762
762
  * @returns {TokenStream} The input-where with the refs transformed to absolute ones
763
763
  */
764
- function remapExistingWhere(target, where) {
764
+ function remapExistingWhere( target, where ) {
765
765
  return where.map((part) => {
766
766
  if (part.ref) {
767
767
  part.ref = [ target, ...part.ref ];
@@ -783,7 +783,7 @@ function handleExists(csn, options, error) {
783
783
  * @param {CSN.Path} path
784
784
  * @returns {TokenStream} The WHERE representing the $self comparison
785
785
  */
786
- function translateDollarSelfToWhere(base, target, assoc, path) {
786
+ function translateDollarSelfToWhere( base, target, assoc, path ) {
787
787
  const where = [];
788
788
  const { art } = inspectRef(path);
789
789
  if (art.keys) {
@@ -15,7 +15,7 @@ const { ModelError } = require('../../base/error');
15
15
  * @param {string} associationName
16
16
  * @returns {object} The mixin association
17
17
  */
18
- function getMixinAssocOfQueryIfPublished(query, association, associationName) {
18
+ function getMixinAssocOfQueryIfPublished( query, association, associationName ) {
19
19
  if (query && query.SELECT && query.SELECT.mixin) {
20
20
  const aliasedColumnsMap = Object.create(null);
21
21
  if (query.SELECT.columns) {
@@ -49,7 +49,7 @@ function getMixinAssocOfQueryIfPublished(query, association, associationName) {
49
49
  * @param {string} associationName
50
50
  * @returns {boolean} True if used
51
51
  */
52
- function usesMixinAssociation(query, association, associationName) {
52
+ function usesMixinAssociation( query, association, associationName ) {
53
53
  if (query && query.SELECT && query.SELECT.columns) {
54
54
  for (const column of query.SELECT.columns) {
55
55
  if (typeof column === 'object' && column.ref && column.ref.length > 1 && (column.ref[0] === associationName || column.ref[0].id === associationName))
@@ -66,7 +66,7 @@ function usesMixinAssociation(query, association, associationName) {
66
66
  * @param {Function} transformCommon For the time being: Pass from outside
67
67
  * @returns {(query: CSN.Query, artifact: CSN.Artifact, artName: string, path: CSN.Path) => void} Transformer function for views
68
68
  */
69
- function getViewTransformer(csn, options, messageFunctions, transformCommon) {
69
+ function getViewTransformer( csn, options, messageFunctions, transformCommon ) {
70
70
  const {
71
71
  get$combined, isAssocOrComposition,
72
72
  inspectRef, queryOrMain, // csnRefs
@@ -85,7 +85,7 @@ function getViewTransformer(csn, options, messageFunctions, transformCommon) {
85
85
  * @param {CSN.Elements} elements
86
86
  * @param {CSN.Path} path
87
87
  */
88
- function checkForMixinPublishing(query, elements, path) {
88
+ function checkForMixinPublishing( query, elements, path ) {
89
89
  for (const elementName in elements) {
90
90
  const element = elements[elementName];
91
91
  if (element.target) {
@@ -123,7 +123,7 @@ function getViewTransformer(csn, options, messageFunctions, transformCommon) {
123
123
  * @param {CSN.Query} query
124
124
  * @returns {object}
125
125
  */
126
- function getColumnMap(query) {
126
+ function getColumnMap( query ) {
127
127
  const map = Object.create(null);
128
128
  if (query && query.SELECT && query.SELECT.columns) {
129
129
  query.SELECT.columns.forEach((col) => {
@@ -169,7 +169,7 @@ function getViewTransformer(csn, options, messageFunctions, transformCommon) {
169
169
  * @param {object} columnMap
170
170
  * @param {string} elemName
171
171
  */
172
- function addProjectionOrStarElement(query, isProjection, isSelectStar, $combined, columnMap, elemName) {
172
+ function addProjectionOrStarElement( query, isProjection, isSelectStar, $combined, columnMap, elemName ) {
173
173
  // Prepend an alias if present
174
174
  let alias = (isProjection || isSelectStar) &&
175
175
  (query.SELECT.from.as || (query.SELECT.from.ref && implicitAs(query.SELECT.from.ref)));
@@ -205,7 +205,7 @@ function getViewTransformer(csn, options, messageFunctions, transformCommon) {
205
205
  * @param {CSN.Element} elem
206
206
  * @param {string} elemName
207
207
  */
208
- function addForeignKeysToColumns(columnMap, elem, elemName) {
208
+ function addForeignKeysToColumns( columnMap, elem, elemName ) {
209
209
  const assocCol = columnMap[elemName];
210
210
  if (assocCol && assocCol.ref) {
211
211
  elem.keys.forEach((foreignKey) => {
@@ -243,7 +243,7 @@ function getViewTransformer(csn, options, messageFunctions, transformCommon) {
243
243
  * @param {CSN.Path} elementsPath Path pointing to elements
244
244
  * @param {CSN.Path} queryPath Path pointing to the query
245
245
  */
246
- function handleAssociationElement(query, elements, columnMap, publishedMixins, elem, elemName, elementsPath, queryPath) {
246
+ function handleAssociationElement( query, elements, columnMap, publishedMixins, elem, elemName, elementsPath, queryPath ) {
247
247
  if (isUnion(queryPath) && options.transformation === 'hdbcds') {
248
248
  if (isBetaEnabled(options, 'ignoreAssocPublishingInUnion') && doA2J) {
249
249
  if (elem.keys)
@@ -328,7 +328,7 @@ function getViewTransformer(csn, options, messageFunctions, transformCommon) {
328
328
  * @param {CSN.Column} col
329
329
  * @param {CSN.Path} path
330
330
  */
331
- function addImplicitAliasWithAssoc(col, path) {
331
+ function addImplicitAliasWithAssoc( col, path ) {
332
332
  if (!col.as && col.ref && col.ref.length > 1) {
333
333
  const { links } = inspectRef(path);
334
334
  if (links && links.slice(0, -1).some(({ art }) => isAssocOrComposition(art && art.type || '')))
@@ -342,7 +342,7 @@ function getViewTransformer(csn, options, messageFunctions, transformCommon) {
342
342
  *
343
343
  * @param {CSN.Column} col
344
344
  */
345
- function addImplicitAliasWithLonelyParam(col) {
345
+ function addImplicitAliasWithLonelyParam( col ) {
346
346
  if (!col.as && col.param)
347
347
  col.as = getLastRefStepString(col.ref);
348
348
  }
@@ -355,7 +355,7 @@ function getViewTransformer(csn, options, messageFunctions, transformCommon) {
355
355
  * @param {CSN.Column[]} columns
356
356
  * @param {CSN.Path} path
357
357
  */
358
- function processColumns(functions, columns, path) {
358
+ function processColumns( functions, columns, path ) {
359
359
  for (let i = 0; i < columns.length; i++) {
360
360
  const col = columns[i];
361
361
  functions.forEach(fn => fn(col, path.concat(i)));
@@ -369,7 +369,7 @@ function getViewTransformer(csn, options, messageFunctions, transformCommon) {
369
369
  * @param {CSN.Path} path
370
370
  */
371
371
  // eslint-disable-next-line complexity
372
- function transformViewOrEntity(query, artifact, artName, path) {
372
+ function transformViewOrEntity( query, artifact, artName, path ) {
373
373
  const { elements } = queryOrMain(query, artifact);
374
374
  // We use the elements from the leading query/main artifact - adapt the path
375
375
  const elementsPath = elements === artifact.elements ? path.slice(0, 2).concat('elements') : path.concat('elements');
@@ -453,7 +453,7 @@ function getViewTransformer(csn, options, messageFunctions, transformCommon) {
453
453
  * @param {CSN.Path} path
454
454
  * @returns {boolean}
455
455
  */
456
- function isUnion(path) {
456
+ function isUnion( path ) {
457
457
  const subquery = path[path.length - 1];
458
458
  const queryIndex = path[path.length - 2];
459
459
  const args = path[path.length - 3];
@@ -467,7 +467,7 @@ function isUnion(path) {
467
467
  * @param {object} col A column
468
468
  * @returns {object}
469
469
  */
470
- function stripLeadingSelf(col) {
470
+ function stripLeadingSelf( col ) {
471
471
  if (col.ref && col.ref.length > 1 && col.ref[0] === '$self')
472
472
  col.ref = col.ref.slice(1);
473
473
 
@@ -482,7 +482,7 @@ function stripLeadingSelf(col) {
482
482
  * @param {string} elementName
483
483
  * @returns {boolean}
484
484
  */
485
- function checkIsNotMixinByItself(query, columnMap, elementName) {
485
+ function checkIsNotMixinByItself( query, columnMap, elementName ) {
486
486
  if (query && query.SELECT && query.SELECT.mixin) {
487
487
  const col = columnMap[elementName];
488
488
 
@@ -506,7 +506,7 @@ function checkIsNotMixinByItself(query, columnMap, elementName) {
506
506
  * @param {Array} ref
507
507
  * @returns {string}
508
508
  */
509
- function getLastRefStepString(ref) {
509
+ function getLastRefStepString( ref ) {
510
510
  const last = ref[ref.length - 1];
511
511
  if (last.id)
512
512
  return last.id;