@sap/cds-compiler 5.5.0 → 5.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@
7
7
  Note: `beta` fixes, changes and features are usually not listed in this ChangeLog but [here](doc/CHANGELOG_BETA.md).
8
8
  The compiler behavior concerning `beta` features can change at any time without notice.
9
9
 
10
+ ## Version 5.5.2 - 2024-12-02
11
+
12
+ ### Fixed
13
+
14
+ - to.hdi|sql|edm[x]: Correctly handle `cds.Map`, ensure that it does not have `.elements` yet.
10
15
 
11
16
  ## Version 5.5.0 - 2024-11-22
12
17
 
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ const { hasNonEnumerable } = require('../utils/objectUtils');
4
+
5
+ /**
6
+ * We don't support cds.Map in conjunction with .elements yet. To ensure that no one uses it and accidentally creates an
7
+ * empty structured type, we check for it and forbid it.
8
+ *
9
+ * Non-enumerable .elements are added by cds.linked - we silently remove them and proceed as usual.
10
+ *
11
+ * @param {*} parent
12
+ * @param {*} prop
13
+ * @param {*} type
14
+ * @param {*} path
15
+ */
16
+ function checkCdsMap( parent, prop, type, path ) {
17
+ if (type === 'cds.Map' && parent.elements) {
18
+ if (hasNonEnumerable(parent, 'elements'))
19
+ delete parent.elements; // linked CSN sets a non-enumerable empty elements on cds.Map
20
+ else
21
+ this.error('type-unexpected-elements-for-map', path, { id: path.at(-1), type: 'cds.Map' }, 'Unexpected .elements for element $(ID) of type $(TYPE)');
22
+ }
23
+ }
24
+
25
+ module.exports = {
26
+ type: checkCdsMap,
27
+ };
@@ -26,6 +26,7 @@ const {
26
26
  checkTemporalAnnotationsAssignment,
27
27
  } = require('./annotationsOData');
28
28
  // both
29
+ const checkCdsMap = require('./cdsMap');
29
30
  const { validateOnCondition, validateMixinOnCondition } = require('./onConditions');
30
31
  const validateForeignKeys = require('./foreignKeys');
31
32
  const {
@@ -80,6 +81,7 @@ const forRelationalDBArtifactValidators = [
80
81
  ];
81
82
 
82
83
  const forRelationalDBCsnValidators = [
84
+ checkCdsMap,
83
85
  existsMustEndInAssoc,
84
86
  forbidAssocInExists,
85
87
  nonexpandableStructuredInExpression,
@@ -118,7 +120,7 @@ const forOdataArtifactValidators
118
120
  checkReadOnlyAndInsertOnly,
119
121
  ];
120
122
 
121
- const forOdataCsnValidators = [ nonexpandableStructuredInExpression ];
123
+ const forOdataCsnValidators = [ checkCdsMap, nonexpandableStructuredInExpression ];
122
124
 
123
125
  const forOdataQueryValidators = [];
124
126
 
@@ -917,6 +917,7 @@ function define( model ) {
917
917
  else {
918
918
  // a late syntax error (this code also runs with parse-cdl), i.e.
919
919
  // no semantic loc (wouldn't be available for expand/inline anyway)
920
+ // TODO: why here and not in parser?
920
921
  error( 'syntax-duplicate-wildcard', [ col.location, null ], {
921
922
  '#': (wildcard.location.col ? 'col' : 'std'),
922
923
  prop: '*',