@sap/cds-compiler 2.15.2 → 3.0.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 (111) hide show
  1. package/CHANGELOG.md +66 -1590
  2. package/bin/cdsc.js +42 -46
  3. package/doc/CHANGELOG_ARCHIVE.md +1592 -0
  4. package/doc/CHANGELOG_BETA.md +3 -4
  5. package/doc/CHANGELOG_DEPRECATED.md +35 -1
  6. package/doc/{DeprecatedOptions.md → DeprecatedOptions_v2.md} +3 -1
  7. package/doc/Versioning.md +20 -1
  8. package/lib/api/.eslintrc.json +2 -2
  9. package/lib/api/main.js +312 -143
  10. package/lib/api/options.js +15 -85
  11. package/lib/api/validate.js +6 -10
  12. package/lib/base/keywords.js +280 -110
  13. package/lib/base/message-registry.js +80 -24
  14. package/lib/base/messages.js +103 -52
  15. package/lib/base/model.js +44 -2
  16. package/lib/base/optionProcessorHelper.js +53 -21
  17. package/lib/checks/actionsFunctions.js +7 -5
  18. package/lib/checks/annotationsOData.js +1 -1
  19. package/lib/checks/cdsPersistence.js +1 -0
  20. package/lib/checks/elements.js +6 -6
  21. package/lib/checks/invalidTarget.js +1 -1
  22. package/lib/checks/nonexpandableStructured.js +1 -1
  23. package/lib/checks/queryNoDbArtifacts.js +2 -1
  24. package/lib/checks/selectItems.js +5 -1
  25. package/lib/checks/types.js +4 -2
  26. package/lib/checks/utils.js +2 -2
  27. package/lib/checks/validator.js +2 -1
  28. package/lib/compiler/assert-consistency.js +15 -10
  29. package/lib/compiler/builtins.js +127 -10
  30. package/lib/compiler/define.js +6 -4
  31. package/lib/compiler/extend.js +63 -12
  32. package/lib/compiler/finalize-parse-cdl.js +20 -9
  33. package/lib/compiler/index.js +25 -11
  34. package/lib/compiler/moduleLayers.js +7 -0
  35. package/lib/compiler/populate.js +16 -14
  36. package/lib/compiler/propagator.js +3 -3
  37. package/lib/compiler/resolve.js +194 -222
  38. package/lib/compiler/shared.js +56 -76
  39. package/lib/compiler/tweak-assocs.js +9 -10
  40. package/lib/compiler/utils.js +7 -2
  41. package/lib/edm/annotations/genericTranslation.js +60 -6
  42. package/lib/edm/annotations/preprocessAnnotations.js +10 -11
  43. package/lib/edm/csn2edm.js +39 -41
  44. package/lib/edm/edm.js +22 -15
  45. package/lib/edm/edmPreprocessor.js +66 -69
  46. package/lib/edm/edmUtils.js +12 -62
  47. package/lib/gen/Dictionary.json +8 -6
  48. package/lib/gen/language.checksum +1 -1
  49. package/lib/gen/language.interp +8 -30
  50. package/lib/gen/language.tokens +105 -114
  51. package/lib/gen/languageLexer.interp +1 -34
  52. package/lib/gen/languageLexer.js +889 -1007
  53. package/lib/gen/languageLexer.tokens +95 -106
  54. package/lib/gen/languageParser.js +20717 -22376
  55. package/lib/json/from-csn.js +73 -68
  56. package/lib/json/to-csn.js +13 -10
  57. package/lib/language/antlrParser.js +2 -2
  58. package/lib/language/docCommentParser.js +61 -38
  59. package/lib/language/errorStrategy.js +52 -40
  60. package/lib/language/genericAntlrParser.js +333 -259
  61. package/lib/language/language.g4 +600 -645
  62. package/lib/language/multiLineStringParser.js +14 -42
  63. package/lib/language/textUtils.js +44 -0
  64. package/lib/main.d.ts +27 -42
  65. package/lib/main.js +104 -81
  66. package/lib/model/csnRefs.js +2 -1
  67. package/lib/model/csnUtils.js +183 -285
  68. package/lib/model/revealInternalProperties.js +32 -9
  69. package/lib/model/sortViews.js +32 -31
  70. package/lib/optionProcessor.js +64 -57
  71. package/lib/render/.eslintrc.json +1 -1
  72. package/lib/render/DuplicateChecker.js +4 -7
  73. package/lib/render/manageConstraints.js +70 -2
  74. package/lib/render/toCdl.js +334 -339
  75. package/lib/render/toHdbcds.js +20 -16
  76. package/lib/render/toRename.js +44 -22
  77. package/lib/render/toSql.js +60 -54
  78. package/lib/render/utils/common.js +15 -1
  79. package/lib/render/utils/sql.js +20 -19
  80. package/lib/sql-identifier.js +6 -0
  81. package/lib/transform/db/.eslintrc.json +3 -2
  82. package/lib/transform/db/cdsPersistence.js +5 -15
  83. package/lib/transform/db/constraints.js +1 -1
  84. package/lib/transform/db/expansion.js +7 -6
  85. package/lib/transform/db/flattening.js +18 -19
  86. package/lib/transform/db/views.js +3 -3
  87. package/lib/transform/draft/.eslintrc.json +2 -2
  88. package/lib/transform/draft/db.js +6 -6
  89. package/lib/transform/draft/odata.js +6 -7
  90. package/lib/transform/forHanaNew.js +19 -22
  91. package/lib/transform/forOdataNew.js +13 -15
  92. package/lib/transform/localized.js +35 -25
  93. package/lib/transform/odata/toFinalBaseType.js +11 -9
  94. package/lib/transform/odata/typesExposure.js +3 -3
  95. package/lib/transform/odata/utils.js +1 -38
  96. package/lib/transform/transformUtilsNew.js +63 -77
  97. package/lib/transform/translateAssocsToJoins.js +6 -2
  98. package/lib/transform/universalCsn/.eslintrc.json +2 -2
  99. package/lib/transform/universalCsn/coreComputed.js +11 -6
  100. package/lib/transform/universalCsn/universalCsnEnricher.js +33 -5
  101. package/lib/utils/file.js +31 -21
  102. package/lib/utils/timetrace.js +20 -21
  103. package/package.json +34 -4
  104. package/share/messages/syntax-expected-integer.md +9 -8
  105. package/doc/ApiMigration.md +0 -237
  106. package/doc/CommandLineMigration.md +0 -58
  107. package/doc/ErrorMessages.md +0 -175
  108. package/doc/FioriAnnotations.md +0 -94
  109. package/doc/ODataTransformation.md +0 -273
  110. package/lib/backends.js +0 -529
  111. package/lib/fix_antlr4-8_warning.js +0 -56
@@ -1,175 +0,0 @@
1
- # Error Messages Explained
2
-
3
- > Status Oct 2019: up-to-date
4
-
5
- This document tries to explain some of the less-obvious error messages.
6
-
7
- ## Common Compiler Messages (Independent From Backend)
8
-
9
- ### Duplicate definitions
10
-
11
- In most cases, you really have just used the same name twice when defining an artifact.
12
- This section is about a situation where you are pretty sure that you have not done that.
13
-
14
- ```
15
- node_modules/Base/index.cds:1:6-7: Error: Duplicate definition of artifact "T"
16
- node_modules/base/index.cds:1:6-7: Error: Duplicate definition of artifact "T"
17
- node_modules/dep/node_modules/model/index.cds:1:8-9: Error: Duplicate definition of artifact "E"
18
- node_modules/model/index.cds:1:8-9: Error: Duplicate definition of artifact "E"
19
- ```
20
-
21
- Here, the CDS Compiler considers `…/Base/index.cds` to be different to `…/base/index.cds`,
22
- and also considers the two `…/model/index.cds` files to be different files.
23
- Why is that the case? Consider the following "top-level" file
24
-
25
- ```
26
- using from 'Base'; // upper-case 'B'!
27
- using from 'model';
28
- using from 'dep';
29
- ```
30
-
31
- File node_modules/dep/index.cds` looks like:
32
-
33
- ```
34
- using from 'base'; // lower-case 'b'!
35
- using from 'model';
36
- ```
37
-
38
- `node_modules/Base/index.cds` is the same file as
39
- `node_modules/base/index.cds` on case-insensitive file systems (Windows, Mac):
40
-
41
- ```
42
- type T: Integer;
43
- ```
44
-
45
- We have `node_modules/model/index.cds` and a copy of it in
46
- `node_modules/dep/node_modules/model/index.cds`:
47
-
48
- ```
49
- entity E { i: Integer; }
50
- ```
51
-
52
- The technical explanation is that the CDS Compiler considers
53
- two file names pointing to the same file if their `fs.realpath` is equal.
54
- That means that we properly _recognize symlinks_ (Linux, Mac),
55
- but we do _not_ recognize two files to be equal if:
56
-
57
- * the same file is referred to with different name casing,
58
- which does not work on case-sensitive file systems (Linux) anyway
59
- (yes, we might issue a better message when `node v9.2` is widely adopted),
60
- * a file is _copied_ within the NPM package (or when _hardlinks_ are used).
61
-
62
- The CDL code/package can be corrected as follows:
63
-
64
- * Use __consistent casing__ when referring to file and modules in `using from`
65
- (if in doubt, please check the error output provided by the CDS compiler client tool).
66
- * __Clean up a dirty NPM installation__. Then, the file
67
- `node_modules/dep/node_modules/model/index.cds` should disappear
68
- (or be a symlink to `node_modules/model/index.cds`).
69
-
70
-
71
- ### Nested extensions
72
-
73
- If you use nested extensions, you might get messages like:
74
-
75
- ```
76
- nested-extensions.cds:3:20-26: Error: No `EXTEND artifact` within CONTEXT extensions
77
- nested-extensions.cds:4:20-28: Error: No `ANNOTATE artifact` within SERVICE extensions
78
- nested-extensions.cds:5:14-22: Error: Elements only exist in entities, types or typed constructs
79
- nested-extensions.cds:6:12-36: Error: Elements only exist in entities, types or typed constructs
80
- ```
81
-
82
- Artifacts (entities, types, …) should not be extended within other extensions –
83
- just elements (and other members) are to be extended within an artifact extension.
84
- The above messages are reported for the following CDL code:
85
-
86
- ```
87
- context C { entity E { d: Integer; } }
88
- service S { entity E { d: Integer; } }
89
- extend context C { extend C.E { e: Integer; } }
90
- extend service S { annotate S.E @Anno; }
91
- annotate C { E @Anno; }
92
- extend S { extend E { e: Integer; } }
93
- ```
94
-
95
- The reason for these messages is – if we would allow it:
96
-
97
- * If we follow the [normal name resolution rules](NameResolution.md),
98
- people would have to refer to the entity the same way
99
- as outside `extend context`/`extend service`.
100
- Most people would probably expect being able
101
- to write just `E` instead `C.E`/`S.E` in line 3 and 4,
102
- but this not only require special rules, but leads to other surprises – see below.
103
- * Using `{ … }` inside a plain `annotate` or `extend` statement
104
- is supposed to annotate/extend elements (or enums), not containing artifacts.
105
-
106
- The CDL code can be corrected as follows:
107
-
108
- ```
109
- context C { entity E { d: Integer; } }
110
- service S { entity E { d: Integer; } }
111
- extend C.E { e: Integer; }
112
- annotate S.E @Anno;
113
- annotate C.E @Anno;
114
- extend S.E { e: Integer; }
115
- ```
116
-
117
- Now consider that you could use the following to extend the entity `C.E`:
118
-
119
- ```
120
- context C { entity E { key d: Integer; } }
121
- entity E { key x: Integer; }
122
- extend context C {
123
- extend E { e: Integer; } // i.e. extend C.E
124
- }
125
- extend context C {
126
- entity F { a: association to E; } // target: E, not C.E (normal name resolution)
127
- }
128
- ```
129
-
130
- What about combining the two `extend context`:
131
-
132
- ```
133
- context C { entity E { key d: Integer; } }
134
- entity E { key x: Integer; }
135
- extend context C {
136
- extend E { e: Integer; } // i.e. extend C.E
137
- entity F { a: association to E; } // target: E or C.E ?
138
- }
139
- ```
140
-
141
- In summary, allowing artifact extensions inside `extend context`/`extend service`
142
- would provide little benefit, but would add complexity and confusion.
143
-
144
-
145
- ### Redirection issues
146
-
147
- The target `OrigTarget` of an existing association can only be redirected to another target `NewTarget`
148
- if the `NewTarget` is a direct or indirect projection of `OrigTarget`
149
- (complex views are questionable and lead to a Warning),
150
- or an entity definition which directly or indirectly includes `OrigTarget`.
151
-
152
- ```
153
- entity Base {
154
- key i: Integer;
155
- }
156
- entity Proj as projection on Base;
157
- entity NewTarget as projection on Intermediate;
158
- entity Intermediate as projection on Base;
159
-
160
- entity Assocs {
161
- base: association to Base;
162
- proj: association to Proj;
163
- }
164
- entity Redirect as projection on Assocs {
165
- base: redirected to NewTarget, // works
166
- proj: redirected to NewTarget // ERROR: does not originate from Proj
167
- }
168
- ```
169
-
170
- For the above CDS code, you get the following error message:
171
-
172
- ```
173
- redirect-to-unrelated.cds:16:25-34: Error: The redirected target does not originate from "Proj"
174
- (in entity:"Redirect"/element:"proj")
175
- ```
@@ -1,94 +0,0 @@
1
- # Translation of Fiori annotations
2
-
3
- > Status Oct 2019: too vague, old links, to be moved to internalDoc if we want to keep it.
4
-
5
- Fiori annotations are translated in a generic way. Essentially, write down in CDS precisely what you want to get in edmx.
6
-
7
- A more detailed description will follow soon, for the time being we hope the following example will give the idea:
8
-
9
- These CDS annotations
10
- ```
11
- @(
12
- UI.Chart : {
13
- ChartType: #Bullet,
14
- Measures: [ Revenue ],
15
- MeasureAttributes: [
16
- {
17
- Measure: Revenue,
18
- Role: #Axis1,
19
- DataPoint: '@UI.DataPoint#BulletChartDataPoint'
20
- }
21
- ]
22
- },
23
- UI.DataPoint#BulletChartDataPoint: {
24
- Title: 'Product',
25
- Value: Revenue,
26
- TargetValue: TargetRevenue,
27
- ForecastValue: ForecastRevenue,
28
- MinimumValue: MinValue,
29
- MaximumValue: MaxValue,
30
- CriticalityCalculation: {
31
- ImprovementDirection: #Target,
32
- ToleranceRangeLowValue: ToleranceRangeLow,
33
- ToleranceRangeHighValue: ToleranceRangeHigh,
34
- DeviationRangeLowValue: DeviationRangeLow,
35
- DeviationRangeHighValue: DeviationRangeHigh
36
- }
37
- }
38
- )
39
- Something ...;
40
- ```
41
- are translated into the following edmx:
42
- ```xml
43
- <Annotations Target="Something">
44
- <Annotation Term="UI.Chart">
45
- <Record>
46
- <PropertyValue EnumMember="UI.ChartType/Bullet"
47
- Property="ChartType" />
48
- <PropertyValue Property="Measures">
49
- <Collection>
50
- <PropertyPath>Revenue</PropertyPath>
51
- </Collection>
52
- </PropertyValue>
53
- <PropertyValue Property="MeasureAttributes">
54
- <Collection>
55
- <Record Type="UI.ChartMeasureAttributeType">
56
- <PropertyValue Property="Measure" PropertyPath="Revenue" />
57
- <PropertyValue Property="Role" EnumMember="UI.ChartMeasureRoleType/Axis1" />
58
- <PropertyValue Property="DataPoint" AnnotationPath="@UI.DataPoint#BulletChartDataPoint" />
59
- </Record>
60
- </Collection>
61
- </PropertyValue>
62
- </Record>
63
- </Annotation>
64
- <Annotation Term="UI.DataPoint" Qualifier="BulletChartDataPoint">
65
- <Record>
66
- <PropertyValue String="Product" Property="Title" />
67
- <PropertyValue Path="Revenue" Property="Value" />
68
- <PropertyValue Path="TargetRevenue" Property="TargetValue" />
69
- <PropertyValue Path="ForecastRevenue" Property="ForecastValue" />
70
- <PropertyValue Path="MinValue" Property="MinimumValue" />
71
- <PropertyValue Path="MaxValue" Property="MaximumValue" />
72
- <PropertyValue Property="CriticalityCalculation">
73
- <Record>
74
- <PropertyValue Property="ImprovementDirection" EnumMember="UI.ImprovementDirectionType/Target" />
75
- <PropertyValue Path="ToleranceRangeLow" Property="ToleranceRangeLowValue" />
76
- <PropertyValue Path="ToleranceRangeHigh" Property="ToleranceRangeHighValue" />
77
- <PropertyValue Path="DeviationRangeLow" Property="DeviationRangeLowValue" />
78
- <PropertyValue Path="DeviationRangeHigh" Property="DeviationRangeHighValue" />
79
- </Record>
80
- </PropertyValue>
81
- </Record>
82
- </Annotation>
83
- </Annotations>
84
- ```
85
-
86
-
87
- All suppoted Fiori annotations are defined in the following vocabularies:
88
- * [Core](http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/vocabularies/Org.OData.Core.V1.xml)
89
- * [Measures](http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/vocabularies/Org.OData.Measures.V1.xml)
90
- * [Capabilities](http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/vocabularies/Org.OData.Capabilities.V1.xml)
91
- * [Aggregation](http://docs.oasis-open.org/odata/odata-data-aggregation-ext/v4.0/cs02/vocabularies/Org.OData.Aggregation.V1.xml)
92
- * [Common](https://wiki.scn.sap.com/wiki/download/attachments/448470974/Common.xml?api=v2)
93
- * [Communication](https://wiki.scn.sap.com/wiki/download/attachments/448470971/Communication.xml?api=v2)
94
- * [UI](https://wiki.scn.sap.com/wiki/download/attachments/448470968/UI.xml?api=v2)
@@ -1,273 +0,0 @@
1
- # ODATA Transformation
2
-
3
- > Status Oct 2019: outdated, uses old-style CSN, to be reworked completely -> move to internalDoc/.
4
- > For users, OData is a backend, they do not care too much that it works via a CSN transformation.
5
-
6
- Prior to the generation of EDMX (Entity Data Model XML) files from a CDS model,
7
- the following transformations are applied to the model. Most (but not all) of
8
- them become visible both in Augmented CSN and in Plain CSN:
9
-
10
- ## Generated foreign key fields for managed associations
11
-
12
- Managed associations do not have ON-conditions. Instead, they implicitly
13
- compare fields (usually the key fields) of the association's target entity with
14
- foreign key fields automatically generated into the entity containing the
15
- association.
16
-
17
- ### Creating the generated fields
18
-
19
- The ODATA transformation adds the generated foreign key fields to the model.
20
- The names of the generated foreign key fields are a concatenation of the
21
- association element name, an underscore, and the key name or its alias.
22
-
23
- Each generated foreign key field gets the name of the corresponding association
24
- as an annotation `@odata.foreignKey4`.
25
-
26
- _FIXME_: Do we want to keep that?
27
-
28
- For example, for the three association elements `a1`, `a2` and `a3` in the
29
- following snippet:
30
-
31
- ```
32
- service S {
33
- entity FromEntity {
34
- a1 : association to ToEntity; // Use target's keys
35
- a2 : association to ToEntity {x}; // Explicitly specified key
36
- a3 : association to ToEntity {x as z}; // Key with alias
37
- }
38
-
39
- entity ToEntity {
40
- key x : Integer;
41
- key y : Integer;
42
- }
43
- }
44
- ```
45
-
46
- the ODATA transformation would generate foreign key fields in the resulting CSN
47
- as follows (shown here in CDS source form):
48
-
49
- ```
50
- entity FromEntity {
51
- a1 : association to ToEntity;
52
- a2 : association to ToEntity {x};
53
- @odata.foreignKey4: 'a1'
54
- a1_x : Integer; // Generated foreign key
55
- @odata.foreignKey4: 'a1'
56
- a1_y : Integer; // Generated foreign key
57
- @odata.foreignKey4: 'a2'
58
- a2_x : Integer; // Generated foreign key
59
- @odata.foreignKey4: 'a3'
60
- a3_z : Integer; // Generated foreign key
61
- }
62
- ```
63
-
64
- It is an error if the generated fields conflict with existing fields.
65
-
66
- ### Annotation propagation
67
-
68
- The ODATA transformation propagates all annotations from the association to all
69
- its generated foreign key fields.
70
-
71
- _FIXME_: Do we want to keep that?
72
-
73
- ### Connecting the associations with the generated fields
74
-
75
- The CSN for the managed association elements contains a `foreignKeys` property,
76
- which is a dictionary of foreign key names (taken from the target key names, or
77
- from explicitly specified keys resp. their aliases) to the foreign key
78
- properties.
79
-
80
- The ODATA transformation adds a `generatedFieldName` property to each foreign
81
- key, containing the name of the generated foreign key field. Together with the
82
- `@odata.foreignKey4` annotation described above, this provides a bi-directional
83
- link between the association and its generated field.
84
-
85
- For the example shown above, the CSN for the three association elements `a1`,
86
- `a2` and `a3` would look as follows:
87
-
88
- ```
89
- "a1": {
90
- "indexNo": 1,
91
- "target": "S.ToEntity",
92
- "type": "cds.Association",
93
- "foreignKeys": {
94
- "x": {
95
- "indexNo": 1,
96
- "path": "x",
97
- "generatedFieldName": "a1_x"
98
- },
99
- "y": {
100
- "indexNo": 2,
101
- "path": "y",
102
- "generatedFieldName": "a1_y"
103
- }
104
- }
105
- },
106
- "a2": {
107
- "indexNo": 2,
108
- "target": "S.ToEntity",
109
- "type": "cds.Association",
110
- "foreignKeys": {
111
- "x": {
112
- "path": "x",
113
- "indexNo": 1,
114
- "generatedFieldName": "a2_x"
115
- }
116
- }
117
- },
118
- "a3": {
119
- "indexNo": 3,
120
- "target": "S.ToEntity",
121
- "type": "cds.Association",
122
- "foreignKeys": {
123
- "z": {
124
- "path": "x",
125
- "indexNo": 1,
126
- "generatedFieldName": "a3_z"
127
- }
128
- }
129
- },
130
- ```
131
-
132
- ## (Augmented CSN only): Adding `_service` to exposed artifacts
133
-
134
- For each artifact that is exposed by a service (including the service itself),
135
- the ODATA transformation adds a non-enumerable property `_service` to the
136
- artifact in the Augmented CSN model, containing a link to the corresponding
137
- service artifact.
138
-
139
- This is convenient for EDMX processors that want to process only exposed
140
- artifacts or only artifacts belonging to a specific service.
141
-
142
- ## Implicit redirection for non-exposed association targets
143
-
144
- For each exposed artifact that contains associations, it is checked that the
145
- association target is also exposed by the same service. If this is not the
146
- case, the ODATA transformation tries to find an "exposed representative" of
147
- the target, i.e. an exposed projection or view on the target, or an exposed entity
148
- that includes the target. If such a representative is found and unique, the
149
- association is implicitly redirected to the exposed representative.
150
-
151
- Note that only projections and projection-like views (i.e. those that have a
152
- single `from` source without `union`, `join` or nested queries) are considered
153
- as implicit redirection targets.
154
-
155
- Example:
156
-
157
- ```
158
- // All these entities are used as association targets below
159
- // Simple target
160
- entity E1 {
161
- key id : Integer;
162
- }
163
- // Base target included by E2a
164
- entity E2 {
165
- key id : Integer;
166
- }
167
- entity E2a : E2 {
168
- s : String(10);
169
- }
170
- // Base target included by S.E3a
171
- entity E3 {
172
- key id : Integer;
173
- }
174
-
175
- // Exposure in service
176
- service S {
177
- entity P1 as projection on E1; // Exposes simple target E1
178
- entity P2a as projection on E2a; // Exposes E2a but also its included E2
179
- entity E3a : E3 { }; // Exposes included E3
180
-
181
- entity Redirected {
182
- toE1 : association to E1; // Implicitly redirected to P1 (projection exposes E1)
183
- toE2 : association to E2; // Implicitly redirected to P2a (projection exposes something that includes E2)
184
- toE3 : association to E3; // Implicitly redirected to E3a (entity includes E3)
185
- }
186
- }
187
- ```
188
-
189
- ## Exposure checking
190
-
191
- Currently, it is assumed that services must be self-contained, i.e. that all
192
- associations within a service must point to targets also exposed by this
193
- service. This is checked by the ODATA transformation.
194
-
195
- _FIXME: The same restriction will probably apply when structured types are
196
- allowed as element types within exposed entities._
197
-
198
- ## Unraveling derived scalar types
199
-
200
- The ODATA transformation unravels derived scalar types, i.e. primitive types
201
- for which the user has provided a custom name (possibly multiple times in a
202
- chain) are replaced by the original primitive type. Annotations are propagated
203
- upwards in the chain from the primitive type to the most derived type.
204
-
205
- For example, the following CDS source
206
-
207
- ```
208
- @IsName: true
209
- type Name : String(20);
210
-
211
- @IsCustomer: true
212
- type CustomerName : Name;
213
-
214
- service S {
215
- entity E {
216
- name : CustomerName;
217
- }
218
- }
219
- ```
220
-
221
- essentially behaves as if the user had written
222
-
223
- ```
224
- service S {
225
- entity E {
226
- @IsCustomer: true
227
- @IsName: true
228
- name : String(20);
229
- }
230
- }
231
- ```
232
-
233
- ## (Tentative): Checking ON-conditions
234
-
235
- Currently, the ODATA transformation checks for various restrictions regarding
236
- ON-conditions of unmanaged associations:
237
-
238
- - only `=` and `AND` operators may be used
239
- - operands may only be paths or values (not expressions)
240
- - exactly one of the operands must traverse the association
241
-
242
- The intention behind this restriction is to produce a meaningful value for the
243
- `ReferentialConstraint` of the resulting `NavigationProperty`.
244
-
245
- _FIXME_: Do we want to keep that?
246
-
247
- ## (Tentative): Renaming annotations
248
-
249
- Currently, the ODATA transformation renames various "shorthand" annotations to
250
- their more elaborate "long form".
251
-
252
- | Original name | New name |
253
- | -------------------------- | --------------------------------------------- |
254
- | `@label` | `@Common.Label` |
255
- | `@label` | `@Common.Label` |
256
- | `@title` | `@Common.Label` |
257
- | `@ValueList.entity` | `@Common.ValueList.entity` |
258
- | `@ValueList.type` | `@Common.ValueList.type` |
259
- | `@Capabilities.Deletable` | `@Capabilities.DeleteRestrictions.Deletable` |
260
- | `@Capabilities.Insertable` | `@Capabilities.InsertRestrictions.Insertable` |
261
- | `@Capabilities.Updatable` | `@Capabilities.UpdateRestrictions.Updatable` |
262
- | `@readonly` | `@Core.Immutable` |
263
- | `@important` | `@UI.Importance` |
264
- | `@assert.format` | `@Validation.pattern: value` |
265
- | `@assert.range` | `@Validation.Minimum/Maximum: value` |
266
- | | or `@Validation.AllowedValues: {` |
267
- | | `@Core.SymbolicName: enum-name }` |
268
-
269
-
270
- For the annotation `@important` (which is renamed to `@UI.Importance`), the
271
- values `true`/`false` are also replaced by the enum constants `#High`/`#Low`.
272
-
273
- _FIXME_: Do we want to keep that?