@sap/cds-compiler 5.9.4 → 6.0.12

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 (114) hide show
  1. package/CHANGELOG.md +117 -319
  2. package/README.md +1 -1
  3. package/bin/cds_update_identifiers.js +3 -5
  4. package/bin/cdsc.js +24 -9
  5. package/bin/cdshi.js +1 -1
  6. package/bin/cdsse.js +4 -4
  7. package/doc/CHANGELOG_BETA.md +11 -0
  8. package/doc/CHANGELOG_DEPRECATED.md +29 -0
  9. package/lib/api/main.js +8 -5
  10. package/lib/api/options.js +12 -10
  11. package/lib/base/builtins.js +1 -0
  12. package/lib/base/message-registry.js +191 -99
  13. package/lib/base/messages.js +35 -21
  14. package/lib/base/model.js +14 -24
  15. package/lib/checks/actionsFunctions.js +10 -20
  16. package/lib/checks/annotationsOData.js +1 -1
  17. package/lib/checks/elements.js +35 -10
  18. package/lib/checks/enums.js +31 -0
  19. package/lib/checks/foreignKeys.js +2 -2
  20. package/lib/checks/hasPersistedElements.js +5 -0
  21. package/lib/checks/invalidTarget.js +1 -1
  22. package/lib/checks/managedWithoutKeys.js +5 -4
  23. package/lib/checks/queryNoDbArtifacts.js +10 -8
  24. package/lib/checks/types.js +5 -5
  25. package/lib/checks/validator.js +6 -4
  26. package/lib/compiler/assert-consistency.js +13 -9
  27. package/lib/compiler/checks.js +20 -52
  28. package/lib/compiler/define.js +31 -6
  29. package/lib/compiler/extend.js +5 -1
  30. package/lib/compiler/generate.js +14 -17
  31. package/lib/compiler/populate.js +8 -31
  32. package/lib/compiler/propagator.js +21 -35
  33. package/lib/compiler/resolve.js +64 -29
  34. package/lib/compiler/shared.js +16 -4
  35. package/lib/compiler/tweak-assocs.js +1 -1
  36. package/lib/compiler/utils.js +1 -1
  37. package/lib/edm/annotations/edmJson.js +23 -20
  38. package/lib/edm/annotations/genericTranslation.js +12 -10
  39. package/lib/edm/csn2edm.js +50 -56
  40. package/lib/edm/edm.js +33 -28
  41. package/lib/edm/edmInboundChecks.js +2 -2
  42. package/lib/edm/edmPreprocessor.js +54 -88
  43. package/lib/edm/edmUtils.js +9 -12
  44. package/lib/gen/BaseParser.js +63 -52
  45. package/lib/gen/CdlGrammar.checksum +1 -1
  46. package/lib/gen/CdlParser.js +1153 -1165
  47. package/lib/gen/Dictionary.json +21 -1
  48. package/lib/json/from-csn.js +70 -43
  49. package/lib/json/to-csn.js +6 -8
  50. package/lib/language/multiLineStringParser.js +3 -2
  51. package/lib/main.d.ts +58 -24
  52. package/lib/model/cloneCsn.js +3 -0
  53. package/lib/model/csnUtils.js +28 -39
  54. package/lib/model/xprAsTree.js +23 -9
  55. package/lib/modelCompare/compare.js +5 -4
  56. package/lib/optionProcessor.js +24 -17
  57. package/lib/parsers/AstBuildingParser.js +81 -25
  58. package/lib/parsers/XprTree.js +57 -3
  59. package/lib/parsers/identifiers.js +1 -1
  60. package/lib/parsers/index.js +0 -3
  61. package/lib/render/manageConstraints.js +25 -25
  62. package/lib/render/toCdl.js +173 -170
  63. package/lib/render/toHdbcds.js +126 -128
  64. package/lib/render/toRename.js +7 -7
  65. package/lib/render/toSql.js +128 -125
  66. package/lib/render/utils/common.js +47 -22
  67. package/lib/render/utils/delta.js +25 -25
  68. package/lib/render/utils/operators.js +2 -2
  69. package/lib/render/utils/pretty.js +5 -5
  70. package/lib/render/utils/sql.js +13 -13
  71. package/lib/render/utils/standardDatabaseFunctions.js +115 -103
  72. package/lib/render/utils/unique.js +4 -4
  73. package/lib/transform/db/applyTransformations.js +1 -1
  74. package/lib/transform/db/assertUnique.js +2 -2
  75. package/lib/transform/db/associations.js +6 -7
  76. package/lib/transform/db/assocsToQueries/utils.js +4 -5
  77. package/lib/transform/db/backlinks.js +12 -9
  78. package/lib/transform/db/cdsPersistence.js +8 -7
  79. package/lib/transform/db/constraints.js +13 -10
  80. package/lib/transform/db/expansion.js +7 -3
  81. package/lib/transform/db/flattening.js +4 -14
  82. package/lib/transform/db/processSqlServices.js +2 -1
  83. package/lib/transform/db/temporal.js +5 -7
  84. package/lib/transform/db/views.js +2 -4
  85. package/lib/transform/draft/db.js +8 -8
  86. package/lib/transform/draft/odata.js +10 -7
  87. package/lib/transform/forOdata.js +10 -5
  88. package/lib/transform/forRelationalDB.js +5 -75
  89. package/lib/transform/localized.js +1 -1
  90. package/lib/transform/odata/createForeignKeys.js +11 -10
  91. package/lib/transform/odata/flattening.js +8 -4
  92. package/lib/transform/odata/foreignKeyRefsInXprAnnos.js +96 -0
  93. package/lib/transform/odata/typesExposure.js +3 -3
  94. package/lib/transform/transformUtils.js +4 -8
  95. package/lib/transform/translateAssocsToJoins.js +14 -7
  96. package/lib/transform/universalCsn/universalCsnEnricher.js +10 -4
  97. package/lib/utils/objectUtils.js +0 -17
  98. package/package.json +10 -13
  99. package/share/messages/def-upcoming-virtual-change.md +1 -1
  100. package/LICENSE +0 -37
  101. package/bin/cds_remove_invalid_whitespace.js +0 -138
  102. package/doc/CHANGELOG_ARCHIVE.md +0 -3604
  103. package/lib/gen/genericAntlrParser.js +0 -3
  104. package/lib/gen/language.checksum +0 -1
  105. package/lib/gen/language.interp +0 -456
  106. package/lib/gen/language.tokens +0 -180
  107. package/lib/gen/languageLexer.interp +0 -439
  108. package/lib/gen/languageLexer.js +0 -1483
  109. package/lib/gen/languageLexer.tokens +0 -167
  110. package/lib/gen/languageParser.js +0 -24941
  111. package/lib/language/antlrParser.js +0 -205
  112. package/lib/language/errorStrategy.js +0 -646
  113. package/lib/language/genericAntlrParser.js +0 -1572
  114. package/lib/parsers/CdlGrammar.g4 +0 -2070
package/CHANGELOG.md CHANGED
@@ -4,11 +4,116 @@
4
4
  <!-- markdownlint-disable MD004 -->
5
5
  <!-- (no-duplicate-heading)-->
6
6
 
7
- Note: `beta` fixes, changes and features are usually not listed in this ChangeLog but [here](doc/CHANGELOG_BETA.md).
7
+ Note: `beta` fixes, changes and features are usually not listed in this ChangeLog
8
+ but in [doc/CHANGELOG_BETA.md](doc/CHANGELOG_BETA.md).
8
9
  The compiler behavior concerning `beta` features can change at any time without notice.
9
10
 
11
+ ## Version 6.0.12 - 2025-06-06
12
+
13
+ ### Changed
14
+
15
+ - Update OData vocabularies: 'Common', 'Hierarchy'
16
+
17
+ ### Fixed
18
+
19
+ - compiler: Fix artifact refs in annotated annotation expressions,
20
+ i.e. the `Type` inside `annotate … with @SomeAnno: (cast( … as Type ))`.
21
+ - to.sql: Checks around managed associations for mocked entities have been relaxed.
22
+ - to.edm(x): Resolved a crash caused by references in annotation expressions that were not properly updated.
23
+
24
+ ## Version 6.0.10 - 2025-05-28
25
+
26
+ ### Fixed
27
+
28
+ - to.sql/to.hdi:
29
+ + Fixed internal error for to-many associations without ON-condition in entities with `@cds.persistence.skip`.
30
+ - for.odata/to.edm(x):
31
+ + In annotation expressions: enum references that have already been resolved by the compiler are
32
+ correctly rendered to EDMX.
33
+
34
+ ## Version 6.0.8 - 2025-05-23
35
+
36
+ ### Changed
37
+
38
+ - License changed to "SAP DEVELOPER LICENSE AGREEMENT Version 3.2 CAP"
39
+ - Node 20 is now the minimum required version.
40
+ - Namespace `cds.core` is no longer reserved by the cds-compiler. It is used by the CAP runtimes.
41
+ - compiler:
42
+ + Providing a filter for a function call now is a syntax error (was a warning before).
43
+ Example: `count(*)[ uncheckedFilterRef > 0 ]`.
44
+ + Providing a default value for an array-like action or function parameter is a syntax error now
45
+ (was a warning before). Example: `action A( par: many Integer default 42 )`.
46
+ + Providing an annotation for an array-like element in the middle of a type expression is no longer allowed
47
+ (was a warning before), as this leads to unexpected results. Example: `bar: many String null @anno enum { symbol };`.
48
+ Fix this by moving the annotation out of the type expression, e.g. before the element name.
49
+ + A simple query inside parentheses (e.g. `entity V as (select from E)`) is no longer
50
+ represented as `set` in CSN. Repeated `order by` or `limit` clauses are no longer allowed
51
+ (e.g. `entity V as ( select from E order by id ) order by id;`).
52
+ + Defining an element or parameter as `not null default now` now is an error.
53
+ + A virtual element can be defined in a view without providing a value or reference.
54
+
55
+ ```cds
56
+ entity V as select from E { virtual a } //defines new virtual element 'a'
57
+ ```
58
+
59
+ In this example, the compiler no longer tries to resolve the name of the virtual element as reference
60
+ to an element of the view's data source.
61
+ + If a select item selects an element of a virtual structure that itself is not explicitly marked as virtual,
62
+ then the select item must be explicitly marked as virtual, too.
63
+ + To-many associations without ON-condition no longer get a `keys` property, i.e. `Association to many Foo;` does not get
64
+ any foreign keys.
65
+ + Annotation `@cds.persistence.journal` is now propagated to generated entities, including `.texts` entities.
66
+ + Doc comments are no longer propagated; use option `propagateDocComments: true` to propagate them again.
67
+ + With CSN input, the compiler does not accept anymore type properties
68
+ like `enum` in the `cast` property for the SQL function `cast` which were simply
69
+ ignored by the SQL backend. Remark: inside a direct `cast` property for select
70
+ columns (CDL-style `cast`), these type properties are still allowed.
71
+ - to.sql/to.hdi:
72
+ + Default for option `booleanEquality` is `true`, i.e. `!=` is rendered as `IS DISTINCT FROM`
73
+ or a similar expression and therefore has boolean logic instead of three-valued logic.
74
+ + To-many associations with neither an explicit foreign key list (i.e. without `keys`) nor an ON-condition
75
+ are reported as errors.
76
+ + For SAP HANA, CDS associations are by default no longer reflected in the respective database tables and views by
77
+ native HANA Associations (HANA SQL clause `WITH ASSOCIATIONS`). They can be switched on via configuration
78
+ `cds.sql.native_hana_associations: true`.
79
+ + A set of OData and SAP HANA functions are translated to database-specific variants.
80
+ See <https://cap.cloud.sap/docs/guides/databases#standard-database-functions>.
81
+ + For SQL and HDI rendering, `$now` is no longer rendered as `CURRENT_TIMESTAMP`, but as
82
+ a session variable `SESSION_CONTEXT('NOW')` for SAP HANA, `SESSION_CONTEXT('$now')`
83
+ for SQLite, `@now` for H2, and `current_setting('cap.now')::timestamp` for Postgres.
84
+ For `default` values, `CURRENT_TIMESTAMP` is kept, as `default` clauses only allow static expressions.
85
+ To restore the old behavior, use option `dollarNowAsTimestamp: true`.
86
+ + `count(*)` inside nested projections is rejected, as there is no proper representation in SQL
87
+ - to.cdl:
88
+ + Nested definition rendering is now the default, i.e. definitions inside services are
89
+ rendered in `service { … }`, instead of being rendered top-level using their absolute name.
90
+ + `to.cdl` no longer returns an entry `namespace`, only `model`.
91
+ - for.odata/to.edm(x):
92
+ + References to foreign keys in annotation expressions are now adjusted to directly
93
+ reference the corresponding local foreign key element.
94
+ + Annotating the generated `DraftAdministrativeData` artifacts and their elements is now supported.
95
+
96
+ ### Added
97
+
98
+ - for.odata/to.edm(x):
99
+ + Annotating the generated `DraftAdministrativeData` artifacts and their elements is now supported.
100
+
101
+ ### Removed
102
+
103
+ - compiler:
104
+ + The Antlr-based parser is removed.
105
+ + v5 deprecated flags are removed, see [CHANGELOG_DEPRECATED.md](doc/CHANGELOG_DEPRECATED.md).
106
+ + Option `compositionIncludes` is removed, as its default is `true`; instead, a deprecated flag was added.
107
+ - to.hdbcds: The HDBCDS backend is deprecated and can no longer be invoked.
108
+
109
+ ### Fixed
110
+
111
+ - to.edm(x): Fixed crash for rare case if annotation expressions were used.
112
+
10
113
  ## Version 5.9.4 - 2025-05-22
11
114
 
115
+ ### Fixed
116
+
12
117
  - to.edm(x): Parameters are marked optional unless explicitly marked as `not null`.
13
118
  Annotation `Core.OptionalParameter` will be added to optional parameters.
14
119
 
@@ -18,7 +123,6 @@ The compiler behavior concerning `beta` features can change at any time without
18
123
 
19
124
  - to.edm(x): Revert addition of the attribute sap:filterable="false" to the NavigationProperty DraftAdministrativeData in OData V2
20
125
 
21
-
22
126
  ## Version 5.9.0 - 2025-03-28
23
127
 
24
128
  ### Added
@@ -37,8 +141,8 @@ The compiler behavior concerning `beta` features can change at any time without
37
141
  + Annotation array values are pretty-printed to reduce whitespace.
38
142
  - for.effective: Property `namespace` is no longer part of effective CSN.
39
143
  - for.sql/hdi:
40
- - The new operator `==` is rendered as `IS NOT DISTINCT FROM` or an equivalent expression.
41
- - Using option `booleanEquality`, operator `!=` is rendered as `IS DISTINCT FROM` or an equivalent expression.
144
+ + The new operator `==` is rendered as `IS NOT DISTINCT FROM` or an equivalent expression.
145
+ + Using option `booleanEquality`, operator `!=` is rendered as `IS DISTINCT FROM` or an equivalent expression.
42
146
 
43
147
  ### Changed
44
148
 
@@ -48,14 +152,12 @@ The compiler behavior concerning `beta` features can change at any time without
48
152
 
49
153
  - to.odata: Annotation expressions using `LabeledElement` were not correctly rendered into EDMX.
50
154
 
51
-
52
155
  ## Version 5.8.2 - 2025-03-07
53
156
 
54
157
  ### Fixed
55
158
 
56
159
  - for.odata: Generate foreign key elements for events again.
57
160
 
58
-
59
161
  ## Version 5.8.0 - 2025-02-27
60
162
 
61
163
  ### Added
@@ -86,7 +188,6 @@ The compiler behavior concerning `beta` features can change at any time without
86
188
  - for.odata/to.edm(x)/for.seal: Propagate annotation expressions from managed associations
87
189
  to the foreign keys
88
190
 
89
-
90
191
  ### Changed
91
192
 
92
193
  - Top-level CSN property `csnInteropEffective` is ignored and no longer warned about.
@@ -198,7 +299,6 @@ The compiler behavior concerning `beta` features can change at any time without
198
299
 
199
300
  - to.sql: For SQLite, map `cds.Map` to `JSON_TEXT` to ensure text affinity.
200
301
 
201
-
202
302
  ## Version 5.4.0 - 2024-10-24
203
303
 
204
304
  ### Added
@@ -375,6 +475,13 @@ This is a preview version for the major release and contains breaking changes. I
375
475
  - API: Deprecated functions `preparedCsnToEdmx` and `preparedCsnToEdm` were removed.
376
476
  Use `to.edm(x)` instead.
377
477
 
478
+ ## Version 4.9.10 - 2025-04-29
479
+
480
+ ### Fixed
481
+
482
+ - Added option `allowMixinInProjectionExtension` which allows referring to mixins in `extend projection`.
483
+ This was forbidden in cds-compiler v4, but re-introduced in v5.5. Users wanting to migrate from cds-compiler
484
+ v3 to v4 can use this option for easier migration.
378
485
 
379
486
  ## Version 4.9.8 - 2024-07-29
380
487
 
@@ -445,7 +552,7 @@ This is a preview version for the major release and contains breaking changes. I
445
552
  - Support associations to/from entities with parameters for SAP HANA SQL (hdi/direct).
446
553
  - to.sql/to.hdi:
447
554
  + SAP HANA keywords `ABSOLUTE`, `REAL_VECTOR`, and `ST_ASESRIJSON` are now included for smart quoting.
448
- +PostgreSQL keyword `SYSTEM_USER` is now included for smart quoting.
555
+ + PostgreSQL keyword `SYSTEM_USER` is now included for smart quoting.
449
556
  - API: Added `to.sql.postgres.keywords` and `to.sql.h2.keywords`.
450
557
  They contain keywords for the respective SQL dialect.
451
558
 
@@ -1262,8 +1369,7 @@ This is a preview version for the major release and contains breaking changes. I
1262
1369
  `to.edm(x)`. This allows to reuse imported enum types in new APIs.
1263
1370
  + Messages raised from the EDM annotation renderer have been reworked with message id and enhanced message
1264
1371
  position including the annotation under investigation.
1265
- + `@Validation.AllowedValues` annotation as introduced for enum elements with
1266
- [1.44.2](./doc/CHANGELOG_ARCHIVE.md#version-1442---2020-10-09)
1372
+ + `@Validation.AllowedValues` annotation as introduced for enum elements with v1.44.2
1267
1373
  are now always rendered into the API regardless of `@assert.range`.
1268
1374
  - to.cdl: The input CSN is no longer cloned for client-CSN and parseCdl-CSN,
1269
1375
  as the renderer does not modify it.
@@ -1521,311 +1627,3 @@ This is a preview version for the major release and contains breaking changes. I
1521
1627
  - CDL parser: `*` is not parsed anymore as argument to all SQL functions;
1522
1628
  it is now only allowed for `count`, `min`, `max`, `sum`, `avg`, `stddev`, `var`.
1523
1629
  - All non-SNAPI options.
1524
-
1525
- ## Version 2.15.10 - 2023-01-26
1526
-
1527
- ### Fixed
1528
-
1529
- - If an entity with parameters is auto-exposed, the generated projection now has
1530
- the same formal parameters and its query forwards these parameters to the origin entity.
1531
- - to.edm(x): Respect record type hint `$Type` in EDM JSON as full qualified `@type` URI property.
1532
-
1533
- ## Version 2.15.8 - 2022-08-02
1534
-
1535
- ### Fixed
1536
-
1537
- - to.edm(x): Nested `@UI.TextArrangement` has precedence over `@TextArrangement` shortcut annotation for `@Common.Text`.
1538
- - to.hdi.migration:
1539
- + Respect option `disableHanaComments` when rendering the `ALTER` statements
1540
- + Doc comments rendered the _full doc comment_ instead of only the first paragraph, as `to.hdi` does.
1541
- - compiler: An association's cardinality was lost for associations published in projections.
1542
-
1543
- ## Version 2.15.6 - 2022-07-26
1544
-
1545
- ### Fixed
1546
-
1547
- - Annotations on sub-elements were lost during re-compilation.
1548
-
1549
- ## Version 2.15.4 - 2022-06-09
1550
-
1551
- ### Fixed
1552
-
1553
- - for.odata:
1554
- + Fix derived type to scalar type resolution with intermediate `many`.
1555
- - to.edm(x):
1556
- + (V4 structured) Fix key paths in combination with `--odata-foreign-keys`.
1557
- + Add `Edm.PrimitiveType` to `@odata.Type`.
1558
- + (V4 JSON) Render constant expressions for `Edm.Stream` and `Edm.Untyped`.
1559
- + Fix a bug in target path calculation for `NavigationPropertyBinding`s to external references.
1560
- + Render inner annotations even if `$value` is missing.
1561
- - Update OData vocabularies 'Common', 'UI'.
1562
- - to.sql/to.hdbcds/to.hdi: "type of"s in `cast()`s could lead to type properties being lost.
1563
-
1564
- ## Version 2.15.2 - 2022-05-12
1565
-
1566
- ### Fixed
1567
-
1568
- - Option `cdsHome` can be used instead of `global.cds.home` to specify the path to `@sap/cds/`.
1569
- - to.edm(x):
1570
- + Set anonymous nested proxy key elements to `Nullable:false` until first named type is reached.
1571
- + Enforce `odata-spec-violation-key-null` on explicit foreign keys of managed primary key associations.
1572
- + Proxies/service cross references are no longer created for associations with arbitrary ON conditions.
1573
- Only managed or `$self` backlink association targets are proxy/service cross reference candidates.
1574
- + Explicit foreign keys of a managed association that are not a primary key in the target are exposed in the proxy.
1575
- + If an association is primary key, the resulting navigation property is set to `Nullable:false` in structured mode.
1576
-
1577
- ## Version 2.15.0 - 2022-05-06
1578
-
1579
- ### Added
1580
-
1581
- - A new warning is emitted if `excluding` is used without a wildcard, since this does
1582
- not have any effect.
1583
- - All scalar types can now take named arguments, e.g. `MyString(length: 10)`.
1584
- For custom scalar types, one unnamed arguments is interpreted as length, two arguments are interpreted
1585
- as precision and scale, e.g. `MyDecimal(3,3)`.
1586
- - If the type `sap.common.Locale` exists, it will be used as type for the `locale` element
1587
- of generated texts entities. The type must be a `cds.String`.
1588
- - to.cdl: Extend statements (from `extensions`) can now be rendered.
1589
- - Add OData vocabulary 'Hierarchy'.
1590
- - CDL: New associations can be published in queries, e.g. `assoc : Association to Target on assoc.id = id`
1591
-
1592
- ### Changed
1593
-
1594
- - to.edm(x):
1595
- + perform inbound qualification and spec violation checks as well as most/feasible EDM preprocessing steps
1596
- on requested services only.
1597
- + Open up `@odata { Type, MaxLength, Precision, Scale, SRID }` annotation.
1598
- The annotations behavior is defined as follows:
1599
- + The element/parameter must have a scalar CDS type. The annotation is not applied on named types
1600
- (With the V2 exception where derived type chains terminating in a scalar type are resolved).
1601
- + The value of `@odata.Type` must be a valid `EDM` type for the rendered protocol version.
1602
- + If `@odata.Type` can be applied, all canonic type facets (`MaxLength`, `Precision`, `Scale`, `SRID`) are
1603
- removed from the Edm Node and the new facets `@odata { MaxLength, Precision, Scale, SRID }` are applied.
1604
- Non Edm type conformant facets are ignored (eg. `@odata { Type: 'Edm.Decimal', MaxLength: 10, SRID: 0 }`).
1605
- + Type facet values are not evaluated.
1606
- + V2: Propagate `@Core.MediaType` annotation from stream element to entity type if not set.
1607
- - to.edm: Render constant expressions in short notation.
1608
- - Update OData Vocabularies: 'Common', 'Graph', 'Validation'.
1609
-
1610
- ### Fixed
1611
-
1612
- - to.cdl:
1613
- + Annotations of elements of action `returns` are now rendered as `annotate` statements.
1614
- + Annotations on columns (query sub-elements) were not always rendered.
1615
- + Doc comments on bound actions were rendered twice.
1616
- + Unapplied annotations for action parameters were not rendered.
1617
- + Unions and joins are correctly put into parentheses.
1618
- + Add parentheses around certain expressions in function bodies that require it, such as `fct((1=1))`.
1619
- - to.edm(x):
1620
- + Fix a bug in top level and derived type `items` exposure leading to undefined type rendering.
1621
- + Fix a naming bug in type exposure leading to false reuse types, disguising invididual type
1622
- modifications (such as annotations, (auto-)redirections, element extensions).
1623
- + Ignore `@Aggregation.default`.
1624
- + Consolidate message texts and formatting.
1625
- + Fix navigation property binding in cross service rendering mode.
1626
- + Remove partner attribute in proxy/cross service navigations.
1627
- - Core engine (function `compile`):
1628
- + Annotations for new columns inside `extend projection` blocks were not used.
1629
- + Extending an unknown select item resulted in a crash.
1630
- + Extending a context/service with columns now correctly emits an error.
1631
- + Unmanaged `redirected to` in queries did not check whether the source is an association.
1632
- - parseCdl: `extend <art> with enum {...}` incorrectly threw a compiler error.
1633
- - API: `compile()` used a synchronous call `fs.realpathSync()` on the input filename array.
1634
- Now the asynchronous `fs.realpath()` is used.
1635
- - On-conditions in localized convenience views may be incorrectly rewritten if an element
1636
- has the same as a localized entity.
1637
- - to.sql/hdi/hdbcds:
1638
- + No referential constraint is generated for an association if its parent
1639
- or target entity are annotated with `@cds.persistence.exists: true`.
1640
- + Fix rendering of virtual elements in subqueries
1641
- + Correctly process subqueries in JOINs
1642
- - to.sql/hdi: Queries with `UNION`, `INTERSECT` and similar in expressions are now enclosed in parentheses.
1643
-
1644
- ## Version 2.14.0 - 2022-04-08
1645
-
1646
- ### Added
1647
-
1648
- - cdsc:
1649
- + `--quiet` can now be used to suppress compiler output, including messages.
1650
- + `--options <file.json>` can be used to load compiler options. A JSON file is expected. Is compatible to CDS `package.json`
1651
- and `.cdsrc.json` by first looking for `cdsc` key in `cds`, then for a `cdsc` key and otherwise uses the full JSON file.
1652
- + `--[error|warn|info|debug] id1,id2` can be used to reclassify specific messages.
1653
- - Add OData Vocabularies: 'DataIntegration', 'JSON'.
1654
-
1655
- ### Changed
1656
-
1657
- - Update OData Vocabularies: 'UI'.
1658
-
1659
- ### Fixed
1660
-
1661
- - to.cdl:
1662
- + Delimited identifiers as the last elements of arrays in annotation values are now
1663
- rendered with spaces in between, to avoid accidentally escaping `]`.
1664
- + Identifiers in includes and redirection targets were not quoted if they are reserved keywords.
1665
- - to.edm(x): Correctly rewrite `@Capabilities.ReadRestrictions.ReadByKeyRestrictions` into
1666
- `@Capabilities.NavigationPropertyRestriction` in containment mode.
1667
-
1668
- ## Version 2.13.8 - 2022-03-29
1669
-
1670
- ### Fixed
1671
-
1672
- - to.hdbcds/hdi/sql: Correctly handle `localized` in conjunction with `@cds.persistence.exists` and `@cds.persistence.skip`
1673
-
1674
- ## Version 2.13.6 - 2022-03-25
1675
-
1676
- ### Fixed
1677
-
1678
- - to.hdbcds/hdi/sql: Correctly handle `localized` in conjunction with `@cds.persistence.exists`
1679
-
1680
- ## Version 2.13.4 - 2022-03-22
1681
-
1682
- No changes compared to Version 2.13.0; fixes latest NPM tag
1683
-
1684
- ## Version 2.13.2 - 2022-03-22
1685
-
1686
- No changes compared to Version 2.13.0; fixes latest NPM tag
1687
-
1688
- ## Version 2.13.0 - 2022-03-22
1689
-
1690
- ### Added
1691
-
1692
- - CDL syntax:
1693
- + Allow to `extend E:elem` and `annotate E:elem` instead of having to write deeply nested statements.
1694
- + Enable `default` values as part of scalar type definitions.
1695
- + The following `extend` syntax variants are now possible:
1696
- ```cds
1697
- extend … with elements { … }
1698
- extend … with definitions { … }
1699
- extend … with columns { … }
1700
- extend … with enum { … }
1701
- extend … with actions { … }
1702
- ```
1703
- This syntax expresses _how_ an artifact is extended instead of _what_ is extended.
1704
- + Using `ORDER BY` in generic functions such as SAP HANA's `first_value` is now possible.
1705
- - Make API function `compileSources` accept CSN objects as file content
1706
- - to.edm(x): Annotate view parameters with `@sap.parameter: mandatory` (V2) and `@Common.FieldControl: #Mandatory` (V4).
1707
- - to.sql/hdi/hdbcds: Introduce the annotations `@sql.prepend` and `@sql.append` that allow inserting user-written SQL
1708
- snippets into the compiler generated content. Changes in annotations `@sql.prepend` and `@sql.append` are now reflected
1709
- in the output of `to.hdi.migration`. This enables CDS Build to produce `.hdbmigrationtable` files translating such model
1710
- changes into schema changes.
1711
- - API: Lists of keywords for various backends are available as `to.<backend>[.<config>].keywords`, e.g. `to.sql.sqlite.keywords`.
1712
- - for.odata/to.edm(x): The draft composition hull is now also taking into account compositions in subelements.
1713
-
1714
- ### Changed
1715
-
1716
- - In query entities inside services, only auto-redirect associations and compositions
1717
- in the main query of the entity.
1718
- - An element now inherits the property `notNull` from its query source (as
1719
- before) or its type (like it does for most other properties);
1720
- `notNull` is then not further propagated to its sub elements anymore.
1721
- - A structure element inherits the property `virtual` from its query source (as
1722
- before), but does not further propagate `virtual` to its sub elements
1723
- (semantically of course, but the CSN is not cluttered with it);
1724
- there is a new warning if a previously `virtual` query entity
1725
- element is now considered to be non-virtual.
1726
- - Do not propagate annotation value `null`.
1727
- The value `null` of an annotation (and `doc`) is used to stop the inheritance
1728
- of an annotation value. This means than other than that, a value `null` should
1729
- not be handled differently to not having set that annotation.
1730
- - In the effective CSN, the structure type is only expanded if something has changed
1731
- for associations: the `target` (`keys` does not change if the `target` does not change)
1732
- unmanaged associations as sub elements are not supported anyway.
1733
- - In the effective CSN, “simple” type properties like `length`, `precision`,
1734
- `scale` and `srid` are propagated even for a propagation via type.
1735
- - Update OData Vocabularies: 'Capabilities', 'Common', 'Core', 'UI'.
1736
- - to.sql:
1737
- + For SQL dialect `hana` referential constraints are now appended
1738
- as `ALTER TABLE ADD CONSTRAINT` clause to the end of `schema.sql`.
1739
- With option `constraintsInCreateTable` constraints are rendered into the
1740
- `CREATE TABLE` statement.
1741
- + Referential constraint names are now prefixed with `c__`.
1742
-
1743
- ### Fixed
1744
-
1745
- - Properly resolve references inside anonymous aspects:
1746
- + references starting with `$self.` made the compiler dump.
1747
- + a simple `$self` did not always work as expected (it represents the entity created via the anonymous aspect).
1748
- + other references inside deeply nested anonymous aspects induced a compilation error.
1749
- - compiler: `()` inside `ORDER BY` clause was not correctly set.
1750
- - parse.cdl: References in `ORDER BY` and filters are now correctly resolved.
1751
- - Issue error when trying to introduce managed compositions of aspects in `mixin`s
1752
- - Issue error in all cases for type references to unmanaged associations.
1753
- - Avoid dump when extending an illegal definition with a name starting with `cds.`.
1754
- - to.sql/to.cdl/to.hdbcds/to.hdi: Render `cast()` inside `ORDER BY`, `GROUP BY` and `HAVING` properly.
1755
- - to.sql/hdi/hdbcds:
1756
- + `$self` was incorrectly treated as a structured path step.
1757
- + Correctly handle table alias in on-condition of mixin in `exists` expansion.
1758
- + Correctly handle table `$self` references to aliased fields in on-condition of mixin association
1759
- during `exists` expansion.
1760
- - to.edm: Don't escape `&` as `&amp;`.
1761
- - to.edmx: Escaping compliant to XML specification:
1762
- + `&` and `<` are always escaped.
1763
- + `>` is not escaped, unless it appears in text values as `]]>`.
1764
- + `"` is escaped in attribute values only.
1765
- + Control characters are always escaped.
1766
- - Ellipsis (`...`) in annotations in different layers but without base annotation now produces an error.
1767
- The old but incorrect behavior can be re-enabled with option `anno-unexpected-ellipsis-layers`.
1768
-
1769
- ## Version 2.12.0 - 2022-01-25
1770
-
1771
- ### Added
1772
-
1773
- - CDL parser: You can now use multiline string literals and text blocks.
1774
- Use backticks (\`) for string literals that can span multiple lines and can use JavaScript-like escape
1775
- sequences such as `\u{0020}`. You can also use three backticks (\`\`\`) for strings (a.k.a. text blocks)
1776
- which are automatically indentation-stripped and can have an optional language identifier that is used
1777
- for syntax highlighting, similar to markdown. In difference to the former, text blocks require the
1778
- opening and closing backticks to be on separate lines.
1779
- Example:
1780
- ````
1781
- @annotation: `Multi
1782
- line\u{0020}strings`
1783
-
1784
- @textblock: ```xml
1785
- <summary>
1786
- <detail>The root tag has no indentation in this example</detail>
1787
- </summary>
1788
- ```
1789
- ````
1790
-
1791
- - Enhance the ellipsis operator `...` for array annotations by an `up to ‹val›`:
1792
- only values in the array of the base annotation up to (including) the first match
1793
- of the specified `‹val›` are included at the specified place in the final array value.
1794
- An array annotation can have more than on `... up to ‹val›` items and must also
1795
- have a pure `...` item after them.
1796
- A structured `‹val›` matches if the array item is also a structure and all property
1797
- values in `‹val›` are equal to the corresponding property value in the array value;
1798
- it is not necessary to specify all properties of the array value items in `‹val›`.
1799
- Example
1800
- ```
1801
- @Anno: [{name: one, val: 1}, {name: two, val: 2}, {name: four, val: 4}]
1802
- type T: Integer;
1803
- @Anno: [{name: zero, val: 0}, ... up to {name: two}, {name: three, val: 3}, ...]
1804
- annotate T;
1805
- ```
1806
- - for.odata: Support `@cds.on {update|insert}` as replacement for deprecated `@odata.on { update|insert }` to
1807
- set `@Core.Computed`.
1808
-
1809
- ### Changed
1810
-
1811
- - Update OData Vocabularies 'Aggregation', 'Capabilities', 'Common', 'Core', PersonalData, 'Session', 'UI'
1812
-
1813
- ### Fixed
1814
-
1815
- - to.sql/hdi/hdbcds: With `exists`, ensure that the precedence of the existing association-on-conditions and where-conditions is kept by adding braces.
1816
- - to.sql/hdi: Window function suffixes are now properly rendered.
1817
- - to.sql: `$self` comparisons inside aspects are not checked and won't result in an error anymore.
1818
- - to.hdbcds:
1819
- + Correctly apply the "."-to-"_"-translation algorithm to artifacts that are marked with `@cds.persistence.exists`.
1820
- + Message with ID `anno-hidden-exists` (former `anno-unstable-hdbcds`) is now
1821
- only issued if the compiler generates a SAP HANA CDS artifact which would hide
1822
- a native database object from being resolved in a SAP HANA CDS `using … as …`.
1823
- - to.cdl: Annotation paths containing special characters such as spaces or `@` are now quoted, e.g. `@![some@annotation]`.
1824
- - compiler: A warning is emitted for elements of views with localized keys as the localized property is ignored for them.
1825
-
1826
-
1827
-
1828
- ## Older Versions
1829
-
1830
- The change log for older entries can be found at
1831
- [`doc/CHANGELOG_ARCHIVE.md`](doc/CHANGELOG_ARCHIVE.md).
package/README.md CHANGED
@@ -34,4 +34,4 @@ In case you find a bug, please report an [incident](https://cap.cloud.sap/docs/r
34
34
 
35
35
  ## License
36
36
 
37
- This package is provided under the terms of the [SAP Developer License Agreement](https://tools.hana.ondemand.com/developer-license-3_1.txt).
37
+ This package is provided under the terms of the [SAP Developer License Agreement](https://cap.cloud.sap/resources/license/developer-license-3_2_CAP.txt).
@@ -55,6 +55,7 @@ process.exit(0); // success
55
55
  // --------------------------------------------------------
56
56
 
57
57
  function modernizeIdentifierStyle( source, filename ) {
58
+ // TODO: Switch to new parser
58
59
  const options = { messages: [], attachTokens: true };
59
60
  const messageFunctions = createMessageFunctions( options, 'parse', null );
60
61
 
@@ -78,7 +79,7 @@ function modernizeIdentifierStyle( source, filename ) {
78
79
 
79
80
  const { tokens } = ast.tokenStream;
80
81
  for (const token of tokens) {
81
- if (token.type === ast.tokenStream.Identifier && token.text.startsWith('"'))
82
+ if (token.type === 'Id' && !token.keyword && token.text.startsWith('"'))
82
83
  updateIdent(token);
83
84
  }
84
85
 
@@ -89,12 +90,9 @@ function modernizeIdentifierStyle( source, filename ) {
89
90
  function updateIdent( identToken ) {
90
91
  const newIdentText = toNewIdentStyle(identToken.text);
91
92
 
92
- if (!identToken.stop)
93
- throw new Error(`INTERNAL ERROR: Identifier at ${ identToken.start } has no end!`);
94
-
95
93
  const start = identToken.start + currentOffset;
96
94
  // 'end' points at the position *before* the character
97
- const end = identToken.stop + currentOffset + 1;
95
+ const end = identToken.start + identToken.text.length + currentOffset;
98
96
 
99
97
  source = replaceSliceInSource(source, start, end, newIdentText);
100
98
 
package/bin/cdsc.js CHANGED
@@ -78,6 +78,10 @@ function remapCmdOptions( options, command ) {
78
78
  case 'serviceNames':
79
79
  options.serviceNames = value.split(',');
80
80
  break;
81
+ case 'noStandardDatabaseFunctions':
82
+ options.standardDatabaseFunctions = false;
83
+ delete options.noStandardDatabaseFunctions;
84
+ break;
81
85
  default:
82
86
  options[key] = value;
83
87
  }
@@ -218,16 +222,25 @@ function cdscMain() {
218
222
  if (cmdLine.options.stdin)
219
223
  cmdLine.options.fallbackParser ??= 'auto!';
220
224
 
221
- if (cmdLine.options[cmdLine.command]?.transitiveLocalizedViews) {
222
- cmdLine.options.fewerLocalizedViews
223
- = !cmdLine.options[cmdLine.command].transitiveLocalizedViews;
224
- delete cmdLine.options[cmdLine.command].transitiveLocalizedViews;
225
+ const commandOptions = cmdLine.options[cmdLine.command];
226
+ if (commandOptions?.transitiveLocalizedViews) {
227
+ cmdLine.options.fewerLocalizedViews = !commandOptions.transitiveLocalizedViews;
228
+ delete commandOptions.transitiveLocalizedViews;
225
229
  }
226
230
 
227
- if (cmdLine.options.noCompositionIncludes) {
228
- cmdLine.options.compositionIncludes = false;
229
- delete cmdLine.options.noCompositionIncludes;
231
+ if (commandOptions?.noRenderCdlDefinitionNesting) {
232
+ commandOptions.renderCdlDefinitionNesting = false;
233
+ delete commandOptions.noRenderCdlDefinitionNesting;
234
+ }
235
+ if (commandOptions?.noRenderCdlCommonNamespace) {
236
+ commandOptions.renderCdlCommonNamespace = false;
237
+ delete commandOptions.noRenderCdlCommonNamespace;
230
238
  }
239
+ if (commandOptions?.noBooleanEquality) {
240
+ commandOptions.booleanEquality = false;
241
+ delete commandOptions.noBooleanEquality;
242
+ }
243
+
231
244
 
232
245
  parseSeverityOptions(cmdLine);
233
246
 
@@ -336,7 +349,8 @@ async function executeCommandLine( command, options, args ) {
336
349
  return;
337
350
  }
338
351
 
339
- options.messages = [];
352
+ if (!options.directMessages)
353
+ options.messages = [];
340
354
  args.files ??= [];
341
355
 
342
356
  // Load a file from stdin if no explicit file is given and stdin is not a TTY.
@@ -585,7 +599,8 @@ async function executeCommandLine( command, options, args ) {
585
599
 
586
600
  const log = console.error;
587
601
 
588
- sortMessages(messages);
602
+ if (!options.internalMsg)
603
+ sortMessages(messages);
589
604
 
590
605
  const msgConfig = {
591
606
  normalizeFilename,
package/bin/cdshi.js CHANGED
@@ -40,7 +40,7 @@ const categoryChars = { // default: first char of category name
40
40
  // Remark: do not use `x`/`X` (hex literal `x'1e3d'`)
41
41
  };
42
42
 
43
- const options = { newParser: true, attachTokens: true, messages: [] };
43
+ const options = { attachTokens: true, messages: [] };
44
44
 
45
45
  function highlight( err, buf ) {
46
46
  if (err) {
package/bin/cdsse.js CHANGED
@@ -76,7 +76,7 @@ function complete( err, buf ) {
76
76
  const src = `${ buf.substring( 0, off.prefix ) }__NO_SUCH_ID__${ buf.substring( off.cursor ) }`;
77
77
  const fname = path.resolve( '', file );
78
78
  compiler.compileX( [ file ], '', {
79
- newParser: true, attachValidNames: true, lintMode: true, beta, messages,
79
+ attachValidNames: true, lintMode: true, beta, messages,
80
80
  }, { [fname]: src } )
81
81
  .then( ident, ident );
82
82
  }
@@ -117,7 +117,7 @@ function find( err, buf ) {
117
117
  const src = `${ buf.substring( 0, off.prefix ) }__NO_SUCH_ID__${ buf.substring( off.cursor ) }`;
118
118
  const fname = path.resolve( '', file );
119
119
  compiler.compileX( [ file ], '', {
120
- newParser: true, attachValidNames: true, lintMode: true, beta, messages,
120
+ attachValidNames: true, lintMode: true, beta, messages,
121
121
  }, { [fname]: src } )
122
122
  .then( show, show );
123
123
  return true;
@@ -143,7 +143,7 @@ function lint( err, buf ) {
143
143
  const messages = [];
144
144
  const fname = path.resolve( '', file );
145
145
  compiler.compileX( [ file ], '', {
146
- newParser: true, lintMode: true, beta, messages,
146
+ lintMode: true, beta, messages,
147
147
  }, { [fname]: buf } )
148
148
  .then( display, display );
149
149
  return true;
@@ -160,7 +160,7 @@ function lint( err, buf ) {
160
160
  function tokensAt( buf, _offset, col, symbol ) {
161
161
  const messages = [];
162
162
  const src = `${ buf.substring( 0, _offset ) }≠${ buf.substring( _offset ) }`;
163
- compiler.parseX( src, frel, { newParser: true, messages } );
163
+ compiler.parseX( src, frel, { messages } );
164
164
  const et = messageAt( messages, 'expectedTokens', col ) || [];
165
165
  for (const n of et) {
166
166
  if (typeof symbol === 'string') {
@@ -8,6 +8,17 @@ Note: `beta` fixes, changes and features are listed in this ChangeLog just for i
8
8
  The compiler behavior concerning `beta` features can change at any time without notice.
9
9
  **Don't use `beta` fixes, changes and features in productive mode.**
10
10
 
11
+ ## Version 6.0.8 - 2025-05-23
12
+
13
+ ### Added `v7preview`
14
+
15
+ Use this beta flag to enable features that will be available for cds-compiler v7.
16
+ It also enables new warnings and errors that are intended for the next version.
17
+
18
+ ### Removed `v6preview`
19
+
20
+ Features are now enabled by default.
21
+
11
22
  ## Version 5.8.0 - 2025-02-27
12
23
 
13
24
  ### Added `v6preview`