@sap/cds-compiler 6.9.3 → 7.0.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.
- package/CHANGELOG.md +76 -2
- package/bin/cdsc.js +4 -33
- package/doc/IncompatibleChanges_v7.md +639 -0
- package/lib/api/main.js +4 -56
- package/lib/api/options.js +5 -15
- package/lib/api/validate.js +1 -0
- package/lib/base/builtins.js +1 -2
- package/lib/base/csnRefs.js +2 -6
- package/lib/base/message-registry.js +82 -76
- package/lib/base/messages.js +8 -5
- package/lib/base/optionProcessor.js +2 -72
- package/lib/base/specialOptions.js +20 -17
- package/lib/checks/defaultValues.js +1 -39
- package/lib/checks/hasPersistedElements.js +19 -3
- package/lib/checks/parameters.js +0 -34
- package/lib/checks/selectItems.js +2 -38
- package/lib/checks/typeParameters.js +162 -0
- package/lib/checks/validator.js +5 -8
- package/lib/compiler/assert-consistency.js +19 -5
- package/lib/compiler/checks.js +47 -43
- package/lib/compiler/define.js +6 -6
- package/lib/compiler/extend.js +102 -111
- package/lib/compiler/generate.js +4 -8
- package/lib/compiler/populate.js +4 -7
- package/lib/compiler/propagator.js +9 -9
- package/lib/compiler/resolve.js +205 -7
- package/lib/compiler/shared.js +76 -82
- package/lib/compiler/tweak-assocs.js +102 -22
- package/lib/compiler/utils.js +57 -12
- package/lib/compiler/xpr-rewrite.js +2 -15
- package/lib/edm/annotations/edmJson.js +14 -10
- package/lib/edm/annotations/genericTranslation.js +3 -1
- package/lib/edm/annotations/preprocessAnnotations.js +9 -26
- package/lib/edm/csn2edm.js +27 -20
- package/lib/edm/edmUtils.js +25 -0
- package/lib/gen/CdlGrammar.checksum +1 -1
- package/lib/gen/CdlParser.js +2237 -2241
- package/lib/gen/Dictionary.json +17 -2
- package/lib/json/from-csn.js +67 -52
- package/lib/json/to-csn.js +28 -25
- package/lib/language/textUtils.js +0 -13
- package/lib/main.d.ts +22 -59
- package/lib/main.js +1 -1
- package/lib/model/csnUtils.js +9 -8
- package/lib/parsers/AstBuildingParser.js +45 -55
- package/lib/parsers/Lexer.js +2 -0
- package/lib/parsers/identifiers.js +0 -9
- package/lib/render/toCdl.js +41 -40
- package/lib/render/toSql.js +8 -1
- package/lib/render/utils/common.js +1 -1
- package/lib/render/utils/sql.js +2 -3
- package/lib/tool-lib/enrichCsn.js +1 -2
- package/lib/transform/db/applyTransformations.js +7 -5
- package/lib/transform/db/assertUnique.js +8 -51
- package/lib/transform/db/associations.js +1 -1
- package/lib/transform/db/cdsPersistence.js +1 -15
- package/lib/transform/db/expansion.js +9 -12
- package/lib/transform/db/flattening.js +1 -1
- package/lib/transform/db/groupByOrderBy.js +0 -16
- package/lib/transform/db/views.js +57 -161
- package/lib/transform/draft/db.js +2 -2
- package/lib/transform/forOdata.js +25 -14
- package/lib/transform/forRelationalDB.js +93 -301
- package/lib/transform/localized.js +33 -102
- package/lib/transform/odata/flattening.js +11 -2
- package/lib/transform/transformUtils.js +25 -3
- package/lib/transform/universalCsn/universalCsnEnricher.js +1 -2
- package/package.json +2 -2
- package/lib/render/toHdbcds.js +0 -1810
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
# Incompatible Changes in CDS Compiler Version 7
|
|
2
|
+
|
|
3
|
+
This document lists (potentially) incompatible changes
|
|
4
|
+
which came with Compiler Version 7.
|
|
5
|
+
|
|
6
|
+
<!-- toc: start -->
|
|
7
|
+
|
|
8
|
+
1. [Preamble](#preamble)
|
|
9
|
+
2. [Summary](#summary)
|
|
10
|
+
3. [General](#general)
|
|
11
|
+
1. [Increase Required Node.js Version to 22](#increase-required-nodejs-version-to-22)
|
|
12
|
+
2. [Remove HDBCDS backend](#remove-hdbcds-backend)
|
|
13
|
+
3. [Remove old deprecated flags](#remove-old-deprecated-flags)
|
|
14
|
+
4. [Changes in CDL and CSN parser](#changes-in-cdl-and-csn-parser)
|
|
15
|
+
1. [syntax-unsupported-masked](#syntax-unsupported-masked)
|
|
16
|
+
5. [Changes in Core Compiler](#changes-in-core-compiler)
|
|
17
|
+
1. [name-deprecated-$self](#name-deprecated-self)
|
|
18
|
+
2. [String representation for expression-like annotation values](#string-representation-for-expression-like-annotation-values)
|
|
19
|
+
3. [Default for structures](#default-for-structures)
|
|
20
|
+
4. [Default for arrays)](#default-for-arrays-ic-v7-33)
|
|
21
|
+
5. [Extend builtin with type properties](#extend-builtin-with-type-properties)
|
|
22
|
+
6. [Key propagation](#key-propagation)
|
|
23
|
+
7. [Annotate with invalid target](#annotate-with-invalid-target)
|
|
24
|
+
8. [Duplicate element via extend with aspect](#duplicate-element-via-extend-with-aspect)
|
|
25
|
+
9. [Extend ... with definitions](#extend--with-definitions)
|
|
26
|
+
10. [Propagate value null](#propagate-value-null)
|
|
27
|
+
11. [Expression as UP TO value](#expression-as-up-to-value)
|
|
28
|
+
12. [Associations defined via backlink associations](#associations-defined-via-backlink-associations)
|
|
29
|
+
6. [Changes in OData/EDM](#changes-in-odataedm)
|
|
30
|
+
1. [Vocabulary change for Common.SideEffectsType](#vocabulary-change-for-commonsideeffectstype)
|
|
31
|
+
7. [Changes in to.sql()](#changes-in-tosql)
|
|
32
|
+
1. [Remove option to generate transitive localized views](#remove-option-to-generate-transitive-localized-views)
|
|
33
|
+
2. [Change type mapping for Decimal on SQLite](#change-type-mapping-for-decimal-on-sqlite)
|
|
34
|
+
|
|
35
|
+
<!-- toc: end -->
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Preamble
|
|
40
|
+
|
|
41
|
+
Major versions are used to clean up things that could potentially break existing user code.
|
|
42
|
+
Such changes always have a reason, and we don't introduce them "just for the sake of it".
|
|
43
|
+
|
|
44
|
+
## Summary
|
|
45
|
+
|
|
46
|
+
| Title | Cat | Prob |
|
|
47
|
+
| ----------------------------------- | --- | -------- |
|
|
48
|
+
| Remove HDBCDS backend | 1 | very low |
|
|
49
|
+
| Remove old deprecated flags | 1 | very low |
|
|
50
|
+
| syntax-unsupported-masked | 1 | very low |
|
|
51
|
+
| name-deprecated-$self | 1 | very low |
|
|
52
|
+
| String representation for anno-xpr | 4 | low |
|
|
53
|
+
| Default for structures | 2 | low |
|
|
54
|
+
| Default for arrays | 2 | low |
|
|
55
|
+
| Extend builtin with type properties | 2 | very low |
|
|
56
|
+
| Key propagation | 3 | low |
|
|
57
|
+
| Sec-Annotate with invalid target | 2 | high |
|
|
58
|
+
| Duplicate elem by extend w/ aspect | 2 | low |
|
|
59
|
+
| Extend ... with definitions | 4 | zero |
|
|
60
|
+
| Propagate value null | 4 | very low |
|
|
61
|
+
| Expression as UP TO value | 2+4 | low |
|
|
62
|
+
| Associations via backlink | 2 | low |
|
|
63
|
+
| OData: Common.SideEffectsType | 5 | low |
|
|
64
|
+
| SQL: Transitive localized views | 5 | very low |
|
|
65
|
+
| SQL: Decimal on SQLite | 3 | ? |
|
|
66
|
+
|
|
67
|
+
Category:
|
|
68
|
+
* 1: remove an _undocumented_ switch that was used to avoid an error or to get back an old behavior
|
|
69
|
+
* 2: new error, model must be fixed
|
|
70
|
+
* 3: changed behavior
|
|
71
|
+
* 4: changed CSN
|
|
72
|
+
* 5: other
|
|
73
|
+
|
|
74
|
+
Prob: probability that change has a _negative_ impact on projects that _requires_ an action
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
## General
|
|
79
|
+
|
|
80
|
+
### Increase Required Node.js Version to 22
|
|
81
|
+
|
|
82
|
+
Node.js 20 reached EOL in April 2026. Accordingly, we require Node.js 22 starting with cds-compiler v7.
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
### Remove HDBCDS backend
|
|
86
|
+
|
|
87
|
+
Only relevant for HANA on-prem (or "old" HaaS), as HANA CDS is not available on HANA Cloud.
|
|
88
|
+
|
|
89
|
+
In the early days of CAP, the only possibility to generate the DB schema was via
|
|
90
|
+
the hdbcds backend (i.e. generating and deploying HANA CDS files).
|
|
91
|
+
|
|
92
|
+
Since cds-compiler v1.5 the DB backend could alternatively be generated via hdbtable/hdbview,
|
|
93
|
+
while for new projects the default still was hdbcds.
|
|
94
|
+
With CDS 7 (cds-compiler v4), the default was switched to hdbtable,
|
|
95
|
+
see [Release Notes June 2023](https://cap.cloud.sap/docs/releases/2023/jun23#deploy-format-hdbtable).
|
|
96
|
+
|
|
97
|
+
For regular CAP projects on HANA, there is no need to use the hdbcds backend any longer.
|
|
98
|
+
They should migrate to hdbtable.
|
|
99
|
+
|
|
100
|
+
We started deprecation in v5 with issuing a warning when the hdbcds backend was invoked:
|
|
101
|
+
* capire [release notes June 2024](https://cap.cloud.sap/docs/releases/2024/jun24#deprecation-of-deploy-format-hdbcds)
|
|
102
|
+
* [Migration guide](https://cap.cloud.sap/docs/cds/compiler/hdbcds-to-hdbtable)
|
|
103
|
+
|
|
104
|
+
This warning was raised to a (configurable) error `api-deprecated-hdbcds` in v6:
|
|
105
|
+
* capire [release notes May 2025](https://cap.cloud.sap/docs/releases/2025/may25#removed-hdbcds-format)
|
|
106
|
+
|
|
107
|
+
Now, in v7, we remove the code for the hdbcds backend.
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
### Remove old deprecated flags
|
|
111
|
+
|
|
112
|
+
We removed deprecated flags `noPersistenceJournalForGeneratedEntities` and
|
|
113
|
+
`noCompositionIncludes`.
|
|
114
|
+
If you really still need them, please let us know (and give some reasons for your wish).
|
|
115
|
+
|
|
116
|
+
All hidden deprecated flags (i.e. those listed as removed before,
|
|
117
|
+
but actually having been just renamed) are now really removed.
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
## Changes in CDL and CSN parser
|
|
121
|
+
|
|
122
|
+
### syntax-unsupported-masked
|
|
123
|
+
|
|
124
|
+
Keyword masked is not supported.
|
|
125
|
+
|
|
126
|
+
```cds
|
|
127
|
+
entity E {
|
|
128
|
+
key id : Integer;
|
|
129
|
+
masked val : String(22);
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
It was ...
|
|
134
|
+
* introduced in first compiler versions on request by TNT, but never documented
|
|
135
|
+
* made an error (configurable) already in cds-compiler v3.
|
|
136
|
+
|
|
137
|
+
The error could be downgraded with
|
|
138
|
+
```sh
|
|
139
|
+
cdsc b51.<file> --warn syntax-unsupported-masked --deprecated downgradableErrors
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
In cds-compiler v7:
|
|
143
|
+
As we don't plan to support `masked` in the near future, we make it
|
|
144
|
+
an unconfigurable error by removing it from the syntax.
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
## Changes in Core Compiler
|
|
148
|
+
|
|
149
|
+
### name-deprecated-$self
|
|
150
|
+
|
|
151
|
+
`$self` should not be used as name for an artifact definition.
|
|
152
|
+
|
|
153
|
+
In cds-compiler v5, we introduced a configurable error,
|
|
154
|
+
see [Release Notes](https://cap.cloud.sap/docs/releases/2024/jun24#no-definition-named-self).
|
|
155
|
+
|
|
156
|
+
Example:
|
|
157
|
+
```cds
|
|
158
|
+
entity $self {
|
|
159
|
+
key id : Integer; // err: name-deprecated-$self
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The error could be downgraded with
|
|
164
|
+
```sh
|
|
165
|
+
cdsc <file> --warn name-deprecated-$self
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
In cds-compiler v7, we make `name-deprecated-$self` a non-configurable error.
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
### String representation for expression-like annotation values
|
|
172
|
+
|
|
173
|
+
Before cds-compiler v7:
|
|
174
|
+
The CSN representation of an expression-like annotation value is an object with
|
|
175
|
+
properties `=` and one of `ref`, `xpr`, `val`, `func`, `SELECT`, `list`.
|
|
176
|
+
In `=` we capture the (space-normalized, comments removed) string representation of the expression,
|
|
177
|
+
the other one holds the parsed expression as a token stream.
|
|
178
|
+
|
|
179
|
+
When the annotation is propagated ...
|
|
180
|
+
* the token stream representation is rewritten, if necessary
|
|
181
|
+
* if the expression is a path/reference (`ref`), the string representation is rewritten, too
|
|
182
|
+
(including paths with filter)
|
|
183
|
+
* for all other expressions: if no rewriting is necessary, the string representation in `=` is kept,
|
|
184
|
+
otherwise it is set to `true`
|
|
185
|
+
|
|
186
|
+
Remark: for CSN input, there is no check that the string actually corresponds
|
|
187
|
+
to the CSN representation of the expression provided in sibling properties of `=`;
|
|
188
|
+
CSN consumers are advised not to rely on the value of `=`.
|
|
189
|
+
|
|
190
|
+
Example:
|
|
191
|
+
```cds
|
|
192
|
+
@Anno: (a+b)
|
|
193
|
+
entity E {
|
|
194
|
+
key id : Integer;
|
|
195
|
+
a : Integer;
|
|
196
|
+
b : Integer;
|
|
197
|
+
}
|
|
198
|
+
entity P as projection on E { a as x, b as y};
|
|
199
|
+
```
|
|
200
|
+
Resulting CSN:
|
|
201
|
+
```jsonc
|
|
202
|
+
{
|
|
203
|
+
"definitions": {
|
|
204
|
+
"E": {
|
|
205
|
+
"kind": "entity",
|
|
206
|
+
"@Anno": {
|
|
207
|
+
"=": "a+b",
|
|
208
|
+
"xpr": [ { "ref": ["a"] }, "+", { "ref": ["b"] } ]
|
|
209
|
+
},
|
|
210
|
+
"elements": { /*...*/ }
|
|
211
|
+
},
|
|
212
|
+
"P": {
|
|
213
|
+
"kind": "entity",
|
|
214
|
+
"@Anno": {
|
|
215
|
+
"=": true,
|
|
216
|
+
"xpr": [ { "ref": ["x"] }, "+", { "ref": ["y"] } ]
|
|
217
|
+
},
|
|
218
|
+
"projection": { /*...*/ }, "elements": { /*...*/ }
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
In cds-compiler v7:
|
|
225
|
+
* For anno-xpr that are a simple ref (simple: can be path, but no filter, no parameters), keep current behavior:
|
|
226
|
+
- Keep both `=` and `ref`.
|
|
227
|
+
- When rewriting is necessary, also adapt the `=`.
|
|
228
|
+
* For all other expressions:
|
|
229
|
+
- Remove the `=`
|
|
230
|
+
+ both in original and in propagated annotations
|
|
231
|
+
+ no matter whether rewriting is necessary or not
|
|
232
|
+
|
|
233
|
+
With the removal of `=`, any object with a `ref` or `xpr` or `val` inside an array
|
|
234
|
+
is regarded as an expression value. This could introduce ambiguities. Outside arrays
|
|
235
|
+
there is no danger of ambiguity due to flattening.
|
|
236
|
+
To avoid such ambiguities in CDL, the parser in v7 throws an error for "ambiguous" sources like
|
|
237
|
+
```cds
|
|
238
|
+
@A_xpr: [(2*foo)]
|
|
239
|
+
@A_str: [{xpr: [{val: 2}, '*', {ref: ['foo']}]}]
|
|
240
|
+
entity E { foo : Integer; }
|
|
241
|
+
```
|
|
242
|
+
For: ref, xpr, val, func, SELECT, list.
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
### Default for structures
|
|
246
|
+
|
|
247
|
+
Before cds-compiler v7:
|
|
248
|
+
Providing a default value for a structured element resulted in a warning, the default was ignored in backends.
|
|
249
|
+
|
|
250
|
+
```cds
|
|
251
|
+
type T : {
|
|
252
|
+
a : String;
|
|
253
|
+
b : Integer;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
entity E {
|
|
257
|
+
field : T default 22; // v6: warning, ignored in SQL and OData
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
This is an inconsistent situation:
|
|
262
|
+
* default for a structured element causes a warning,
|
|
263
|
+
the default value is ignored by SQL and OData backend (even if `T` has only one element)
|
|
264
|
+
* one-element struct comparisons with a scalar are allowed
|
|
265
|
+
* a `default` for a managed association with one foreign key is allowed
|
|
266
|
+
|
|
267
|
+
In cds-compiler v7:
|
|
268
|
+
* for structs with one leaf element:
|
|
269
|
+
- allow in compiler, remove the warning
|
|
270
|
+
- add the default in SQL/OData (like for managed assoc)
|
|
271
|
+
* for structs with more than one leaf element
|
|
272
|
+
- configurable compiler error
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
### Default for arrays
|
|
276
|
+
|
|
277
|
+
Before cds-compiler v7:
|
|
278
|
+
Providing a default value for an array element is accepted and reflected (illegally) in the runtimes.
|
|
279
|
+
|
|
280
|
+
```cds
|
|
281
|
+
type T : array of Integer;
|
|
282
|
+
|
|
283
|
+
entity E {
|
|
284
|
+
field : T default 22;
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Default is recorded in CSN.
|
|
289
|
+
|
|
290
|
+
Resulting OData - is illegal according to CSN spec:
|
|
291
|
+
```xml
|
|
292
|
+
<Property Name="field" Type="Collection(S.T)" Nullable="true" DefaultValue="22"/>
|
|
293
|
+
```
|
|
294
|
+
Resulting SQL - probably this doesn't work:
|
|
295
|
+
```sql
|
|
296
|
+
field NCLOB DEFAULT 22,
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
Note: providing a default for an array element defined inline is syntactically forbidden:
|
|
301
|
+
```cds
|
|
302
|
+
entity E {
|
|
303
|
+
field : array of Integer default 22;
|
|
304
|
+
}
|
|
305
|
+
// -> Error[syntax-unexpected-token]: Mismatched ‘default’, expecting ...
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
In cds-compiler v7:
|
|
309
|
+
providing a default value for an array element is an error.
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
### Extend builtin with type properties
|
|
313
|
+
|
|
314
|
+
Before cds-compiler v7:
|
|
315
|
+
Extend statements that add type properties to builtin types are ignored.
|
|
316
|
+
|
|
317
|
+
Example:
|
|
318
|
+
```cds
|
|
319
|
+
extend cds.String with (length: 39); // is ignored
|
|
320
|
+
extend cds.Integer with (length: 39); // is ignored
|
|
321
|
+
```
|
|
322
|
+
Such extends are highly dubious, in particular the second one, which sets a property that
|
|
323
|
+
doesn't exist for the type.
|
|
324
|
+
|
|
325
|
+
In cds-compiler v7,
|
|
326
|
+
the compiler throws configurable errors for these situations.
|
|
327
|
+
Planned to make non-configurable in v8.
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
### Key propagation
|
|
331
|
+
|
|
332
|
+
Before cds-compiler v7:
|
|
333
|
+
A view or projection inherits the key of the underlying base entity, if ...
|
|
334
|
+
* no explicit key is set in the query
|
|
335
|
+
* all key elements of the primary base entity are selected
|
|
336
|
+
* no union, join or similar query construct is used
|
|
337
|
+
* no path expression with a to-many association is used
|
|
338
|
+
|
|
339
|
+
(key = the entirety of the key elements)
|
|
340
|
+
|
|
341
|
+
Essentially this means: we propagate the key only in situations
|
|
342
|
+
where we are (almost) sure that the result is a valid key. "Almost", because
|
|
343
|
+
a path with a to-many association isn't recognized inside an expression.
|
|
344
|
+
|
|
345
|
+
These rules are unnecessarily complex.
|
|
346
|
+
|
|
347
|
+
In cds-compiler v7:
|
|
348
|
+
Simplify rules: a view or projection inherits the key of the
|
|
349
|
+
underlying base entity, if ...
|
|
350
|
+
* no explicit key is set in the query
|
|
351
|
+
* all key elements of the primary base entity and all key elements of joined
|
|
352
|
+
entities are selected
|
|
353
|
+
|
|
354
|
+
Note: second rule is very strict, as oftentimes not all key elements of the target need
|
|
355
|
+
to be selected because they are tied to a key element of the source via the ON condition.
|
|
356
|
+
In these situations no key is propagated and we basically have the same situation as before v7.
|
|
357
|
+
|
|
358
|
+
This change means:
|
|
359
|
+
we would propagate the key also in many situations where we are not sure the
|
|
360
|
+
result is a valid key.
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
### Annotate with invalid target
|
|
364
|
+
|
|
365
|
+
Before cds-compiler v7:
|
|
366
|
+
An annotate statement with an invalid (i.e. non-existing) target results in a warning.
|
|
367
|
+
|
|
368
|
+
Only for the security related annotations `@restrict`, `@requires`, and `@ams` we issue a configurable error
|
|
369
|
+
since cds-compiler 6.5 (see [capire Release Notes November 2025](https://pages.github.tools.sap/cap/docs/releases/2025/nov25#security-annotations)).
|
|
370
|
+
Note that there are three different error ids/error messages.
|
|
371
|
+
|
|
372
|
+
Example:
|
|
373
|
+
```cds
|
|
374
|
+
service S {
|
|
375
|
+
entity Foo {
|
|
376
|
+
bar : Integer;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
annotate S.FooX with @restrict: [{ grant:['WRITE'], to: ['Admin'] }];
|
|
381
|
+
// -> Error[ext-undefined-def-sec]: Artifact “S.FooX” has not been found
|
|
382
|
+
|
|
383
|
+
annotate SX.Foo with @restrict: [{ grant:['WRITE'], to: ['Admin'] }];
|
|
384
|
+
// -> Error[ext-undefined-art-sec]: No artifact has been found with name “SX”
|
|
385
|
+
|
|
386
|
+
annotate S.Foo:barX with @ams.attributes: (bar);
|
|
387
|
+
// -> Error[ext-undefined-element-sec]: Element “barX” has not been found
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
In v7, we additionally
|
|
391
|
+
* consolidated the messages: `ext-undefined-art-sec` now is `ext-undefined-def-sec`
|
|
392
|
+
* closed a gap, where we before missed some invalid `annotate` statements
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
### Duplicate element via extend with aspect
|
|
396
|
+
|
|
397
|
+
Before cds-compiler v7:
|
|
398
|
+
If the same element gets into an entity via two direct includes, the compiler issues an error.
|
|
399
|
+
|
|
400
|
+
Example:
|
|
401
|
+
```cds
|
|
402
|
+
aspect A { field : String; }
|
|
403
|
+
aspect B { field : String; }
|
|
404
|
+
|
|
405
|
+
entity E : A, B {
|
|
406
|
+
name: Integer;
|
|
407
|
+
}
|
|
408
|
+
```
|
|
409
|
+
-> Error[`duplicate-definition`]: Duplicate element “field” through multiple includes “A”, “B”
|
|
410
|
+
|
|
411
|
+
If the aspects are applied to the entity via `extend`, the compiler accepts this.
|
|
412
|
+
|
|
413
|
+
Example:
|
|
414
|
+
```cds
|
|
415
|
+
aspect A { field : String; }
|
|
416
|
+
aspect B { field : Date; }
|
|
417
|
+
|
|
418
|
+
entity E {
|
|
419
|
+
name: Integer;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
extend E with A;
|
|
423
|
+
extend E with B;
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
This is not correct, as `extend` should have the same effect as a direct include.
|
|
427
|
+
This was an unnoticed regression: the compiler issued an error until version 3.4.
|
|
428
|
+
|
|
429
|
+
In cds-compiler v6.9,
|
|
430
|
+
we introduced a warning as preparation.
|
|
431
|
+
|
|
432
|
+
In cds-compiler v7,
|
|
433
|
+
duplicate elements via `extend` are an error:
|
|
434
|
+
```txt
|
|
435
|
+
Error[ext-duplicate-include]: Duplicate element “field” through multiple includes “A”, “B”
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
### Extend ... with definitions
|
|
440
|
+
|
|
441
|
+
Before cds-compiler v7:
|
|
442
|
+
`extend Foo with definitions ...` produces empty `extend` blocks in parsed CSN.
|
|
443
|
+
|
|
444
|
+
Example:
|
|
445
|
+
```cds
|
|
446
|
+
service S {}
|
|
447
|
+
extend S with definitions { type A : String; }
|
|
448
|
+
type S.B : String;
|
|
449
|
+
```
|
|
450
|
+
Parsed CSN:
|
|
451
|
+
```json
|
|
452
|
+
{
|
|
453
|
+
"definitions": {
|
|
454
|
+
"S": { "kind": "service" },
|
|
455
|
+
"S.A": { "kind": "type", "type": "cds.String" },
|
|
456
|
+
"S.B": { "kind": "type", "type": "cds.String" },
|
|
457
|
+
},
|
|
458
|
+
"extensions": [
|
|
459
|
+
{ "extend": "S" }
|
|
460
|
+
]
|
|
461
|
+
}
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
Information content of the empty `extend` is very limited:
|
|
465
|
+
We know that in the original source there was an `extend`, but we don't know
|
|
466
|
+
whether `S.A` or `S.B` came via the `extend`.
|
|
467
|
+
|
|
468
|
+
In cds-compiler v7:
|
|
469
|
+
Remove the empty `extend` (or `annotate`). Keep empty `extend` in parsed CSN only
|
|
470
|
+
when the `extend` in CDL is empty: `extend S` (or make that a syntax error).
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
### Propagate value null
|
|
475
|
+
|
|
476
|
+
Before cds-compiler v7,
|
|
477
|
+
an annotation with value `null` is not propagated (`null` effectively "removes" the annotation).
|
|
478
|
+
|
|
479
|
+
This causes a recompilation issue with the following example:
|
|
480
|
+
```cds
|
|
481
|
+
@type type Text: String;
|
|
482
|
+
type Base { @elem @type: null elem: Text(20) };
|
|
483
|
+
entity Incl : Base {}; // recompile: Incl:elem gets @type
|
|
484
|
+
type Derived: Base;
|
|
485
|
+
annotate Derived:elem with @anno; // recompile: Derived:elem gets @type
|
|
486
|
+
```
|
|
487
|
+
After first compilation, `Incl:elem` does not have annotation `@type` (as value `null` prohibits propagation).
|
|
488
|
+
In recompilation, `Incl:elem` gets annotation `@type` with value `true` via the type `Text`.
|
|
489
|
+
|
|
490
|
+
There is no recompile issue with the following example, but "linked" CSN would benefit
|
|
491
|
+
from propagating annotations with value `null`, too.
|
|
492
|
+
```cds
|
|
493
|
+
entity Root { @elem @type: null elem: Text(20) }
|
|
494
|
+
entity Proj as projection on Root; // Proj:elem should have @type: null
|
|
495
|
+
```
|
|
496
|
+
What is the problem here: look at `Proj:elem`, there is no explicit annotation `@type`.
|
|
497
|
+
Via prototype the properties are obtained from the type `Text`, where `@type` has value `true`.
|
|
498
|
+
|
|
499
|
+
In cds-compiler v7, the annotation with value `null` is propagated like any other annotation.
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
### Expression as UP TO value
|
|
503
|
+
|
|
504
|
+
When we introduced expressions as annotation values, we syntactically allowed them as comparator value
|
|
505
|
+
for the `... up to` syntax, but missed to handle them correctly in the comparison logic.
|
|
506
|
+
Some erroneous `annotates` were not detected.
|
|
507
|
+
|
|
508
|
+
Example:
|
|
509
|
+
```cds
|
|
510
|
+
@A: [1, 2, (1+2), 3, 4]
|
|
511
|
+
entity E {
|
|
512
|
+
key id : Integer;
|
|
513
|
+
}
|
|
514
|
+
annotate E with @A: [... up to (1+2), 11, 12, ...];
|
|
515
|
+
```
|
|
516
|
+
results in
|
|
517
|
+
```txt
|
|
518
|
+
Warning: The ‘... up to’ value does not match any item in the base annotation “@A”
|
|
519
|
+
```
|
|
520
|
+
and values 11 and 12 are added to the end of the array.
|
|
521
|
+
|
|
522
|
+
In cds-compiler v7,
|
|
523
|
+
we issue errors (non-configurable) for all complex expressions, and correctly handle those that are allowed.
|
|
524
|
+
|
|
525
|
+
For the example above:
|
|
526
|
+
```txt
|
|
527
|
+
Error: Unexpected expression as ‘... up to’ value in the assignment of “@A”
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
### Associations defined via backlink associations
|
|
531
|
+
|
|
532
|
+
There are additional checks for associations (or compositions) which are defined like
|
|
533
|
+
```cds
|
|
534
|
+
entity E {
|
|
535
|
+
// ..
|
|
536
|
+
assoc: Association to Target on assoc.back = $self …:
|
|
537
|
+
}
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
1. There must be just one comparison with $self in one on condition.
|
|
541
|
+
2. The target `T` of the backlink association `back` must be the entity (or other structure) `E`
|
|
542
|
+
where assoc is embedded in, or be a (direct or indirect) include or query source of `E`.
|
|
543
|
+
The check is partially postponed if `E` is an aspect; there is no warning anymore if `T` is not `E`.
|
|
544
|
+
3. All target elements which are referred to in the foreign keys or ON condition of the backlink
|
|
545
|
+
association `back` must be projected to `E` (or included) from T.
|
|
546
|
+
Renaming these elements is supported.
|
|
547
|
+
|
|
548
|
+
These checks prevent late errors in the SQL backend, during deployment or in the runtime.
|
|
549
|
+
They also enable (a next version of) the SQL backend to properly generate a correct SQL condition
|
|
550
|
+
when elements on the target side of the backlink associations are renamed (see condition 3).
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
## Changes in OData/EDM
|
|
555
|
+
|
|
556
|
+
### Vocabulary change for Common.SideEffectsType
|
|
557
|
+
|
|
558
|
+
In a recent [update](https://github.com/SAP/odata-vocabularies/commit/05eb6034796706bdf3227108cfa13ecab2aab9d9)
|
|
559
|
+
of OData vocabulary `Common`, the complex type `Common.SideEffectsType` was changed incompatibly:
|
|
560
|
+
the (deprecated) property `EffectsType` was removed.
|
|
561
|
+
|
|
562
|
+
Effect:
|
|
563
|
+
```cds
|
|
564
|
+
service S {
|
|
565
|
+
@Common.SideEffects: {
|
|
566
|
+
EffectTypes : #ValueChange
|
|
567
|
+
}
|
|
568
|
+
entity E {
|
|
569
|
+
key id : Integer;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
```
|
|
573
|
+
Before removing property `EffectsType`:
|
|
574
|
+
```xml
|
|
575
|
+
<Annotation Term="Common.SideEffects">
|
|
576
|
+
<Record Type="Common.SideEffectsType">
|
|
577
|
+
<PropertyValue Property="EffectTypes" EnumMember="Common.EffectType/ValueChange"/>
|
|
578
|
+
</Record>
|
|
579
|
+
</Annotation>
|
|
580
|
+
```
|
|
581
|
+
After removal:
|
|
582
|
+
```xml
|
|
583
|
+
<Annotation Term="Common.SideEffects">
|
|
584
|
+
<Record Type="Common.SideEffectsType">
|
|
585
|
+
<PropertyValue Property="EffectTypes" EnumMember="Common.SideEffectsType/ValueChange"/>
|
|
586
|
+
</Record>
|
|
587
|
+
</Annotation>
|
|
588
|
+
```
|
|
589
|
+
with warning:
|
|
590
|
+
```txt
|
|
591
|
+
Warning[odata-anno-type]: “EffectTypes” is not a known property for “@Common.SideEffects” of type “Common.SideEffectsType”
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
You can safely remove property `EffectTypes` from your annotations, as they didn't have any effect.
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
## Changes in to.sql()
|
|
598
|
+
|
|
599
|
+
### Remove option to generate transitive localized views
|
|
600
|
+
|
|
601
|
+
In v5 we changed the default behavior to no longer generate transitive localized views.
|
|
602
|
+
We introduced option `cds.sql.transitive_localized_views` to explicitly switch on generation of transitive localized views.
|
|
603
|
+
See [Release notes June 2024](https://cap.cloud.sap/docs/releases/2024/jun24#transitive-localized-views-removed)
|
|
604
|
+
and [Deprecated Features](https://cap.cloud.sap/docs/releases/2024/jun24#deprecated-features).
|
|
605
|
+
|
|
606
|
+
In v6 we decided to not yet remove this option, as there were
|
|
607
|
+
issues in extension scenarios where cds-compiler v5 (new: no views by default)
|
|
608
|
+
and cds 7 (old: still needs these views) were used together.
|
|
609
|
+
|
|
610
|
+
In cds-compiler v7, this option is removed.
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
### Change type mapping for Decimal on SQLite
|
|
614
|
+
|
|
615
|
+
Before cds-compiler v7, cds type `Decimal` was mapped to `DECIMAL` on SQLite.
|
|
616
|
+
`DECIMAL` uses `NUMERIC` affinity, which has unexpected results in some situations:
|
|
617
|
+
```sql
|
|
618
|
+
> create table T (id int, d1 decimal, d2 decimal);
|
|
619
|
+
> insert into T values (1, 1.0, 4.0);
|
|
620
|
+
> insert into T values (2, 1.0, 4.1);
|
|
621
|
+
> select id, d1/d2 from T;
|
|
622
|
+
1|0
|
|
623
|
+
2|0.24390243902439
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
In cds-compiler v7, we changed the type mapping for SQLite:
|
|
627
|
+
CDS type `Decimal` now is mapped to `REAL_DECIMAL`, which has affinity `REAL`.
|
|
628
|
+
|
|
629
|
+
| CDS type | type old | affinity old | type new | affinity new |
|
|
630
|
+
|----------------|----------------|--------------|---------------------|--------------|
|
|
631
|
+
| Decimal(10, 3) | DECIMAL(10, 3) | NUMERIC | REAL_DECIMAL(10, 3) | REAL |
|
|
632
|
+
| Decimal | DECIMAL | NUMERIC | REAL_DECIMAL | REAL |
|
|
633
|
+
| DecimalFloat | DECIMAL | NUMERIC | REAL_DECIMAL | REAL |
|
|
634
|
+
| Double | DOUBLE | REAL | DOUBLE | REAL |
|
|
635
|
+
|
|
636
|
+
The old mapping can be restored via a switch:
|
|
637
|
+
```
|
|
638
|
+
cds.requires.db.decimal_affinity : 'numeric'
|
|
639
|
+
```
|