@sap/cds-compiler 2.11.4 → 2.13.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +159 -1
- package/bin/cds_update_identifiers.js +7 -7
- package/bin/cdsc.js +22 -23
- package/bin/cdsse.js +2 -2
- package/doc/CHANGELOG_ARCHIVE.md +1 -1
- package/doc/CHANGELOG_BETA.md +25 -6
- package/doc/CHANGELOG_DEPRECATED.md +22 -6
- package/doc/NameResolution.md +21 -16
- package/lib/api/main.js +30 -63
- package/lib/api/options.js +5 -5
- package/lib/api/validate.js +0 -5
- package/lib/backends.js +15 -23
- package/lib/base/dictionaries.js +0 -8
- package/lib/base/error.js +26 -0
- package/lib/base/keywords.js +7 -17
- package/lib/base/location.js +9 -4
- package/lib/base/message-registry.js +52 -2
- package/lib/base/messages.js +16 -26
- package/lib/base/model.js +2 -62
- package/lib/base/optionProcessorHelper.js +246 -183
- package/lib/checks/.eslintrc.json +2 -0
- package/lib/checks/actionsFunctions.js +2 -1
- package/lib/checks/annotationsOData.js +1 -1
- package/lib/checks/cdsPersistence.js +2 -1
- package/lib/checks/enricher.js +17 -1
- package/lib/checks/foreignKeys.js +4 -4
- package/lib/checks/invalidTarget.js +3 -1
- package/lib/checks/managedInType.js +4 -4
- package/lib/checks/managedWithoutKeys.js +3 -1
- package/lib/checks/queryNoDbArtifacts.js +1 -3
- package/lib/checks/selectItems.js +4 -4
- package/lib/checks/sql-snippets.js +94 -0
- package/lib/checks/types.js +1 -1
- package/lib/checks/validator.js +12 -7
- package/lib/compiler/assert-consistency.js +10 -6
- package/lib/compiler/base.js +0 -1
- package/lib/compiler/builtins.js +8 -6
- package/lib/compiler/checks.js +46 -12
- package/lib/compiler/cycle-detector.js +1 -1
- package/lib/compiler/define.js +1103 -0
- package/lib/compiler/extend.js +983 -0
- package/lib/compiler/finalize-parse-cdl.js +231 -0
- package/lib/compiler/index.js +33 -14
- package/lib/compiler/kick-start.js +190 -0
- package/lib/compiler/moduleLayers.js +4 -4
- package/lib/compiler/populate.js +1226 -0
- package/lib/compiler/propagator.js +113 -47
- package/lib/compiler/resolve.js +1433 -0
- package/lib/compiler/shared.js +76 -38
- package/lib/compiler/tweak-assocs.js +529 -0
- package/lib/compiler/utils.js +204 -33
- package/lib/edm/.eslintrc.json +5 -0
- package/lib/edm/annotations/genericTranslation.js +38 -25
- package/lib/edm/annotations/preprocessAnnotations.js +3 -3
- package/lib/edm/csn2edm.js +10 -9
- package/lib/edm/edm.js +19 -20
- package/lib/edm/edmPreprocessor.js +166 -95
- package/lib/edm/edmUtils.js +127 -34
- package/lib/gen/Dictionary.json +92 -43
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +11 -1
- package/lib/gen/language.tokens +86 -82
- package/lib/gen/languageLexer.interp +18 -1
- package/lib/gen/languageLexer.js +925 -847
- package/lib/gen/languageLexer.tokens +78 -74
- package/lib/gen/languageParser.js +5434 -4298
- package/lib/json/from-csn.js +59 -17
- package/lib/json/to-csn.js +143 -71
- package/lib/language/antlrParser.js +3 -3
- package/lib/language/docCommentParser.js +3 -3
- package/lib/language/genericAntlrParser.js +144 -54
- package/lib/language/language.g4 +424 -203
- package/lib/language/multiLineStringParser.js +536 -0
- package/lib/main.d.ts +472 -61
- package/lib/main.js +38 -11
- package/lib/model/api.js +3 -1
- package/lib/model/csnRefs.js +321 -204
- package/lib/model/csnUtils.js +224 -263
- package/lib/model/enrichCsn.js +97 -40
- package/lib/model/revealInternalProperties.js +27 -6
- package/lib/model/sortViews.js +2 -1
- package/lib/modelCompare/compare.js +17 -12
- package/lib/optionProcessor.js +7 -6
- package/lib/render/DuplicateChecker.js +1 -1
- package/lib/render/manageConstraints.js +36 -33
- package/lib/render/toCdl.js +174 -275
- package/lib/render/toHdbcds.js +201 -115
- package/lib/render/toRename.js +7 -10
- package/lib/render/toSql.js +149 -75
- package/lib/render/utils/common.js +22 -8
- package/lib/render/utils/sql.js +10 -7
- package/lib/render/utils/stringEscapes.js +111 -0
- package/lib/sql-identifier.js +1 -1
- package/lib/transform/.eslintrc.json +5 -0
- package/lib/transform/braceExpression.js +4 -2
- package/lib/transform/db/.eslintrc.json +2 -0
- package/lib/transform/db/applyTransformations.js +35 -12
- package/lib/transform/db/assertUnique.js +1 -1
- package/lib/transform/db/associations.js +187 -0
- package/lib/transform/db/cdsPersistence.js +150 -0
- package/lib/transform/db/constraints.js +61 -56
- package/lib/transform/db/expansion.js +50 -29
- package/lib/transform/db/flattening.js +552 -105
- package/lib/transform/db/groupByOrderBy.js +3 -1
- package/lib/transform/db/temporal.js +236 -0
- package/lib/transform/db/transformExists.js +94 -28
- package/lib/transform/db/views.js +5 -4
- package/lib/transform/draft/.eslintrc.json +38 -0
- package/lib/transform/{db/draft.js → draft/db.js} +9 -7
- package/lib/transform/draft/odata.js +227 -0
- package/lib/transform/forHanaNew.js +94 -801
- package/lib/transform/forOdataNew.js +22 -175
- package/lib/transform/localized.js +36 -32
- package/lib/transform/odata/generateForeignKeyElements.js +3 -3
- package/lib/transform/odata/referenceFlattener.js +95 -89
- package/lib/transform/odata/structureFlattener.js +1 -1
- package/lib/transform/odata/toFinalBaseType.js +86 -12
- package/lib/transform/odata/typesExposure.js +5 -5
- package/lib/transform/odata/utils.js +2 -2
- package/lib/transform/transformUtilsNew.js +47 -33
- package/lib/transform/translateAssocsToJoins.js +10 -27
- package/lib/transform/universalCsn/.eslintrc.json +36 -0
- package/lib/transform/universalCsn/coreComputed.js +170 -0
- package/lib/transform/universalCsn/universalCsnEnricher.js +715 -0
- package/lib/transform/universalCsn/utils.js +63 -0
- package/lib/utils/file.js +2 -1
- package/lib/utils/objectUtils.js +30 -0
- package/lib/utils/timetrace.js +8 -2
- package/package.json +1 -1
- package/share/messages/README.md +26 -0
- package/lib/compiler/definer.js +0 -2340
- package/lib/compiler/resolver.js +0 -2988
- package/lib/transform/universalCsnEnricher.js +0 -67
package/CHANGELOG.md
CHANGED
|
@@ -7,12 +7,170 @@
|
|
|
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.13.8 - 2022-03-29
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- to.hdbcds/hdi/sql: Correctly handle `localized` in conjunction with `@cds.persistence.exists` and `@cds.persistence.skip`
|
|
15
|
+
|
|
16
|
+
## Version 2.13.6 - 2022-25-03
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- to.hdbcds/hdi/sql: Correctly handle `localized` in conjunction with `@cds.persistence.exists`
|
|
21
|
+
|
|
22
|
+
## Version 2.13.4 - 2022-22-03
|
|
23
|
+
|
|
24
|
+
No changes compared to Version 2.13.0; fixes latest NPM tag
|
|
25
|
+
|
|
26
|
+
## Version 2.13.2 - 2022-22-03
|
|
27
|
+
|
|
28
|
+
No changes compared to Version 2.13.0; fixes latest NPM tag
|
|
29
|
+
|
|
30
|
+
## Version 2.13.0 - 2022-22-03
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
|
|
34
|
+
- CDL syntax:
|
|
35
|
+
+ Allow to `extend E:elem` and `annotate E:elem` instead of having to write deeply nested statements.
|
|
36
|
+
+ Enable `default` values as part of scalar type definitions.
|
|
37
|
+
+ The following `extend` syntax variants are now possible:
|
|
38
|
+
```cds
|
|
39
|
+
extend … with elements { … }
|
|
40
|
+
extend … with definitions { … }
|
|
41
|
+
extend … with columns { … }
|
|
42
|
+
extend … with enum { … }
|
|
43
|
+
extend … with actions { … }
|
|
44
|
+
```
|
|
45
|
+
This syntax expresses _how_ an artifact is extended instead of _what_ is extended.
|
|
46
|
+
+ Using `ORDER BY` in generic functions such as SAP HANA's `first_value` is now possible.
|
|
47
|
+
- Make API function `compileSources` accept CSN objects as file content
|
|
48
|
+
- to.edm(x): Annotate view parameters with `@sap.parameter: mandatory` (V2) and `@Common.FieldControl: #Mandatory` (V4).
|
|
49
|
+
- to.sql/hdi/hdbcds: Introduce the annotations `@sql.prepend` and `@sql.append` that allow inserting user-written SQL
|
|
50
|
+
snippets into the compiler generated content. Changes in annotations `@sql.prepend` and `@sql.append` are now reflected
|
|
51
|
+
in the output of `to.hdi.migration`. This enables CDS Build to produce `.hdbmigrationtable` files translating such model
|
|
52
|
+
changes into schema changes.
|
|
53
|
+
- API: Lists of keywords for various backends are available as `to.<backend>[.<config>].keywords`, e.g. `to.sql.sqlite.keywords`.
|
|
54
|
+
- for.odata/to.edm(x): The draft composition hull is now also taking into account compositions in subelements.
|
|
55
|
+
|
|
56
|
+
### Changed
|
|
57
|
+
|
|
58
|
+
- In query entities inside services, only auto-redirect associations and compositions
|
|
59
|
+
in the main query of the entity.
|
|
60
|
+
- An element now inherits the property `notNull` from its query source (as
|
|
61
|
+
before) or its type (like it does for most other properties);
|
|
62
|
+
`notNull` is then not further propagated to its sub elements anymore.
|
|
63
|
+
- A structure element inherits the property `virtual` from its query source (as
|
|
64
|
+
before), but does not further propagate `virtual` to its sub elements
|
|
65
|
+
(semantically of course, but the CSN is not cluttered with it);
|
|
66
|
+
there is a new warning if a previously `virtual` query entity
|
|
67
|
+
element is now considered to be non-virtual.
|
|
68
|
+
- Do not propagate annotation value `null`.
|
|
69
|
+
The value `null` of an annotation (and `doc`) is used to stop the inheritance
|
|
70
|
+
of an annotation value. This means than other than that, a value `null` should
|
|
71
|
+
not be handled differently to not having set that annotation.
|
|
72
|
+
- In the effective CSN, the structure type is only expanded if something has changed
|
|
73
|
+
for associations: the `target` (`keys` does not change if the `target` does not change)
|
|
74
|
+
unmanaged associations as sub elements are not supported anyway.
|
|
75
|
+
- In the effective CSN, “simple” type properties like `length`, `precision`,
|
|
76
|
+
`scale` and `srid` are propagated even for a propagation via type.
|
|
77
|
+
- Update OData Vocabularies: 'Capabilities', 'Common', 'Core', 'UI'.
|
|
78
|
+
- to.sql:
|
|
79
|
+
+ For SQL dialect `hana` referential constraints are now appended
|
|
80
|
+
as `ALTER TABLE ADD CONSTRAINT` clause to the end of `schema.sql`.
|
|
81
|
+
With option `constraintsInCreateTable` constraints are rendered into the
|
|
82
|
+
`CREATE TABLE` statement.
|
|
83
|
+
+ Referential constraint names are now prefixed with `c__`.
|
|
84
|
+
|
|
85
|
+
### Fixed
|
|
86
|
+
|
|
87
|
+
- Properly resolve references inside anonymous aspects:
|
|
88
|
+
+ references starting with `$self.` made the compiler dump.
|
|
89
|
+
+ a simple `$self` did not always work as expected (it represents the entity created via the anonymous aspect).
|
|
90
|
+
+ other references inside deeply nested anonymous aspects induced a compilation error.
|
|
91
|
+
- compiler: `()` inside `ORDER BY` clause was not correctly set.
|
|
92
|
+
- parse.cdl: References in `ORDER BY` and filters are now correctly resolved.
|
|
93
|
+
- Issue error when trying to introduce managed compositions of aspects in `mixin`s
|
|
94
|
+
- Issue error in all cases for type references to unmanaged associations.
|
|
95
|
+
- Avoid dump when extending an illegal definition with a name starting with `cds.`.
|
|
96
|
+
- to.sql/to.cdl/to.hdbcds/to.hdi: Render `cast()` inside `ORDER BY`, `GROUP BY` and `HAVING` properly.
|
|
97
|
+
- to.sql/hdi/hdbcds:
|
|
98
|
+
+ `$self` was incorrectly treated as a structured path step.
|
|
99
|
+
+ Correctly handle table alias in on-condition of mixin in `exists` expansion.
|
|
100
|
+
+ Correctly handle table `$self` references to aliased fields in on-condition of mixin association
|
|
101
|
+
during `exists` expansion.
|
|
102
|
+
- to.edm: Don't escape `&` as `&`.
|
|
103
|
+
- to.edmx: Escaping compliant to XML specification:
|
|
104
|
+
+ `&` and `<` are always escaped.
|
|
105
|
+
+ `>` is not escaped, unless it appears in text values as `]]>`.
|
|
106
|
+
+ `"` is escaped in attribute values only.
|
|
107
|
+
+ Control characters are always escaped.
|
|
108
|
+
- Ellipsis (`...`) in annotations in different layers but without base annotation now produces an error.
|
|
109
|
+
The old but incorrect behavior can be re-enabled with option `anno-unexpected-ellipsis-layers`.
|
|
110
|
+
|
|
111
|
+
## Version 2.12.0 - 2022-01-25
|
|
112
|
+
|
|
113
|
+
### Added
|
|
114
|
+
|
|
115
|
+
- CDL parser: You can now use multiline string literals and text blocks.
|
|
116
|
+
Use backticks (\`) for string literals that can span multiple lines and can use JavaScript-like escape
|
|
117
|
+
sequences such as `\u{0020}`. You can also use three backticks (\`\`\`) for strings (a.k.a. text blocks)
|
|
118
|
+
which are automatically indentation-stripped and can have an optional language identifier that is used
|
|
119
|
+
for syntax highlighting, similar to markdown. In difference to the former, text blocks require the
|
|
120
|
+
opening and closing backticks to be on separate lines.
|
|
121
|
+
Example:
|
|
122
|
+
````
|
|
123
|
+
@annotation: `Multi
|
|
124
|
+
line\u{0020}strings`
|
|
125
|
+
|
|
126
|
+
@textblock: ```xml
|
|
127
|
+
<summary>
|
|
128
|
+
<detail>The root tag has no indentation in this example</detail>
|
|
129
|
+
</summary>
|
|
130
|
+
```
|
|
131
|
+
````
|
|
132
|
+
|
|
133
|
+
- Enhance the ellipsis operator `...` for array annotations by an `up to ‹val›`:
|
|
134
|
+
only values in the array of the base annotation up to (including) the first match
|
|
135
|
+
of the specified `‹val›` are included at the specified place in the final array value.
|
|
136
|
+
An array annotation can have more than on `... up to ‹val›` items and must also
|
|
137
|
+
have a pure `...` item after them.
|
|
138
|
+
A structured `‹val›` matches if the array item is also a structure and all property
|
|
139
|
+
values in `‹val›` are equal to the corresponding property value in the array value;
|
|
140
|
+
it is not necessary to specify all properties of the array value items in `‹val›`.
|
|
141
|
+
Example
|
|
142
|
+
```
|
|
143
|
+
@Anno: [{name: one, val: 1}, {name: two, val: 2}, {name: four, val: 4}]
|
|
144
|
+
type T: Integer;
|
|
145
|
+
@Anno: [{name: zero, val: 0}, ... up to {name: two}, {name: three, val: 3}, ...]
|
|
146
|
+
annotate T;
|
|
147
|
+
```
|
|
148
|
+
- for.odata: Support `@cds.on {update|insert}` as replacement for deprecated `@odata.on { update|insert }` to
|
|
149
|
+
set `@Core.Computed`.
|
|
150
|
+
|
|
151
|
+
### Changed
|
|
152
|
+
|
|
153
|
+
- Update OData Vocabularies 'Aggregation', 'Capabilities', 'Common', 'Core', PersonalData, 'Session', 'UI'
|
|
154
|
+
|
|
155
|
+
### Fixed
|
|
156
|
+
|
|
157
|
+
- to.sql/hdi/hdbcds: With `exists`, ensure that the precedence of the existing association-on-conditions and where-conditions is kept by adding braces.
|
|
158
|
+
- to.sql/hdi: Window function suffixes are now properly rendered.
|
|
159
|
+
- to.sql: `$self` comparisons inside aspects are not checked and won't result in an error anymore.
|
|
160
|
+
- to.hdbcds:
|
|
161
|
+
+ Correctly apply the "."-to-"_"-translation algorithm to artifacts that are marked with `@cds.persistence.exists`.
|
|
162
|
+
+ Message with ID `anno-hidden-exists` (former `anno-unstable-hdbcds`) is now
|
|
163
|
+
only issued if the compiler generates a SAP HANA CDS artifact which would hide
|
|
164
|
+
a native database object from being resolved in a SAP HANA CDS `using … as …`.
|
|
165
|
+
- to.cdl: Annotation paths containing special characters such as spaces or `@` are now quoted, e.g. `@![some@annotation]`.
|
|
166
|
+
- compiler: A warning is emitted for elements of views with localized keys as the localized property is ignored for them.
|
|
167
|
+
|
|
10
168
|
## Version 2.11.4 - 2021-12-21
|
|
11
169
|
|
|
12
170
|
### Fixed
|
|
13
171
|
|
|
14
172
|
- CDL parser: in many situations, improve message when people use reserved keywords as identifier
|
|
15
|
-
- Improve error text and error location for
|
|
173
|
+
- Improve error text and error location for ambiguous auto-redirection target
|
|
16
174
|
- to.sql/hdi/hdbcds:
|
|
17
175
|
+ Correctly detect `exists` in projections
|
|
18
176
|
+ Correctly handle elements starting with `$` in the on-condition of associations
|
|
@@ -30,22 +30,22 @@ const fs = require('fs');
|
|
|
30
30
|
const path = require('path');
|
|
31
31
|
|
|
32
32
|
const cliArgs = process.argv.slice(2);
|
|
33
|
-
const
|
|
33
|
+
const filepath = cliArgs[0];
|
|
34
34
|
|
|
35
35
|
if (cliArgs.length !== 1)
|
|
36
36
|
exitError(`Expected exactly one argument, ${cliArgs.length} given`);
|
|
37
37
|
|
|
38
|
-
if (!
|
|
39
|
-
exitError('Expected non-empty
|
|
38
|
+
if (!filepath)
|
|
39
|
+
exitError('Expected non-empty filepath as argument!');
|
|
40
40
|
|
|
41
41
|
// Do not use allow-list approach.
|
|
42
42
|
// There may be CDS files with other extensions than `.cds`.
|
|
43
|
-
if (
|
|
43
|
+
if (filepath.endsWith('.csn') || filepath.endsWith('.json'))
|
|
44
44
|
exitError('Only CDS files can be passed! Found CSN file!');
|
|
45
45
|
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
fs.writeFileSync(
|
|
46
|
+
let sourceStr = fs.readFileSync(filepath, 'utf-8');
|
|
47
|
+
sourceStr = modernizeIdentifierStyle(sourceStr, filepath);
|
|
48
|
+
fs.writeFileSync(filepath, sourceStr);
|
|
49
49
|
process.exit(0); // success
|
|
50
50
|
|
|
51
51
|
// --------------------------------------------------------
|
package/bin/cdsc.js
CHANGED
|
@@ -163,14 +163,6 @@ try {
|
|
|
163
163
|
)
|
|
164
164
|
cmdLine.options.assertIntegrity = cmdLine.options.assertIntegrity === 'true';
|
|
165
165
|
|
|
166
|
-
// remap string values for `constraintsAsAlter` option to boolean
|
|
167
|
-
if (cmdLine.options.constraintsAsAlter &&
|
|
168
|
-
cmdLine.options.constraintsAsAlter === 'true' ||
|
|
169
|
-
cmdLine.options.constraintsAsAlter === 'false'
|
|
170
|
-
)
|
|
171
|
-
cmdLine.options.constraintsAsAlter = cmdLine.options.constraintsAsAlter === 'true';
|
|
172
|
-
|
|
173
|
-
|
|
174
166
|
// Enable all beta-flags if betaMode is set to true
|
|
175
167
|
if (cmdLine.options.betaMode)
|
|
176
168
|
cmdLine.options.beta = availableBetaFlags;
|
|
@@ -227,7 +219,7 @@ function displayUsage(error, helpText, code) {
|
|
|
227
219
|
out.write(`${helpText}\n`);
|
|
228
220
|
if (error) {
|
|
229
221
|
if (error instanceof Array)
|
|
230
|
-
out.write(`${error.map(
|
|
222
|
+
out.write(`${error.map(err => `cdsc: ERROR: ${err}`).join('\n')}\n`);
|
|
231
223
|
else
|
|
232
224
|
out.write(`cdsc: ERROR: ${error}\n`);
|
|
233
225
|
}
|
|
@@ -301,11 +293,11 @@ function executeCommandLine(command, options, args) {
|
|
|
301
293
|
// Return the original model (for chaining)
|
|
302
294
|
function toCsn( model ) {
|
|
303
295
|
if (options.directBackend) {
|
|
304
|
-
displayNamedCsn(model, 'csn'
|
|
296
|
+
displayNamedCsn(model, 'csn');
|
|
305
297
|
}
|
|
306
298
|
else {
|
|
307
299
|
// Result already provided by caller
|
|
308
|
-
displayNamedXsn(model, 'csn'
|
|
300
|
+
displayNamedXsn(model, 'csn');
|
|
309
301
|
}
|
|
310
302
|
return model;
|
|
311
303
|
}
|
|
@@ -316,7 +308,7 @@ function executeCommandLine(command, options, args) {
|
|
|
316
308
|
const csn = options.directBackend ? model : compactModel(model, options);
|
|
317
309
|
|
|
318
310
|
if (options.toHana && options.toHana.csn) {
|
|
319
|
-
displayNamedCsn(for_hdbcds(csn, remapCmdOptions(options, options.toHana)), 'hana_csn'
|
|
311
|
+
displayNamedCsn(for_hdbcds(csn, remapCmdOptions(options, options.toHana)), 'hana_csn');
|
|
320
312
|
}
|
|
321
313
|
else {
|
|
322
314
|
const hanaResult = main.to.hdbcds(csn, remapCmdOptions(options, options.toHana));
|
|
@@ -339,7 +331,7 @@ function executeCommandLine(command, options, args) {
|
|
|
339
331
|
const csn = options.directBackend ? model : compactModel(model, options);
|
|
340
332
|
const odataCsn = main.for.odata(csn, remapCmdOptions(options, options.toOdata));
|
|
341
333
|
if (options.toOdata && options.toOdata.csn) {
|
|
342
|
-
displayNamedCsn(odataCsn, 'odata_csn'
|
|
334
|
+
displayNamedCsn(odataCsn, 'odata_csn');
|
|
343
335
|
}
|
|
344
336
|
else if (options.toOdata && options.toOdata.json) {
|
|
345
337
|
const result = main.to.edm.all(odataCsn, options);
|
|
@@ -392,7 +384,7 @@ function executeCommandLine(command, options, args) {
|
|
|
392
384
|
const csn = options.directBackend ? model : compactModel(model, options);
|
|
393
385
|
if (options.toSql && options.toSql.src === 'hdi') {
|
|
394
386
|
if (options.toSql.csn) {
|
|
395
|
-
displayNamedCsn(for_hdi(csn, remapCmdOptions(options, options.toSql)), 'hdi_csn'
|
|
387
|
+
displayNamedCsn(for_hdi(csn, remapCmdOptions(options, options.toSql)), 'hdi_csn');
|
|
396
388
|
}
|
|
397
389
|
else {
|
|
398
390
|
const hdiResult = main.to.hdi(csn, remapCmdOptions(options, options.toSql));
|
|
@@ -401,7 +393,7 @@ function executeCommandLine(command, options, args) {
|
|
|
401
393
|
}
|
|
402
394
|
}
|
|
403
395
|
else if (options.toSql && options.toSql.csn) {
|
|
404
|
-
displayNamedCsn(for_sql(csn, remapCmdOptions(options, options.toSql)), 'sql_csn'
|
|
396
|
+
displayNamedCsn(for_sql(csn, remapCmdOptions(options, options.toSql)), 'sql_csn');
|
|
405
397
|
}
|
|
406
398
|
else {
|
|
407
399
|
const sqlResult = main.to.sql(csn, remapCmdOptions(options, options.toSql));
|
|
@@ -452,7 +444,7 @@ function executeCommandLine(command, options, args) {
|
|
|
452
444
|
* Print the model's messages to stderr in a human readable way.
|
|
453
445
|
*
|
|
454
446
|
* @param {CSN.Model | XSN.Model} model
|
|
455
|
-
* @param {
|
|
447
|
+
* @param {CompileMessage[]} messages
|
|
456
448
|
*/
|
|
457
449
|
function displayMessages( model, messages = options.messages ) {
|
|
458
450
|
if (!Array.isArray(messages))
|
|
@@ -483,7 +475,6 @@ function executeCommandLine(command, options, args) {
|
|
|
483
475
|
hasAtLeastOneExplanation = hasAtLeastOneExplanation || main.hasMessageExplanation(msg.messageId);
|
|
484
476
|
const name = msg.location && msg.location.file;
|
|
485
477
|
const fullFilePath = name ? path.resolve('', name) : undefined;
|
|
486
|
-
const context = fullFilePath ? sourceLines(fullFilePath) : [];
|
|
487
478
|
log(main.messageStringMultiline(msg, {
|
|
488
479
|
normalizeFilename,
|
|
489
480
|
noMessageId: !options.showMessageId,
|
|
@@ -491,8 +482,12 @@ function executeCommandLine(command, options, args) {
|
|
|
491
482
|
hintExplanation: true,
|
|
492
483
|
color: options.color,
|
|
493
484
|
}));
|
|
494
|
-
if (
|
|
485
|
+
if (fullFilePath && msg.location.col) {
|
|
486
|
+
// A message context only makes sense, if we have at least a medium precision,
|
|
487
|
+
// i.e. line and column for start position.
|
|
488
|
+
const context = sourceLines(fullFilePath);
|
|
495
489
|
log(main.messageContext(context, msg, { color: options.color }));
|
|
490
|
+
}
|
|
496
491
|
log(); // newline
|
|
497
492
|
});
|
|
498
493
|
if (options.showMessageId && hasAtLeastOneExplanation)
|
|
@@ -505,7 +500,7 @@ function executeCommandLine(command, options, args) {
|
|
|
505
500
|
// or display it to stdout if 'options.out' is '-'.
|
|
506
501
|
// Depending on 'options.rawOutput', the model is either compacted to 'name.json' or
|
|
507
502
|
// written in raw form to '<name>_raw.txt'.
|
|
508
|
-
function displayNamedXsn(xsn, name
|
|
503
|
+
function displayNamedXsn(xsn, name) {
|
|
509
504
|
if (options.rawOutput) {
|
|
510
505
|
writeToFileOrDisplay(options.out, `${name}_raw.txt`, util.inspect(reveal(xsn, options.rawOutput), false, null), true);
|
|
511
506
|
}
|
|
@@ -525,9 +520,8 @@ function executeCommandLine(command, options, args) {
|
|
|
525
520
|
/**
|
|
526
521
|
* @param {CSN.Model} csn
|
|
527
522
|
* @param {string} name
|
|
528
|
-
* @param {CSN.Options} options
|
|
529
523
|
*/
|
|
530
|
-
function displayNamedCsn(csn, name
|
|
524
|
+
function displayNamedCsn(csn, name) {
|
|
531
525
|
if (!csn) // only print CSN if it is set.
|
|
532
526
|
return;
|
|
533
527
|
if (options.internalMsg) {
|
|
@@ -558,8 +552,13 @@ function executeCommandLine(command, options, args) {
|
|
|
558
552
|
content = JSON.stringify(content, null, 2);
|
|
559
553
|
|
|
560
554
|
if (dir === '-') {
|
|
561
|
-
if (!omitHeadline)
|
|
562
|
-
|
|
555
|
+
if (!omitHeadline) {
|
|
556
|
+
const sqlTypes = {
|
|
557
|
+
sql: true, hdbconstraint: true, hdbtable: true, hdbview: true,
|
|
558
|
+
};
|
|
559
|
+
const commentStarter = fileName.split('.').pop() in sqlTypes ? '--$' : '//';
|
|
560
|
+
process.stdout.write(`${commentStarter} ------------------- ${fileName} -------------------\n`);
|
|
561
|
+
}
|
|
563
562
|
|
|
564
563
|
process.stdout.write(`${content}\n`);
|
|
565
564
|
if (!omitHeadline)
|
package/bin/cdsse.js
CHANGED
|
@@ -144,8 +144,8 @@ function lint( err, buf ) {
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
function tokensAt( buf,
|
|
148
|
-
const src = `${buf.substring( 0,
|
|
147
|
+
function tokensAt( buf, _offset, col, symbol ) {
|
|
148
|
+
const src = `${buf.substring( 0, _offset )}≠${buf.substring( _offset )}`;
|
|
149
149
|
const et = messageAt( compiler.parseX( src, frel, { messages: [] } ), 'expectedTokens', col ) || [];
|
|
150
150
|
for (const n of et) {
|
|
151
151
|
if (typeof symbol === 'string') {
|
package/doc/CHANGELOG_ARCHIVE.md
CHANGED
|
@@ -1516,7 +1516,7 @@ Changes
|
|
|
1516
1516
|
* Preserve the `key` properties of elements selected in a view (like we do in projections).
|
|
1517
1517
|
* Improve the CSN representation for views.
|
|
1518
1518
|
Represent the `where` and `on` condition of `select`s like other conditions.
|
|
1519
|
-
* Project name in github is now `
|
|
1519
|
+
* Project name in github is now `cap/cds-compiler`.
|
|
1520
1520
|
|
|
1521
1521
|
Features
|
|
1522
1522
|
* Support `select *` in views.
|
package/doc/CHANGELOG_BETA.md
CHANGED
|
@@ -8,17 +8,30 @@ 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 2.
|
|
11
|
+
## Version 2.XX.YY
|
|
12
|
+
|
|
13
|
+
### Removed `assocsWithParams`
|
|
14
|
+
|
|
15
|
+
Instead, of using the beta flag `assocsWithParams`, you can change the severity of the messages
|
|
16
|
+
`def-unexpected-paramview-assoc` and `def-unexpected-calcview-assoc`.
|
|
17
|
+
|
|
18
|
+
## Version 2.12.0 - 2022-01-25
|
|
19
|
+
|
|
20
|
+
### Added `sqlSnippets`
|
|
21
|
+
|
|
22
|
+
- to.sql/hdi/hdbcds: Introduce the annotations `@sql.prepend` and `@sql.append` that allow inserting user-written SQL snippets into the compiler generated content.
|
|
23
|
+
|
|
24
|
+
## Version 2.11.0 - 2021-12-02
|
|
12
25
|
|
|
13
26
|
### Removed `foreignKeyConstraints`
|
|
14
27
|
|
|
15
|
-
## Version 2.10.4
|
|
28
|
+
## Version 2.10.4 - 2021-11-05
|
|
16
29
|
|
|
17
30
|
### Fixed `nestedProjections`
|
|
18
31
|
|
|
19
32
|
- to.sql/hdi/hdbcds: Correctly handle a `*` at the not-first place in the query
|
|
20
33
|
|
|
21
|
-
## Version 2.6.0
|
|
34
|
+
## Version 2.6.0 - 2021-08-23
|
|
22
35
|
|
|
23
36
|
### Removed `pretransformedCSN`
|
|
24
37
|
|
|
@@ -42,7 +55,7 @@ This is now the default - see CHANGELOG entry for 2.6.0
|
|
|
42
55
|
- Composition of one w/o backlink will result in a constraint in
|
|
43
56
|
the entity where the composition is defined
|
|
44
57
|
|
|
45
|
-
## Version 2.4.4
|
|
58
|
+
## Version 2.4.4 - 2021-07-02
|
|
46
59
|
|
|
47
60
|
### Added `nestedProjections`
|
|
48
61
|
|
|
@@ -53,7 +66,7 @@ This is now the default - see CHANGELOG entry for 2.6.0
|
|
|
53
66
|
- _Some checks are missing and will be added! Minor changes might occur._
|
|
54
67
|
- **The SQL backends might not work properly yet if nested projections are used!**
|
|
55
68
|
|
|
56
|
-
## Version 2.4.2
|
|
69
|
+
## Version 2.4.2 - 2021-07-01
|
|
57
70
|
|
|
58
71
|
### Added `keylessManagedAssoc`
|
|
59
72
|
|
|
@@ -65,7 +78,7 @@ This is now the default - see CHANGELOG entry for 2.6.0
|
|
|
65
78
|
Consequently, these associations are not added to the `WITH ASSOCIATIONS` clause or forwarded to HANA CDS.
|
|
66
79
|
Managed Associations without foreign keys must be enabled with `--beta: keylessManagedAssoc`
|
|
67
80
|
|
|
68
|
-
## Version 2.4.0
|
|
81
|
+
## Version 2.4.0 - 2021-06-28
|
|
69
82
|
|
|
70
83
|
### Changed `foreignKeyConstraints`
|
|
71
84
|
|
|
@@ -163,6 +176,12 @@ The association to join transformation treats foreign key accesses with priority
|
|
|
163
176
|
|
|
164
177
|
Unique constraints are now generally available.
|
|
165
178
|
|
|
179
|
+
## Version 1.33.0 - 2020-08-24
|
|
180
|
+
|
|
181
|
+
### Added `hanaAssocRealCardinality`
|
|
182
|
+
|
|
183
|
+
Render JOIN cardinality in native HANA association if provided. If no cardinality has been specified.
|
|
184
|
+
|
|
166
185
|
## Version 1.32.0 - 2020-07-10
|
|
167
186
|
|
|
168
187
|
### Removed `aspectCompositions`
|
|
@@ -11,9 +11,25 @@ Note: `deprecated` features are listed in this ChangeLog just for information.
|
|
|
11
11
|
**When the `deprecated` option is set, the `beta` option is ignored,
|
|
12
12
|
and several new features are not available.**
|
|
13
13
|
|
|
14
|
+
## Version 2.XX.YY - 2022-MM-DD
|
|
15
|
+
|
|
16
|
+
### Added `redirectInSubQueries`
|
|
17
|
+
|
|
18
|
+
When this option is set, we auto-redirect associations and composition also in
|
|
19
|
+
non-main queries, sometimes without rewriting the `keys`/`on` (there will be no
|
|
20
|
+
fix for this).
|
|
21
|
+
|
|
22
|
+
### Added `oldVirtualNotNullPropagation`
|
|
23
|
+
|
|
24
|
+
When this option is set, we do not propagate `notNull` along types.
|
|
25
|
+
Additionally, we propagate `notNull` and `virtual` from a query source element
|
|
26
|
+
to the sub elements of a query entity element, even if the property is not
|
|
27
|
+
propagated to the query entity element itself (like with type references).
|
|
28
|
+
|
|
29
|
+
|
|
14
30
|
## Version 2.2.0
|
|
15
31
|
|
|
16
|
-
|
|
32
|
+
### Added `noScopedRedirections`
|
|
17
33
|
|
|
18
34
|
When this option is set, the definition scope is not taken into account when
|
|
19
35
|
trying to find an implicit redirection target. Setting the following
|
|
@@ -21,18 +37,18 @@ deprecated options also switches off scoped redirections (additionally to their
|
|
|
21
37
|
other effect): `noElementsExpansion`, `generatedEntityNameWithUnderscore`,
|
|
22
38
|
`shortAutoexposed`, `longAutoexposed`, `noInheritedAutoexposeViaComposition`.
|
|
23
39
|
|
|
24
|
-
|
|
40
|
+
### Added `noInheritedAutoexposeViaComposition`
|
|
25
41
|
|
|
26
42
|
When this option is set, only entities directly specified after `Composition of` are
|
|
27
43
|
auto-exposed, not entities used as target via explicit or implicit `redirected to`.
|
|
28
44
|
|
|
29
45
|
## Version 2.0.16
|
|
30
46
|
|
|
31
|
-
|
|
47
|
+
### Added `downgradableErrors`
|
|
32
48
|
|
|
33
49
|
Allow to change the severity of some errors which should stay to be an error.
|
|
34
50
|
|
|
35
|
-
|
|
51
|
+
### Added `shortAutoexposed`
|
|
36
52
|
|
|
37
53
|
When this option is set (and `generatedEntityNameWithUnderscore`), the names of
|
|
38
54
|
autoexposed entities are calculated according to the default compiler v1
|
|
@@ -40,13 +56,13 @@ behavior (without v1 options `dependentAutoexposed` and `longAutoexposed`).
|
|
|
40
56
|
|
|
41
57
|
## Version 2.0.10
|
|
42
58
|
|
|
43
|
-
|
|
59
|
+
### Added `longAutoexposed`
|
|
44
60
|
|
|
45
61
|
When this option is set (and `generatedEntityNameWithUnderscore`),
|
|
46
62
|
the names of autoexposed entities are calculated according to the
|
|
47
63
|
compiler v1 option `longAutoexposed`.
|
|
48
64
|
|
|
49
|
-
|
|
65
|
+
### Added `generatedEntityNameWithUnderscore`
|
|
50
66
|
|
|
51
67
|
Keep using `_` is separator for generated autoexposed entities and for entities
|
|
52
68
|
created for managed compositions. It also disables a definition `A.B.C` if `A`
|
package/doc/NameResolution.md
CHANGED
|
@@ -22,22 +22,27 @@ others might want to [skip the introduction](#design-principles).
|
|
|
22
22
|
|
|
23
23
|
## Table of Contents
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
25
|
+
<!-- toc: start -->
|
|
26
|
+
|
|
27
|
+
1. [Table of Contents](#table-of-contents)
|
|
28
|
+
2. [Introduction](#introduction)
|
|
29
|
+
1. [Background: SQL](#background-sql)
|
|
30
|
+
2. [Background: modern programming languages](#background-modern-programming-languages)
|
|
31
|
+
3. [Design Principles](#design-principles)
|
|
32
|
+
4. [Name Resolution - the Basics](#name-resolution---the-basics)
|
|
33
|
+
1. [Common rules](#common-rules)
|
|
34
|
+
2. [Resolving paths](#resolving-paths)
|
|
35
|
+
3. [Navigation environment](#navigation-environment)
|
|
36
|
+
5. [References to main artifacts](#references-to-main-artifacts)
|
|
37
|
+
6. [Values and references to elements](#values-and-references-to-elements)
|
|
38
|
+
1. [References in queries](#references-in-queries)
|
|
39
|
+
2. [References to sibling elements](#references-to-sibling-elements)
|
|
40
|
+
3. [Other element references](#other-element-references)
|
|
41
|
+
7. [Paths as annotation values](#paths-as-annotation-values)
|
|
42
|
+
8. [Differences to HANA-CDS](#differences-to-hana-cds)
|
|
43
|
+
9. [Summary](#summary)
|
|
44
|
+
|
|
45
|
+
<!-- toc: end -->
|
|
41
46
|
|
|
42
47
|
|
|
43
48
|
## Introduction
|