@sap/cds-compiler 2.5.2 → 2.11.0

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 (102) hide show
  1. package/CHANGELOG.md +235 -9
  2. package/bin/cdsc.js +44 -27
  3. package/bin/cdsse.js +1 -0
  4. package/doc/CHANGELOG_BETA.md +37 -3
  5. package/lib/api/.eslintrc.json +2 -0
  6. package/lib/api/main.js +37 -123
  7. package/lib/api/options.js +27 -15
  8. package/lib/api/validate.js +34 -9
  9. package/lib/backends.js +9 -89
  10. package/lib/base/dictionaries.js +2 -1
  11. package/lib/base/keywords.js +32 -2
  12. package/lib/base/message-registry.js +73 -11
  13. package/lib/base/messages.js +86 -30
  14. package/lib/base/model.js +6 -6
  15. package/lib/base/optionProcessorHelper.js +56 -22
  16. package/lib/checks/defaultValues.js +27 -2
  17. package/lib/checks/elements.js +1 -6
  18. package/lib/checks/foreignKeys.js +0 -6
  19. package/lib/checks/managedWithoutKeys.js +17 -0
  20. package/lib/checks/nonexpandableStructured.js +38 -0
  21. package/lib/checks/onConditions.js +9 -45
  22. package/lib/checks/queryNoDbArtifacts.js +25 -7
  23. package/lib/checks/selectItems.js +29 -2
  24. package/lib/checks/types.js +26 -2
  25. package/lib/checks/unknownMagic.js +41 -0
  26. package/lib/checks/utils.js +61 -0
  27. package/lib/checks/validator.js +60 -7
  28. package/lib/compiler/assert-consistency.js +23 -7
  29. package/lib/compiler/base.js +65 -0
  30. package/lib/compiler/builtins.js +30 -1
  31. package/lib/compiler/checks.js +8 -5
  32. package/lib/compiler/definer.js +157 -133
  33. package/lib/compiler/index.js +89 -31
  34. package/lib/compiler/propagator.js +5 -2
  35. package/lib/compiler/resolver.js +375 -185
  36. package/lib/compiler/shared.js +49 -202
  37. package/lib/compiler/utils.js +173 -0
  38. package/lib/edm/annotations/genericTranslation.js +183 -187
  39. package/lib/edm/csn2edm.js +104 -108
  40. package/lib/edm/edm.js +18 -21
  41. package/lib/edm/edmPreprocessor.js +388 -146
  42. package/lib/edm/edmUtils.js +104 -34
  43. package/lib/gen/Dictionary.json +22 -0
  44. package/lib/gen/language.checksum +1 -1
  45. package/lib/gen/language.interp +28 -1
  46. package/lib/gen/language.tokens +79 -69
  47. package/lib/gen/languageLexer.interp +28 -1
  48. package/lib/gen/languageLexer.js +879 -805
  49. package/lib/gen/languageLexer.tokens +71 -62
  50. package/lib/gen/languageParser.js +5330 -4300
  51. package/lib/json/from-csn.js +110 -52
  52. package/lib/json/to-csn.js +434 -120
  53. package/lib/language/antlrParser.js +15 -3
  54. package/lib/language/errorStrategy.js +1 -0
  55. package/lib/language/genericAntlrParser.js +93 -26
  56. package/lib/language/language.g4 +172 -31
  57. package/lib/main.d.ts +216 -19
  58. package/lib/main.js +32 -7
  59. package/lib/model/api.js +78 -0
  60. package/lib/model/csnRefs.js +413 -149
  61. package/lib/model/csnUtils.js +286 -75
  62. package/lib/model/enrichCsn.js +50 -6
  63. package/lib/model/revealInternalProperties.js +22 -5
  64. package/lib/modelCompare/compare.js +39 -21
  65. package/lib/optionProcessor.js +35 -18
  66. package/lib/render/.eslintrc.json +4 -1
  67. package/lib/render/DuplicateChecker.js +9 -6
  68. package/lib/render/toCdl.js +121 -36
  69. package/lib/render/toHdbcds.js +148 -98
  70. package/lib/render/toSql.js +114 -43
  71. package/lib/render/utils/common.js +8 -13
  72. package/lib/render/utils/sql.js +3 -3
  73. package/lib/sql-identifier.js +6 -1
  74. package/lib/transform/db/assertUnique.js +5 -6
  75. package/lib/transform/db/constraints.js +281 -106
  76. package/lib/transform/db/draft.js +11 -8
  77. package/lib/transform/db/expansion.js +584 -0
  78. package/lib/transform/db/flattening.js +341 -0
  79. package/lib/transform/db/groupByOrderBy.js +2 -2
  80. package/lib/transform/db/transformExists.js +345 -65
  81. package/lib/transform/db/views.js +438 -0
  82. package/lib/transform/forHanaNew.js +131 -793
  83. package/lib/transform/forOdataNew.js +30 -24
  84. package/lib/transform/localized.js +39 -10
  85. package/lib/transform/odata/attachPath.js +19 -4
  86. package/lib/transform/odata/generateForeignKeyElements.js +11 -10
  87. package/lib/transform/odata/referenceFlattener.js +60 -39
  88. package/lib/transform/odata/sortByAssociationDependency.js +2 -2
  89. package/lib/transform/odata/structuralPath.js +72 -0
  90. package/lib/transform/odata/structureFlattener.js +19 -18
  91. package/lib/transform/odata/typesExposure.js +22 -12
  92. package/lib/transform/transformUtilsNew.js +144 -78
  93. package/lib/transform/translateAssocsToJoins.js +22 -27
  94. package/lib/transform/universalCsnEnricher.js +67 -0
  95. package/lib/utils/file.js +5 -14
  96. package/lib/utils/moduleResolve.js +6 -8
  97. package/lib/utils/term.js +65 -42
  98. package/lib/utils/timetrace.js +48 -26
  99. package/package.json +1 -1
  100. package/lib/json/walker.js +0 -26
  101. package/lib/transform/sqlite +0 -0
  102. package/lib/utils/string.js +0 -17
package/CHANGELOG.md CHANGED
@@ -7,6 +7,226 @@
7
7
  Note: `beta` fixes, changes and features are usually not listed in this ChangeLog but [here](doc/CHANGELOG_BETA.md).
8
8
  The compiler behavior concerning `beta` features can change at any time without notice.
9
9
 
10
+ ## Version 2.11.0 - 2021-12-02
11
+
12
+ ### Added
13
+
14
+ - Option `defaultBinaryLength` to set a `length` type facet for all definitions with type `cds.Binary`. This option
15
+ overrides the default binary length in the database backends and is also used as `MaxLength` attribute in Odata.
16
+ - If doc-comments are ignored by the compiler, an info message is now emitted. A doc-comment is ignored,
17
+ if it can't be assigned to an artifact. For example for two subsequent doc-comments, the first doc-comment
18
+ is ignored. To suppress these info messages, explicitly set option `docComment` to `false`.
19
+ - `cdsc`:
20
+ - `cdsc explain list` can now be used to get a list of message IDs with explanation texts.
21
+ - `cdsc` now respects the environment variable `NO_COLOR`. If set, no ANSI escape codes will be used.
22
+ Can be overwritten by `cdsc --color always`.
23
+ - to.sql/hdi: Support SQL Window Functions
24
+ - to.sql/hdi/hdbcds:
25
+ + Support configuration of `$session` and `$user` via option `variableReplacements`.
26
+ + Restricted support for SQL foreign key constraints if option `assertIntegrityType` is set to `"DB"`.
27
+ The behavior of this feature might change in the future.
28
+
29
+ ### Changed
30
+
31
+ - Updated OData vocabularies 'Common' and 'UI'.
32
+ - to.sql/hdi/hdbcds: The default length of `cds.Binary` is set to `5000` similar to `cds.String`.
33
+
34
+ ### Removed
35
+
36
+ - to.hdbcds: Doc comments on view columns are not rendered anymore. Doc comments on string literals will make the deployment fail
37
+ as the SAP HANA CDS compiler concatenates the doc comment with the string literal. Besides that, doc comments on view columns
38
+ are not transported to the database by SAP HANA CDS.
39
+ - to.hdbcds/sql/hdi: Forbid associations in filters after `exists` (except for nested `exists`), as the final behavior is not yet specified.
40
+
41
+ ### Fixed
42
+
43
+ - CSN parser: doc-comment extensions are no longer ignored.
44
+ - Properly check for duplicate annotation definitions.
45
+ - Correctly apply annotations on inherited enum symbols.
46
+ - Correctly apply annotations on elements in an inherited structure array.
47
+ - Fix a bug in API `defaultStringLength` value evaluation.
48
+ - Fix crash if named arguments are used in a function that's inside a `CASE` statement.
49
+ - to.sql/hdi/hdbcds:
50
+ + Properly flatten ad-hoc defined elements in `returns` / `params` of `actions` and `functions`.
51
+ + Correctly handle `*` in non-first position.
52
+ + Correctly handle action return types
53
+ + Correctly handle mixin association named `$self`
54
+ - to.cdl: doc-comments are no longer rendered twice.
55
+ - to.edm(x):
56
+ + Fix a bug in V2/V4 partner ship calculation.
57
+ + Remove warning of unknown types for Open Types in `@Core.Dictionary`.
58
+ + An empty CSN no longer results in a JavaScript type error
59
+
60
+ ## Version 2.10.4 - 2021-11-05
61
+
62
+ ### Fixed
63
+
64
+ - to.sql/hdi/hdbcds:
65
+ + Correctly complain about `exists` in conjunction with non-associations/compositions
66
+ + Don't resolve types in action returns, as this causes issues with $self-resolution
67
+
68
+ - to.edm(x): Be robust against transitively untyped keys in stacked view hierarchies
69
+
70
+ ## Version 2.10.2 - 2021-10-29
71
+
72
+ ### Fixed
73
+
74
+ - to.sql/hdi/hdbcds: Correctly handle `exists` in conjunction with mixin-associations
75
+
76
+ ## Version 2.10.0 - 2021-10-28
77
+
78
+ ### Added
79
+
80
+ - Support arbitrary paths after `$user` - similar to `$session`.
81
+ - Support scale `floating` and `variable` for `cds.Decimal` in CDL and CSN. Backend specific handling is descibed in their sections.
82
+ - Allow select item wildcard (`*`) in a `select`/`projection` at any position, not just the first.
83
+
84
+ - to.edm(x):
85
+ + In Odata V4 generate transitive navigation property binding paths along containment hierarchies and terminate on the
86
+ first non-containment association. The association target is either an explicit Edm.EntitySet in the same EntityContainer
87
+ or in a referred EntityContainer (cross service references) or an implicit EntitySet identified by the containment path
88
+ originating from an explicit EntitySet. This enhancement has an observable effect only in structured format with containment
89
+ turned on.
90
+ + Support for scales `variable` and `floating`:
91
+ + V4: `variable` and `floating` are rendered as `Scale="variable"`. Since V4 does not support `floating`, it is aproximated as `variable`.
92
+ + V2: `variable` and `floating` are announced via property annotation `sap:variable-scale="true"`
93
+
94
+ - to.sql/hdi/hdbcds:
95
+ + Reject scale `floating` and `variable`.
96
+ + Reject arbitrary `$user` or `$session` paths that cannot be translated to valid SQL.
97
+ + Following a valid `exists`, further `exists` can be used inside of the filter-expression: `exists assoc[exists another[1=1]]`
98
+ + `exists` can now be followed by more than one association step.
99
+ `exists assoc.anotherassoc.moreassoc` is semantically equivalent to `exists assoc[exists anotherassoc[exists moreassoc]]`
100
+
101
+ ### Changed
102
+
103
+ - to.odata: Inform when overwriting draft action annotations like `@Common.DraftRoot.ActivationAction`.
104
+
105
+ ## Version 2.9.0 - 2021-10-15
106
+
107
+ ### Changed
108
+
109
+ - to.edm(x): Raise `odata-spec-violation-type` to a downgradable error.
110
+
111
+ ### Fixed
112
+
113
+ - to.edm(x):
114
+ + Fix a bug in annotation propagation to foreign keys.
115
+ + Don't render annotations for not rendered stream element in V2.
116
+ - to.hdi:
117
+ + for naming mode "hdbcds" and "quoted" parameter definitions are not quoted anymore.
118
+ - to.hdi/sql/hdbcds:
119
+ + Correctly handle explicit and implicit alias during flattening.
120
+ + Raise an error for `@odata.draft.enabled` artifacts with elements without types - instead of crashing with internal assertions.
121
+
122
+ ## Version 2.8.0 - 2021-10-07
123
+
124
+ ### Added
125
+
126
+ - Allow defining unmanaged associations in anonymous aspects of compositions.
127
+ - Enable extensions of anonymous aspects for managed compositions of aspects.
128
+ - When the option `addTextsLanguageAssoc` is set to true and
129
+ the model contains an entity `sap.common.Languages` with an element `code`,
130
+ all generated texts entities additionally contain an element `language`
131
+ which is an association to `sap.common.Languages` using element `local`.
132
+ - for.odata:
133
+ + In `--odata-format=flat`, structured view parameters are flattened like elements.
134
+ - to.hdbcds
135
+ + Use "smart quotes" for naming mode "plain" - automatically quote identifier which are reserved keywords or non-regular.
136
+
137
+ ### Changed
138
+
139
+ - for.odata:
140
+ + In `--data-format=structured`, anonymous sub elements of primary keys and parameters are set to `notNull:true`,
141
+ an existing `notNull` attribute is _not_ overwritten. Referred named types are _not_ modified.
142
+ - to.edm(x):
143
+ + Improve specification violation checks of (nested) keys:
144
+ + All (sub-)elements must be `Nullable: false` (error).
145
+ + Must represent a single value (error).
146
+ + In V4 must be a specification compliant Edm.PrimitiveType (warning).
147
+ - to.hdi/hdbcds/sql: $user.\<xy\> now has \<xy\> added as alias - "$user.\<xy\> as \<xy\>"
148
+
149
+ ### Fixed
150
+
151
+ - Properly generate auto-exposed entities for associations in parameters.
152
+ - Correctly apply extensions to anonymous array item types.
153
+ - Correctly apply/render annotations to anonymous action return types.
154
+ - With CSN flavor `plain` (`gensrc`), correctly render annotations on elements
155
+ of referred structure types as `annotate` statements in the CSN's `extensions` property.
156
+ - to.cdl:
157
+ + Correctly render extensions on array item types
158
+ + Correctly render annotations on action return types
159
+ - to/for: Correctly handle CSN input where the prototype of objects is not the "default"
160
+ - to.hdi:
161
+ + for naming mode "hdbcds" and "quoted" parameter definitions are now quoted.
162
+ + for naming mode "plain", smart quotation is applied to parameter definitions if they are reserved words.
163
+ - to.hdi/hdbcds/sql:
164
+ + Ensure that cdl-style casts to localized types do not lose their localized property
165
+ + Fix a small memory leak during rendering of SQL/HDBCDS.
166
+ - to.edm(x): Remove ambiguous `Partner` attribute from `NavigationProperty`. A forward association referred
167
+ to by multiple backlinks (`$self` comparisons) is no longer partner to an arbitrary backlink.
168
+
169
+ ## Version 2.7.0 - 2021-09-22
170
+
171
+ ### Added
172
+
173
+ - to.hdi.migration:
174
+ + Support changes to HANA comments.
175
+
176
+ ### Changed
177
+
178
+ - Updated OData vocabularies 'Common', 'Core'
179
+
180
+ ### Fixed
181
+
182
+ - Fix memory issue: do not keep reference to last-compiled model.
183
+ - Fix dump which occured when trying to report that the user has defined an element to be both `key` and `localized` if
184
+ `localized` was inherited via the provided type, or in the generated entity for a managed composition of aspect.
185
+ - Properly auto-expose targets of associations in parameters and `many`.
186
+ - for.Odata:
187
+ + Fix handling of annotation `@cds.odata.valuelist` in conjunction with associations in structures using flat-mode and sqlMapping set to plain.
188
+ + Set correctly the $localized property in the OData backend resulting CSN for artifacts that have localized convenience views.
189
+ - to.edm(x):
190
+ + Fix rendering of structured referential constraints and nested partnerships in combination with `$self` comparisons.
191
+ + Fix merging of `@Capabilities` annotations while transforming them into `NavigationCapabilities` from the containee into the container.
192
+ - to.sql/hdi/hdbcds:
193
+ + Fix a bug in Association to Join translation in multi-level association redirection in combination with `$self`.
194
+ + Correctly flatten paths with filters or parameters.
195
+ + Improve error message in case of invalid `exists`.
196
+
197
+ ## Version 2.6.2 - 2021-08-26
198
+
199
+ ### Fixed
200
+
201
+ - to.sql/hdi/hdbcds/edm(x)/for.odata: Correctly handle tuple expansion in subqueries of Unions.
202
+
203
+ ## Version 2.6.0 - 2021-08-23
204
+
205
+ ### Added
206
+
207
+ - Support managed associations without foreign keys. Associations targeting a definition without primary keys or with an
208
+ explicit empty foreign key tuple or with empty structured elements as foreign keys and their corresponding `$self`
209
+ comparisons do not describe the relationship between the source and the target entity.
210
+ These associations can be used to establish API navigations but cannot be used to access elements in the target
211
+ entity as they cannot be transformed into a valid JOIN expression.
212
+ Consequently, these associations are not added to the `WITH ASSOCIATIONS` clause or forwarded to HANA CDS.
213
+ - to.sql/hdi/hdbcds/edm(x)/for.odata: Structure/managed association comparisons (tuple comparisons) are now
214
+ also expanded in infix filters, all expressions and all on-conditions.
215
+ - to.hdbcds: Better locations for messages - mostly concerning keywords and duplicates
216
+
217
+ ### Changed
218
+
219
+ - to.sql/hdi/hdbcds: Invalid (i.e. not expandable) usage of structures is now checked - an error is raised
220
+
221
+ ### Removed
222
+
223
+ - The internal non-enumerable CSN property `$env` has been removed from the compiled CSN.
224
+
225
+ ### Fixed
226
+
227
+ - Make `;` optional before `}` in all circumstances (was not the case with `many`).
228
+ - to.sql/hdi/hdbcds/edm(x): More graceful handling of CSN input where associations do not have `keys` or an `on`-condition
229
+
10
230
  ## Version 2.5.2 - 2021-08-10
11
231
 
12
232
  ### Fixed
@@ -53,19 +273,19 @@ The compiler behavior concerning `beta` features can change at any time without
53
273
  and 'Ignoring draft node for composition target ... because it is not part of a service'
54
274
  - Doc comments are no longer ignored after enum values and on view columns in parseCdl mode.
55
275
  - to.cdl:
56
- - Doc comments for enum values are correctly rendered.
57
- - Enum value and doc comments are now correctly rendered if the enum is called `doc`.
58
- - Doc comments at type references are correctly rendered.
59
- - Empty doc comments are correctly rendered and not left out.
60
- - Doc comments on view columns are correctly rendered.
276
+ + Doc comments for enum values are correctly rendered.
277
+ + Enum value and doc comments are now correctly rendered if the enum is called `doc`.
278
+ + Doc comments at type references are correctly rendered.
279
+ + Empty doc comments are correctly rendered and not left out.
280
+ + Doc comments on view columns are correctly rendered.
61
281
  - to.edm(x):
62
- - OData V2: Ignore `@odata.singleton`.
63
- - OData V4: Do not render an `edm:NavigationPropertyBinding` to a singleton if the association has
282
+ + OData V2: Ignore `@odata.singleton`.
283
+ + OData V4: Do not render an `edm:NavigationPropertyBinding` to a singleton if the association has
64
284
  cardinality 'to-many'.
65
285
  - forOData:
66
- - Fix automatic renaming of shortcut annotation (eg. `@label`) with value `null`.
286
+ + Fix automatic renaming of shortcut annotation (eg. `@label`) with value `null`.
67
287
  - CSN parser:
68
- - Empty doc comments are correctly parsed and not complained about.
288
+ + Empty doc comments are correctly parsed and not complained about.
69
289
 
70
290
  ## Version 2.4.4 - 2021-07-02
71
291
 
@@ -483,6 +703,12 @@ synchronously.
483
703
  - to.hdi.migration: Don't generate `ALTER` for type change from association to composition or vice versa (if the rest stays the same),
484
704
  as the resulting SQL is identical.
485
705
 
706
+ ## Version 1.50.10 - 2021-07-30
707
+
708
+ ### Fixed
709
+
710
+ - to.hdi.migration: Check for incompatible CSN versions to avoid wrongly generated ALTER|DROP|ADD statements.
711
+
486
712
  ## Version 1.50.8 - 2021-07-01
487
713
 
488
714
  ### Fixed
package/bin/cdsc.js CHANGED
@@ -26,8 +26,10 @@ const path = require('path');
26
26
  const { reveal } = require('../lib/model/revealInternalProperties');
27
27
  const enrichCsn = require('../lib/model/enrichCsn');
28
28
  const { optionProcessor } = require('../lib/optionProcessor');
29
- const { explainMessage, hasMessageExplanation, sortMessages } = require('../lib/base/messages');
30
- const term = require('../lib/utils/term');
29
+ const {
30
+ explainMessage, hasMessageExplanation, sortMessages, messageIdsWithExplanation,
31
+ } = require('../lib/base/messages');
32
+ const { term } = require('../lib/utils/term');
31
33
  const { splitLines } = require('../lib/utils/file');
32
34
  const { addLocalizationViews } = require('../lib/transform/localized');
33
35
  const { availableBetaFlags } = require('../lib/base/model');
@@ -52,9 +54,11 @@ function remapCmdOptions(options, cmdOptions) {
52
54
  options.sqlMapping = value;
53
55
  break;
54
56
  case 'user':
55
- if (!options.magicVars)
56
- options.magicVars = {};
57
- options.magicVars.user = value;
57
+ if (!options.variableReplacements)
58
+ options.variableReplacements = {};
59
+ if (!options.variableReplacements.$user)
60
+ options.variableReplacements.$user = {};
61
+ options.variableReplacements.$user.id = value;
58
62
  break;
59
63
  case 'dialect':
60
64
  options.sqlDialect = value;
@@ -63,9 +67,11 @@ function remapCmdOptions(options, cmdOptions) {
63
67
  options.odataVersion = value;
64
68
  break;
65
69
  case 'locale':
66
- if (!options.magicVars)
67
- options.magicVars = {};
68
- options.magicVars.locale = value;
70
+ if (!options.variableReplacements)
71
+ options.variableReplacements = {};
72
+ if (!options.variableReplacements.$user)
73
+ options.variableReplacements.$user = {};
74
+ options.variableReplacements.$user.locale = value;
69
75
  break;
70
76
  default:
71
77
  options[key] = value;
@@ -124,8 +130,6 @@ try {
124
130
  global.cds = {};
125
131
  global.cds.home = cmdLine.options.cdsHome;
126
132
  }
127
- // Default color mode is 'auto'
128
- term.useColor(cmdLine.options.color || 'auto');
129
133
 
130
134
  // Set default command if required
131
135
  cmdLine.command = cmdLine.command || 'toCsn';
@@ -137,10 +141,7 @@ try {
137
141
  if (cmdLine.command === 'parseCdl') {
138
142
  cmdLine.command = 'toCsn';
139
143
  cmdLine.options.parseCdl = true;
140
- if (cmdLine.args.files.length > 1) {
141
- const err = `'parseCdl' expects exactly one file! ${cmdLine.args.files.length} provided.`;
142
- displayUsage(err, optionProcessor.commands.parseCdl.helpText, 2);
143
- }
144
+ cmdLine.args.files = [ cmdLine.args.file ];
144
145
  }
145
146
 
146
147
  if (cmdLine.options.directBackend)
@@ -155,6 +156,14 @@ try {
155
156
  });
156
157
  }
157
158
 
159
+ // remap string values for `assertIntegrity` option to boolean
160
+ if (cmdLine.options.assertIntegrity &&
161
+ cmdLine.options.assertIntegrity === 'true' ||
162
+ cmdLine.options.assertIntegrity === 'false'
163
+ )
164
+ cmdLine.options.assertIntegrity = Boolean(cmdLine.options.assertIntegrity);
165
+
166
+
158
167
  // Enable all beta-flags if betaMode is set to true
159
168
  if (cmdLine.options.betaMode)
160
169
  cmdLine.options.beta = availableBetaFlags;
@@ -231,6 +240,8 @@ function executeCommandLine(command, options, args) {
231
240
  if (options.out && options.out !== '-' && !fs.existsSync(options.out))
232
241
  fs.mkdirSync(options.out);
233
242
 
243
+ // Default color mode is 'auto'
244
+ const colorTerm = term(options.color || 'auto');
234
245
 
235
246
  // Add implementation functions corresponding to commands here
236
247
  const commands = {
@@ -393,14 +404,15 @@ function executeCommandLine(command, options, args) {
393
404
  }
394
405
 
395
406
  function explain() {
396
- if (args.length !== 1)
397
- displayUsage('Command \'explain\' expects exactly one message-id.', optionProcessor.commands.explain.helpText, 2);
407
+ if (args.messageId === 'list') {
408
+ console.log(messageIdsWithExplanation().join('\n'));
409
+ throw new ProcessExitError(0);
410
+ }
398
411
 
399
- const id = args.files[0];
400
- if (!hasMessageExplanation(id))
401
- console.error(`Message '${id}' does not have an explanation!`);
412
+ if (!hasMessageExplanation(args.messageId))
413
+ console.error(`Message '${args.messageId}' does not have an explanation!`);
402
414
  else
403
- console.log(explainMessage(id));
415
+ console.log(explainMessage(args.messageId));
404
416
  }
405
417
 
406
418
  // Display error messages in `err` resulting from a compilation. Also set
@@ -411,7 +423,7 @@ function executeCommandLine(command, options, args) {
411
423
  if (options.rawOutput)
412
424
  console.error( util.inspect( reveal( err.model, options.rawOutput ), false, null ));
413
425
  else
414
- displayMessages( err.model, err.errors );
426
+ displayMessages( err.model, err.messages );
415
427
  process.exitCode = 1;
416
428
  }
417
429
  else if (err instanceof compiler.InvocationError) {
@@ -464,16 +476,20 @@ function executeCommandLine(command, options, args) {
464
476
  hasAtLeastOneExplanation = hasAtLeastOneExplanation || main.hasMessageExplanation(msg.messageId);
465
477
  const name = msg.location && msg.location.file;
466
478
  const fullFilePath = name ? path.resolve('', name) : undefined;
467
- const context = fullFilePath && sourceLines(fullFilePath);
479
+ const context = fullFilePath ? sourceLines(fullFilePath) : [];
468
480
  log(main.messageStringMultiline(msg, {
469
- normalizeFilename, noMessageId: !options.showMessageId, withLineSpacer: true, hintExplanation: true,
481
+ normalizeFilename,
482
+ noMessageId: !options.showMessageId,
483
+ withLineSpacer: true,
484
+ hintExplanation: true,
485
+ color: options.color,
470
486
  }));
471
487
  if (context)
472
- log(main.messageContext(context, msg));
488
+ log(main.messageContext(context, msg, { color: options.color }));
473
489
  log(); // newline
474
490
  });
475
491
  if (options.showMessageId && hasAtLeastOneExplanation)
476
- log(`${term.help('help')}: Messages marked with '…' have an explanation text. Use \`cdsc explain <message-id>\` for a more detailed error description.`);
492
+ log(`${colorTerm.help('help')}: Messages marked with '…' have an explanation text. Use \`cdsc explain <message-id>\` for a more detailed error description.`);
477
493
  }
478
494
  return model;
479
495
  }
@@ -528,7 +544,7 @@ function executeCommandLine(command, options, args) {
528
544
  fileName = fileName.replace(/[:/\\]/g, '_');
529
545
 
530
546
  // replace all dots with underscore to get deployable .hdbcds sources (except the one before the file extension)
531
- if (options.toHana)
547
+ if (options.transformation === 'hdbcds')
532
548
  fileName = fileName.replace(/\.(?=.*?\.)/g, '_');
533
549
 
534
550
  if (!(content instanceof String || typeof content === 'string'))
@@ -549,10 +565,11 @@ function executeCommandLine(command, options, args) {
549
565
  }
550
566
 
551
567
  function catchErrors(err) {
568
+ // @ts-ignore
552
569
  if (err instanceof Error && err.hasBeenReported)
553
570
  return;
554
571
  console.error( '' );
555
- console.error( 'INTERNAL ERROR: %s', err );
572
+ console.error( 'INTERNAL ERROR:' );
556
573
  console.error( util.inspect(err, false, null) );
557
574
  console.error( '' );
558
575
  process.exitCode = 70;
package/bin/cdsse.js CHANGED
@@ -11,6 +11,7 @@
11
11
  // Planned are: gotoDefinition, highlight (for syntax highighting).
12
12
 
13
13
  /* eslint no-console:off */
14
+ // @ts-nocheck
14
15
 
15
16
  'use strict';
16
17
 
@@ -1,12 +1,47 @@
1
1
  # ChangeLog of Beta Features for cdx compiler and backends
2
2
 
3
3
  <!-- markdownlint-disable MD024 -->
4
+ <!-- markdownlint-disable MD004 -->
4
5
  <!-- (no-duplicate-heading)-->
5
6
 
6
7
  Note: `beta` fixes, changes and features are listed in this ChangeLog just for information.
7
8
  The compiler behavior concerning `beta` features can change at any time without notice.
8
9
  **Don't use `beta` fixes, changes and features in productive mode.**
9
10
 
11
+ ## Version 2.11.0
12
+
13
+ ### Removed `foreignKeyConstraints`
14
+
15
+ ## Version 2.10.4
16
+
17
+ ### Fixed `nestedProjections`
18
+
19
+ - to.sql/hdi/hdbcds: Correctly handle a `*` at the not-first place in the query
20
+
21
+ ## Version 2.6.0
22
+
23
+ ### Removed `pretransformedCSN`
24
+
25
+ ### Removed `renderSql`
26
+
27
+ ### Removed `keylessManagedAssoc`
28
+
29
+ This is now the default - see CHANGELOG entry for 2.6.0
30
+
31
+ ### Fixed `nestedProjections`
32
+
33
+ - to.sql/hdi/hdbcds: now work correctly when nested projections are used
34
+
35
+ ### Fixed `foreignKeyConstraints`
36
+
37
+ - Always use the name of the association / backlink compared to
38
+ `$self` as name suffix for a constraint
39
+ - Composition of one always result in:
40
+ + ON DELETE RESTRICT
41
+ + ON UPDATE RESTRICT
42
+ - Composition of one w/o backlink will result in a constraint in
43
+ the entity where the composition is defined
44
+
10
45
  ## Version 2.4.4
11
46
 
12
47
  ### Added `nestedProjections`
@@ -15,8 +50,8 @@ The compiler behavior concerning `beta` features can change at any time without
15
50
  `longer.ref as name { *, … } excluding { … }`, `{ col_expression1 as sub1, … } as name`, etc.
16
51
  - Support `inline`: columns can look like `assoc_or_struct_or_tabalias.{ col_expression1, … }`,
17
52
  `longer.ref[filter = condition].{ *, … } excluding { … }`, `assoc_or_struct_or_tabalias.*`, etc.
18
- - _Some checks are missing and will be added! Minor changes might occur._
19
- - __The SQL backends might not work properly yet if nested projections are used!__
53
+ - _Some checks are missing and will be added! Minor changes might occur._
54
+ - **The SQL backends might not work properly yet if nested projections are used!**
20
55
 
21
56
  ## Version 2.4.2
22
57
 
@@ -30,7 +65,6 @@ The compiler behavior concerning `beta` features can change at any time without
30
65
  Consequently, these associations are not added to the `WITH ASSOCIATIONS` clause or forwarded to HANA CDS.
31
66
  Managed Associations without foreign keys must be enabled with `--beta: keylessManagedAssoc`
32
67
 
33
-
34
68
  ## Version 2.4.0
35
69
 
36
70
  ### Changed `foreignKeyConstraints`
@@ -14,6 +14,8 @@
14
14
  "jsdoc"
15
15
  ],
16
16
  "rules": {
17
+ // Does not recognize TS types
18
+ "jsdoc/no-undefined-types": "off",
17
19
  // eslint-plugin-jsdoc warning
18
20
  "jsdoc/require-property": 0,
19
21
  // =airbnb, >eslint: