@sap/cds-compiler 6.3.6 → 6.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/LICENSE +32 -0
  3. package/README.md +14 -2
  4. package/bin/cdsse.js +0 -3
  5. package/doc/CHANGELOG_BETA.md +1 -1
  6. package/doc/CHANGELOG_DEPRECATED.md +1 -1
  7. package/lib/base/message-registry.js +7 -0
  8. package/lib/base/messages.js +1 -1
  9. package/lib/base/model.js +2 -0
  10. package/lib/compiler/assert-consistency.js +1 -0
  11. package/lib/compiler/checks.js +37 -26
  12. package/lib/compiler/define.js +1 -1
  13. package/lib/compiler/extend.js +39 -50
  14. package/lib/compiler/finalize-parse-cdl.js +1 -1
  15. package/lib/compiler/lsp-api.js +1 -1
  16. package/lib/compiler/populate.js +2 -2
  17. package/lib/compiler/propagator.js +29 -6
  18. package/lib/compiler/resolve.js +13 -3
  19. package/lib/compiler/shared.js +31 -25
  20. package/lib/compiler/tweak-assocs.js +86 -28
  21. package/lib/compiler/xpr-rewrite.js +70 -38
  22. package/lib/edm/annotations/edmJson.js +206 -37
  23. package/lib/edm/csn2edm.js +13 -0
  24. package/lib/edm/edmUtils.js +2 -2
  25. package/lib/gen/BaseParser.js +106 -72
  26. package/lib/gen/CdlGrammar.checksum +1 -1
  27. package/lib/gen/CdlParser.js +1500 -1509
  28. package/lib/json/to-csn.js +8 -5
  29. package/lib/language/genericAntlrParser.js +0 -0
  30. package/lib/main.js +19 -16
  31. package/lib/model/csnRefs.js +589 -521
  32. package/lib/model/csnUtils.js +8 -5
  33. package/lib/model/enrichCsn.js +1 -0
  34. package/lib/parsers/AstBuildingParser.js +72 -27
  35. package/lib/render/toCdl.js +2 -1
  36. package/lib/render/toHdbcds.js +6 -3
  37. package/lib/render/toSql.js +5 -0
  38. package/lib/transform/db/applyTransformations.js +1 -1
  39. package/lib/transform/db/assertUnique.js +4 -1
  40. package/lib/transform/db/cdsPersistence.js +17 -18
  41. package/lib/transform/db/expansion.js +179 -3
  42. package/lib/transform/db/flattening.js +16 -5
  43. package/lib/transform/db/rewriteCalculatedElements.js +79 -283
  44. package/lib/transform/effective/main.js +8 -1
  45. package/lib/transform/forOdata.js +1 -1
  46. package/lib/transform/forRelationalDB.js +21 -80
  47. package/lib/transform/localized.js +65 -110
  48. package/lib/transform/odata/foreignKeyRefsInXprAnnos.js +89 -63
  49. package/lib/transform/transformUtils.js +23 -21
  50. package/lib/transform/translateAssocsToJoins.js +7 -5
  51. package/lib/transform/tupleExpansion.js +16 -3
  52. package/package.json +1 -1
  53. package/doc/DeprecatedOptions_v2.md +0 -150
  54. package/doc/NameResolution.md +0 -837
  55. package/lib/transform/parseExpr.js +0 -415
@@ -1,150 +0,0 @@
1
- # Deprecated Options and How to Avoid Them
2
-
3
- __Important__: With compiler v3, these deprecated options were removed!
4
-
5
- To ease the migration to CDS Compiler Version 2,
6
- the compiler can be called with an option `deprecated`
7
- which makes the compiler behave more like Compiler Version 1 for certain features.
8
-
9
- As the name suggest, this option should be used only for a limited time.
10
- The support for certain v1 features might also be dropped after a while
11
- (without an increase of the compiler major version).
12
-
13
- __When the `deprecated` option is set, the `beta` option is ignored,
14
- and several new features are not available.__
15
-
16
- The value of the option `deprecated` is a dictionary
17
- mapping v1 feature names to (usually boolean) values.
18
- This document lists all those features,
19
- and describes what you can do instead of setting these features.
20
-
21
-
22
- ## Deprecated features influencing the name of generated entities
23
-
24
- The `compile()` function generates entities in the following cases:
25
-
26
- 1. When an element in an entity is specified to be `localized`,
27
- it creates a __texts entity__ for that entity.
28
- 2. For managed composition of aspects,
29
- it creates a __target entity__ based on the provided target aspect.
30
- 3. A projection in a service is automatically generated
31
- for correspondingly tagged entities in the model (which is then “__auto-exposed__”)
32
- if an association/composition to the model entity is to be _implicitly redirected_
33
- to an exposed entity in the service and no such entity exists yet.
34
-
35
- As a short example for 1 and 3 (2 is similar to 1):
36
-
37
- ```
38
- entity my.Model.Base {
39
- key id: UUID;
40
- text: localized String;
41
- }
42
- service our.Service {
43
- entity Proj as projection on my.Model.Base;
44
- }
45
- ```
46
-
47
- The compiled model contains the following generated entities:
48
-
49
- * the text entity `my.Model.Base.texts`,
50
- which is a composition target of the generated element `my.Model.Base:texts`
51
- * the auto-exposed projection `our.Service.Proj.texts`
52
- which is a composition target of `our.Service.Proj:texts`
53
-
54
- For the following subsections (and in general), it is important to understand that
55
- you can define all auto-exposed entities yourself (well, they are not
56
- _auto_-exposed anymore)
57
- _without_ any difference in the compiled model
58
- except for the sequence of entities in `‹csn›.definitions`.
59
- That means, you can append the following line to the above example:
60
-
61
- ```
62
- @cds.autoexposed entity our.Service.Proj.texts as projection on my.Model.Base.texts;
63
- ```
64
-
65
- The annotation `@cds.autoexposed` ensures that this self-exposed entity
66
- really behaves exactly like an auto-exposed entity:
67
-
68
- * it is only used as a direct redirection target, not as an indirect one
69
- (a detailed explanation of this topic is out-of-scope for this document),
70
- * runtimes also attach a runtime semantics to the annotation `@cds.autoexposed`.
71
-
72
- Thus, if you do not like the name of the generated auto-exposed entity,
73
- you can simply __expose the model entity__ yourself and choose the name you like.
74
- __Never ever__ define a projection on the auto-exposed entity,
75
- which has worked in v1 versions and in the v2.1.x versions in certain situations.
76
-
77
-
78
- ### Deprecated `generatedEntityNameWithUnderscore`
79
-
80
- With compiler v1,
81
- the generated entities had no suffix starting with a `.` like `.texts` for texts entities,
82
- but a suffix starting with a `_`.
83
-
84
- If you have a reference to a generated entity in your model,
85
- you now have to change the model accordingly.
86
- For example, if you had for v1
87
-
88
- ```
89
- using { my.Model.Base, my.Model.Base_texts } from './myModel';
90
- entity Root {
91
- key ID: UUID;
92
- base: Association to Base;
93
- texts: Association to Base_texts;
94
- }
95
- ```
96
-
97
- you now have to write for v2 (you see that it is usually actually simpler now)
98
-
99
- ```
100
- using { my.Model.Base } from './myModel';
101
- entity Root {
102
- key ID: UUID;
103
- base: Association to Base;
104
- texts: Association to Base.texts;
105
- }
106
- ```
107
-
108
- If you are a CSN consumer and analyse the compiled model, you might need
109
- to adopt your code for the name change from `my.Model.Base_texts` to `my.Model.Base.texts`.
110
-
111
- In the following areas, nothing will change:
112
-
113
- * In the OData backend,
114
- the “new” `.`s are replaced by `_`s to make the names conform to the OData naming rules.
115
- In other words, the EDMX (for the generated entities) looks the same as with v1.
116
- * In the SQL/Hana backends,
117
- the “new” `.`s are also replaced by `_`s to adopt to HANA CDS naming restrictions
118
- (with the standard naming mode `plain`, all `.`s are replaced by `_`s anyway).
119
- In other words, no texts table migration will take place.
120
-
121
- But anyway, you might temporarily want to keep the v1 behavior
122
- by setting the option `deprecated.generatedEntityNameWithUnderscore`.
123
- If you do so, scoped definitions are not possible (like they aren't in v1).
124
-
125
- ### Deprecated `shortAutoexposed`
126
-
127
- In compiler v1 without an option
128
- (especially the v1 option `dependentAutoexposed` which basically leads the v2 default behavior),
129
- the name for auto-exposed entities were constructed by
130
- adding the name part after the last `.` to the service name.
131
-
132
- That is, for the above example,
133
- the auto-exposed projection on `my.Model.Base_texts` (in v1) is named
134
- `our.Service.Base_texts` in v1.
135
-
136
- You can temporarily enable that behavior in v2 by setting the options
137
- `deprecated.generatedEntityNameWithUnderscore` and `deprecated.shortAutoexposed`.
138
-
139
- If you just set `deprecated.shortAutoexposed`, you get `our.Service.Base.texts`.
140
-
141
- If you really need that name (instead of the v2 name `our.Service.Proj.texts`),
142
- you can expose the texts entity manually instead of setting the deprecated option:
143
-
144
- ```
145
- @cds.autoexposed entity our.Service.Base.texts as projection on my.Model.Base.texts;
146
- ```
147
-
148
- Again, never define a projection on the auto-exposed entity –
149
- you get an error for that starting with compiler v2.2.0
150
- (and earlier for certain definition sequences anyway, actually in v1 also).