@sap/cds-compiler 5.9.2 → 6.0.10

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