@sap/cds-compiler 2.11.2 → 2.13.6
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 +175 -2
- package/bin/.eslintrc.json +1 -2
- package/bin/cds_update_identifiers.js +10 -8
- package/bin/cdsc.js +23 -17
- package/bin/cdsse.js +2 -2
- package/bin/cdsv2m.js +3 -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 +32 -79
- package/lib/api/options.js +3 -2
- package/lib/api/validate.js +2 -1
- package/lib/backends.js +16 -26
- package/lib/base/dictionaries.js +0 -8
- package/lib/base/error.js +26 -0
- package/lib/base/keywords.js +10 -19
- package/lib/base/location.js +9 -4
- package/lib/base/message-registry.js +75 -9
- package/lib/base/messages.js +31 -35
- 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/emptyOrOnlyVirtual.js +2 -2
- 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/unknownMagic.js +1 -1
- package/lib/checks/validator.js +12 -7
- package/lib/compiler/assert-consistency.js +12 -8
- package/lib/compiler/base.js +0 -1
- package/lib/compiler/builtins.js +42 -21
- 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 +46 -39
- 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 +100 -65
- package/lib/compiler/tweak-assocs.js +529 -0
- package/lib/compiler/utils.js +215 -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 +189 -71
- package/lib/language/antlrParser.js +3 -3
- package/lib/language/docCommentParser.js +3 -3
- package/lib/language/errorStrategy.js +26 -8
- package/lib/language/genericAntlrParser.js +144 -53
- package/lib/language/language.g4 +424 -200
- package/lib/language/multiLineStringParser.js +536 -0
- package/lib/main.d.ts +550 -61
- package/lib/main.js +38 -11
- package/lib/model/api.js +3 -1
- package/lib/model/csnRefs.js +322 -198
- package/lib/model/csnUtils.js +226 -370
- package/lib/model/enrichCsn.js +124 -69
- package/lib/model/revealInternalProperties.js +29 -7
- package/lib/model/sortViews.js +10 -2
- package/lib/modelCompare/compare.js +17 -12
- package/lib/optionProcessor.js +8 -3
- package/lib/render/.eslintrc.json +1 -2
- 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 +203 -122
- package/lib/render/toRename.js +7 -10
- package/lib/render/toSql.js +161 -82
- 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 +212 -0
- 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 +556 -106
- package/lib/transform/db/groupByOrderBy.js +3 -1
- package/lib/transform/db/temporal.js +236 -0
- package/lib/transform/db/transformExists.js +103 -28
- package/lib/transform/db/views.js +92 -44
- 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 +98 -783
- 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 +13 -30
- 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 +8 -3
- 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 -2349
- package/lib/compiler/resolver.js +0 -2922
- package/lib/transform/db/helpers.js +0 -58
- package/lib/transform/universalCsnEnricher.js +0 -67
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,179 @@
|
|
|
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.6 - 2022-25-03
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- to.hdbcds/hdi/sql: Correctly handle `localized` in conjunction with `@cds.persistence.exists`
|
|
15
|
+
|
|
16
|
+
## Version 2.13.4 - 2022-22-03
|
|
17
|
+
|
|
18
|
+
No changes compared to Version 2.13.0; fixes latest NPM tag
|
|
19
|
+
|
|
20
|
+
## Version 2.13.2 - 2022-22-03
|
|
21
|
+
|
|
22
|
+
No changes compared to Version 2.13.0; fixes latest NPM tag
|
|
23
|
+
|
|
24
|
+
## Version 2.13.0 - 2022-22-03
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- CDL syntax:
|
|
29
|
+
+ Allow to `extend E:elem` and `annotate E:elem` instead of having to write deeply nested statements.
|
|
30
|
+
+ Enable `default` values as part of scalar type definitions.
|
|
31
|
+
+ The following `extend` syntax variants are now possible:
|
|
32
|
+
```cds
|
|
33
|
+
extend … with elements { … }
|
|
34
|
+
extend … with definitions { … }
|
|
35
|
+
extend … with columns { … }
|
|
36
|
+
extend … with enum { … }
|
|
37
|
+
extend … with actions { … }
|
|
38
|
+
```
|
|
39
|
+
This syntax expresses _how_ an artifact is extended instead of _what_ is extended.
|
|
40
|
+
+ Using `ORDER BY` in generic functions such as SAP HANA's `first_value` is now possible.
|
|
41
|
+
- Make API function `compileSources` accept CSN objects as file content
|
|
42
|
+
- to.edm(x): Annotate view parameters with `@sap.parameter: mandatory` (V2) and `@Common.FieldControl: #Mandatory` (V4).
|
|
43
|
+
- to.sql/hdi/hdbcds: Introduce the annotations `@sql.prepend` and `@sql.append` that allow inserting user-written SQL
|
|
44
|
+
snippets into the compiler generated content. Changes in annotations `@sql.prepend` and `@sql.append` are now reflected
|
|
45
|
+
in the output of `to.hdi.migration`. This enables CDS Build to produce `.hdbmigrationtable` files translating such model
|
|
46
|
+
changes into schema changes.
|
|
47
|
+
- API: Lists of keywords for various backends are available as `to.<backend>[.<config>].keywords`, e.g. `to.sql.sqlite.keywords`.
|
|
48
|
+
- for.odata/to.edm(x): The draft composition hull is now also taking into account compositions in subelements.
|
|
49
|
+
|
|
50
|
+
### Changed
|
|
51
|
+
|
|
52
|
+
- In query entities inside services, only auto-redirect associations and compositions
|
|
53
|
+
in the main query of the entity.
|
|
54
|
+
- An element now inherits the property `notNull` from its query source (as
|
|
55
|
+
before) or its type (like it does for most other properties);
|
|
56
|
+
`notNull` is then not further propagated to its sub elements anymore.
|
|
57
|
+
- A structure element inherits the property `virtual` from its query source (as
|
|
58
|
+
before), but does not further propagate `virtual` to its sub elements
|
|
59
|
+
(semantically of course, but the CSN is not cluttered with it);
|
|
60
|
+
there is a new warning if a previously `virtual` query entity
|
|
61
|
+
element is now considered to be non-virtual.
|
|
62
|
+
- Do not propagate annotation value `null`.
|
|
63
|
+
The value `null` of an annotation (and `doc`) is used to stop the inheritance
|
|
64
|
+
of an annotation value. This means than other than that, a value `null` should
|
|
65
|
+
not be handled differently to not having set that annotation.
|
|
66
|
+
- In the effective CSN, the structure type is only expanded if something has changed
|
|
67
|
+
for associations: the `target` (`keys` does not change if the `target` does not change)
|
|
68
|
+
unmanaged associations as sub elements are not supported anyway.
|
|
69
|
+
- In the effective CSN, “simple” type properties like `length`, `precision`,
|
|
70
|
+
`scale` and `srid` are propagated even for a propagation via type.
|
|
71
|
+
- Update OData Vocabularies: 'Capabilities', 'Common', 'Core', 'UI'.
|
|
72
|
+
- to.sql:
|
|
73
|
+
+ For SQL dialect `hana` referential constraints are now appended
|
|
74
|
+
as `ALTER TABLE ADD CONSTRAINT` clause to the end of `schema.sql`.
|
|
75
|
+
With option `constraintsInCreateTable` constraints are rendered into the
|
|
76
|
+
`CREATE TABLE` statement.
|
|
77
|
+
+ Referential constraint names are now prefixed with `c__`.
|
|
78
|
+
|
|
79
|
+
### Fixed
|
|
80
|
+
|
|
81
|
+
- Properly resolve references inside anonymous aspects:
|
|
82
|
+
+ references starting with `$self.` made the compiler dump.
|
|
83
|
+
+ a simple `$self` did not always work as expected (it represents the entity created via the anonymous aspect).
|
|
84
|
+
+ other references inside deeply nested anonymous aspects induced a compilation error.
|
|
85
|
+
- compiler: `()` inside `ORDER BY` clause was not correctly set.
|
|
86
|
+
- parse.cdl: References in `ORDER BY` and filters are now correctly resolved.
|
|
87
|
+
- Issue error when trying to introduce managed compositions of aspects in `mixin`s
|
|
88
|
+
- Issue error in all cases for type references to unmanaged associations.
|
|
89
|
+
- Avoid dump when extending an illegal definition with a name starting with `cds.`.
|
|
90
|
+
- to.sql/to.cdl/to.hdbcds/to.hdi: Render `cast()` inside `ORDER BY`, `GROUP BY` and `HAVING` properly.
|
|
91
|
+
- to.sql/hdi/hdbcds:
|
|
92
|
+
+ `$self` was incorrectly treated as a structured path step.
|
|
93
|
+
+ Correctly handle table alias in on-condition of mixin in `exists` expansion.
|
|
94
|
+
+ Correctly handle table `$self` references to aliased fields in on-condition of mixin association
|
|
95
|
+
during `exists` expansion.
|
|
96
|
+
- to.edm: Don't escape `&` as `&`.
|
|
97
|
+
- to.edmx: Escaping compliant to XML specification:
|
|
98
|
+
+ `&` and `<` are always escaped.
|
|
99
|
+
+ `>` is not escaped, unless it appears in text values as `]]>`.
|
|
100
|
+
+ `"` is escaped in attribute values only.
|
|
101
|
+
+ Control characters are always escaped.
|
|
102
|
+
- Ellipsis (`...`) in annotations in different layers but without base annotation now produces an error.
|
|
103
|
+
The old but incorrect behavior can be re-enabled with option `anno-unexpected-ellipsis-layers`.
|
|
104
|
+
|
|
105
|
+
## Version 2.12.0 - 2022-01-25
|
|
106
|
+
|
|
107
|
+
### Added
|
|
108
|
+
|
|
109
|
+
- CDL parser: You can now use multiline string literals and text blocks.
|
|
110
|
+
Use backticks (\`) for string literals that can span multiple lines and can use JavaScript-like escape
|
|
111
|
+
sequences such as `\u{0020}`. You can also use three backticks (\`\`\`) for strings (a.k.a. text blocks)
|
|
112
|
+
which are automatically indentation-stripped and can have an optional language identifier that is used
|
|
113
|
+
for syntax highlighting, similar to markdown. In difference to the former, text blocks require the
|
|
114
|
+
opening and closing backticks to be on separate lines.
|
|
115
|
+
Example:
|
|
116
|
+
````
|
|
117
|
+
@annotation: `Multi
|
|
118
|
+
line\u{0020}strings`
|
|
119
|
+
|
|
120
|
+
@textblock: ```xml
|
|
121
|
+
<summary>
|
|
122
|
+
<detail>The root tag has no indentation in this example</detail>
|
|
123
|
+
</summary>
|
|
124
|
+
```
|
|
125
|
+
````
|
|
126
|
+
|
|
127
|
+
- Enhance the ellipsis operator `...` for array annotations by an `up to ‹val›`:
|
|
128
|
+
only values in the array of the base annotation up to (including) the first match
|
|
129
|
+
of the specified `‹val›` are included at the specified place in the final array value.
|
|
130
|
+
An array annotation can have more than on `... up to ‹val›` items and must also
|
|
131
|
+
have a pure `...` item after them.
|
|
132
|
+
A structured `‹val›` matches if the array item is also a structure and all property
|
|
133
|
+
values in `‹val›` are equal to the corresponding property value in the array value;
|
|
134
|
+
it is not necessary to specify all properties of the array value items in `‹val›`.
|
|
135
|
+
Example
|
|
136
|
+
```
|
|
137
|
+
@Anno: [{name: one, val: 1}, {name: two, val: 2}, {name: four, val: 4}]
|
|
138
|
+
type T: Integer;
|
|
139
|
+
@Anno: [{name: zero, val: 0}, ... up to {name: two}, {name: three, val: 3}, ...]
|
|
140
|
+
annotate T;
|
|
141
|
+
```
|
|
142
|
+
- for.odata: Support `@cds.on {update|insert}` as replacement for deprecated `@odata.on { update|insert }` to
|
|
143
|
+
set `@Core.Computed`.
|
|
144
|
+
|
|
145
|
+
### Changed
|
|
146
|
+
|
|
147
|
+
- Update OData Vocabularies 'Aggregation', 'Capabilities', 'Common', 'Core', PersonalData, 'Session', 'UI'
|
|
148
|
+
|
|
149
|
+
### Fixed
|
|
150
|
+
|
|
151
|
+
- to.sql/hdi/hdbcds: With `exists`, ensure that the precedence of the existing association-on-conditions and where-conditions is kept by adding braces.
|
|
152
|
+
- to.sql/hdi: Window function suffixes are now properly rendered.
|
|
153
|
+
- to.sql: `$self` comparisons inside aspects are not checked and won't result in an error anymore.
|
|
154
|
+
- to.hdbcds:
|
|
155
|
+
+ Correctly apply the "."-to-"_"-translation algorithm to artifacts that are marked with `@cds.persistence.exists`.
|
|
156
|
+
+ Message with ID `anno-hidden-exists` (former `anno-unstable-hdbcds`) is now
|
|
157
|
+
only issued if the compiler generates a SAP HANA CDS artifact which would hide
|
|
158
|
+
a native database object from being resolved in a SAP HANA CDS `using … as …`.
|
|
159
|
+
- to.cdl: Annotation paths containing special characters such as spaces or `@` are now quoted, e.g. `@![some@annotation]`.
|
|
160
|
+
- compiler: A warning is emitted for elements of views with localized keys as the localized property is ignored for them.
|
|
161
|
+
|
|
162
|
+
## Version 2.11.4 - 2021-12-21
|
|
163
|
+
|
|
164
|
+
### Fixed
|
|
165
|
+
|
|
166
|
+
- CDL parser: in many situations, improve message when people use reserved keywords as identifier
|
|
167
|
+
- Improve error text and error location for ambiguous auto-redirection target
|
|
168
|
+
- to.sql/hdi/hdbcds:
|
|
169
|
+
+ Correctly detect `exists` in projections
|
|
170
|
+
+ Correctly handle elements starting with `$` in the on-condition of associations
|
|
171
|
+
+ Correctly handle sub queries in an entity defined with `projection on`
|
|
172
|
+
+ Correctly handle associations in sub queries in a `from` of a sub query
|
|
173
|
+
+ foreign key constraints: respect @assert.integrity: false for compositions
|
|
174
|
+
- to.hdbcds: Correctly quote elements named `$self` and `$projection`
|
|
175
|
+
- to.cdl: `when` was added to the keyword list for smart quoting
|
|
176
|
+
- Compiler support for code completion for `$user` and `$session` now respect user
|
|
177
|
+
provided variables in `options.variableReplacements`.
|
|
178
|
+
- API: `deduplicateMessages()` no longer removes messages for `duplicate` artifact/annotation errors.
|
|
179
|
+
Prior to this version, only one of the duplicated artifacts had a message, leaving the user to
|
|
180
|
+
guess where the other duplicates were.
|
|
181
|
+
|
|
182
|
+
|
|
10
183
|
## Version 2.11.2 - 2021-12-06
|
|
11
184
|
|
|
12
185
|
### Fixed
|
|
@@ -25,8 +198,8 @@ The compiler behavior concerning `beta` features can change at any time without
|
|
|
25
198
|
if it can't be assigned to an artifact. For example for two subsequent doc-comments, the first doc-comment
|
|
26
199
|
is ignored. To suppress these info messages, explicitly set option `docComment` to `false`.
|
|
27
200
|
- `cdsc`:
|
|
28
|
-
|
|
29
|
-
|
|
201
|
+
+ `cdsc explain list` can now be used to get a list of message IDs with explanation texts.
|
|
202
|
+
+ `cdsc` now respects the environment variable `NO_COLOR`. If set, no ANSI escape codes will be used.
|
|
30
203
|
Can be overwritten by `cdsc --color always`.
|
|
31
204
|
- to.sql/hdi: Support SQL Window Functions
|
|
32
205
|
- to.sql/hdi/hdbcds:
|
package/bin/.eslintrc.json
CHANGED
|
@@ -24,37 +24,39 @@
|
|
|
24
24
|
'use strict';
|
|
25
25
|
|
|
26
26
|
const parseLanguage = require('../lib/language/antlrParser');
|
|
27
|
+
const { createMessageFunctions } = require('../lib/base/messages');
|
|
27
28
|
|
|
28
29
|
const fs = require('fs');
|
|
29
30
|
const path = require('path');
|
|
30
31
|
|
|
31
32
|
const cliArgs = process.argv.slice(2);
|
|
32
|
-
const
|
|
33
|
+
const filepath = cliArgs[0];
|
|
33
34
|
|
|
34
35
|
if (cliArgs.length !== 1)
|
|
35
36
|
exitError(`Expected exactly one argument, ${cliArgs.length} given`);
|
|
36
37
|
|
|
37
|
-
if (!
|
|
38
|
-
exitError('Expected non-empty
|
|
38
|
+
if (!filepath)
|
|
39
|
+
exitError('Expected non-empty filepath as argument!');
|
|
39
40
|
|
|
40
41
|
// Do not use allow-list approach.
|
|
41
42
|
// There may be CDS files with other extensions than `.cds`.
|
|
42
|
-
if (
|
|
43
|
+
if (filepath.endsWith('.csn') || filepath.endsWith('.json'))
|
|
43
44
|
exitError('Only CDS files can be passed! Found CSN file!');
|
|
44
45
|
|
|
45
|
-
let
|
|
46
|
-
|
|
47
|
-
fs.writeFileSync(
|
|
46
|
+
let sourceStr = fs.readFileSync(filepath, 'utf-8');
|
|
47
|
+
sourceStr = modernizeIdentifierStyle(sourceStr, filepath);
|
|
48
|
+
fs.writeFileSync(filepath, sourceStr);
|
|
48
49
|
process.exit(0); // success
|
|
49
50
|
|
|
50
51
|
// --------------------------------------------------------
|
|
51
52
|
|
|
52
53
|
function modernizeIdentifierStyle(source, filename) {
|
|
53
54
|
const options = { messages: [], attachTokens: true };
|
|
55
|
+
const messageFunctions = createMessageFunctions( options, 'parse', null );
|
|
54
56
|
|
|
55
57
|
// parseLanguage does not throw on CompilationError, so
|
|
56
58
|
// we do not need a try...catch block.
|
|
57
|
-
const ast = parseLanguage(source, filename, options);
|
|
59
|
+
const ast = parseLanguage(source, filename, options, messageFunctions);
|
|
58
60
|
|
|
59
61
|
// To avoid spam, only report errors.
|
|
60
62
|
// Users should use the compiler to get all messages.
|
package/bin/cdsc.js
CHANGED
|
@@ -161,8 +161,7 @@ try {
|
|
|
161
161
|
cmdLine.options.assertIntegrity === 'true' ||
|
|
162
162
|
cmdLine.options.assertIntegrity === 'false'
|
|
163
163
|
)
|
|
164
|
-
cmdLine.options.assertIntegrity =
|
|
165
|
-
|
|
164
|
+
cmdLine.options.assertIntegrity = cmdLine.options.assertIntegrity === 'true';
|
|
166
165
|
|
|
167
166
|
// Enable all beta-flags if betaMode is set to true
|
|
168
167
|
if (cmdLine.options.betaMode)
|
|
@@ -220,7 +219,7 @@ function displayUsage(error, helpText, code) {
|
|
|
220
219
|
out.write(`${helpText}\n`);
|
|
221
220
|
if (error) {
|
|
222
221
|
if (error instanceof Array)
|
|
223
|
-
out.write(`${error.map(
|
|
222
|
+
out.write(`${error.map(err => `cdsc: ERROR: ${err}`).join('\n')}\n`);
|
|
224
223
|
else
|
|
225
224
|
out.write(`cdsc: ERROR: ${error}\n`);
|
|
226
225
|
}
|
|
@@ -294,11 +293,11 @@ function executeCommandLine(command, options, args) {
|
|
|
294
293
|
// Return the original model (for chaining)
|
|
295
294
|
function toCsn( model ) {
|
|
296
295
|
if (options.directBackend) {
|
|
297
|
-
displayNamedCsn(model, 'csn'
|
|
296
|
+
displayNamedCsn(model, 'csn');
|
|
298
297
|
}
|
|
299
298
|
else {
|
|
300
299
|
// Result already provided by caller
|
|
301
|
-
displayNamedXsn(model, 'csn'
|
|
300
|
+
displayNamedXsn(model, 'csn');
|
|
302
301
|
}
|
|
303
302
|
return model;
|
|
304
303
|
}
|
|
@@ -309,7 +308,7 @@ function executeCommandLine(command, options, args) {
|
|
|
309
308
|
const csn = options.directBackend ? model : compactModel(model, options);
|
|
310
309
|
|
|
311
310
|
if (options.toHana && options.toHana.csn) {
|
|
312
|
-
displayNamedCsn(for_hdbcds(csn, remapCmdOptions(options, options.toHana)), 'hana_csn'
|
|
311
|
+
displayNamedCsn(for_hdbcds(csn, remapCmdOptions(options, options.toHana)), 'hana_csn');
|
|
313
312
|
}
|
|
314
313
|
else {
|
|
315
314
|
const hanaResult = main.to.hdbcds(csn, remapCmdOptions(options, options.toHana));
|
|
@@ -332,7 +331,7 @@ function executeCommandLine(command, options, args) {
|
|
|
332
331
|
const csn = options.directBackend ? model : compactModel(model, options);
|
|
333
332
|
const odataCsn = main.for.odata(csn, remapCmdOptions(options, options.toOdata));
|
|
334
333
|
if (options.toOdata && options.toOdata.csn) {
|
|
335
|
-
displayNamedCsn(odataCsn, 'odata_csn'
|
|
334
|
+
displayNamedCsn(odataCsn, 'odata_csn');
|
|
336
335
|
}
|
|
337
336
|
else if (options.toOdata && options.toOdata.json) {
|
|
338
337
|
const result = main.to.edm.all(odataCsn, options);
|
|
@@ -385,7 +384,7 @@ function executeCommandLine(command, options, args) {
|
|
|
385
384
|
const csn = options.directBackend ? model : compactModel(model, options);
|
|
386
385
|
if (options.toSql && options.toSql.src === 'hdi') {
|
|
387
386
|
if (options.toSql.csn) {
|
|
388
|
-
displayNamedCsn(for_hdi(csn, remapCmdOptions(options, options.toSql)), 'hdi_csn'
|
|
387
|
+
displayNamedCsn(for_hdi(csn, remapCmdOptions(options, options.toSql)), 'hdi_csn');
|
|
389
388
|
}
|
|
390
389
|
else {
|
|
391
390
|
const hdiResult = main.to.hdi(csn, remapCmdOptions(options, options.toSql));
|
|
@@ -394,7 +393,7 @@ function executeCommandLine(command, options, args) {
|
|
|
394
393
|
}
|
|
395
394
|
}
|
|
396
395
|
else if (options.toSql && options.toSql.csn) {
|
|
397
|
-
displayNamedCsn(for_sql(csn, remapCmdOptions(options, options.toSql)), 'sql_csn'
|
|
396
|
+
displayNamedCsn(for_sql(csn, remapCmdOptions(options, options.toSql)), 'sql_csn');
|
|
398
397
|
}
|
|
399
398
|
else {
|
|
400
399
|
const sqlResult = main.to.sql(csn, remapCmdOptions(options, options.toSql));
|
|
@@ -445,7 +444,7 @@ function executeCommandLine(command, options, args) {
|
|
|
445
444
|
* Print the model's messages to stderr in a human readable way.
|
|
446
445
|
*
|
|
447
446
|
* @param {CSN.Model | XSN.Model} model
|
|
448
|
-
* @param {
|
|
447
|
+
* @param {CompileMessage[]} messages
|
|
449
448
|
*/
|
|
450
449
|
function displayMessages( model, messages = options.messages ) {
|
|
451
450
|
if (!Array.isArray(messages))
|
|
@@ -476,7 +475,6 @@ function executeCommandLine(command, options, args) {
|
|
|
476
475
|
hasAtLeastOneExplanation = hasAtLeastOneExplanation || main.hasMessageExplanation(msg.messageId);
|
|
477
476
|
const name = msg.location && msg.location.file;
|
|
478
477
|
const fullFilePath = name ? path.resolve('', name) : undefined;
|
|
479
|
-
const context = fullFilePath ? sourceLines(fullFilePath) : [];
|
|
480
478
|
log(main.messageStringMultiline(msg, {
|
|
481
479
|
normalizeFilename,
|
|
482
480
|
noMessageId: !options.showMessageId,
|
|
@@ -484,8 +482,12 @@ function executeCommandLine(command, options, args) {
|
|
|
484
482
|
hintExplanation: true,
|
|
485
483
|
color: options.color,
|
|
486
484
|
}));
|
|
487
|
-
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);
|
|
488
489
|
log(main.messageContext(context, msg, { color: options.color }));
|
|
490
|
+
}
|
|
489
491
|
log(); // newline
|
|
490
492
|
});
|
|
491
493
|
if (options.showMessageId && hasAtLeastOneExplanation)
|
|
@@ -498,7 +500,7 @@ function executeCommandLine(command, options, args) {
|
|
|
498
500
|
// or display it to stdout if 'options.out' is '-'.
|
|
499
501
|
// Depending on 'options.rawOutput', the model is either compacted to 'name.json' or
|
|
500
502
|
// written in raw form to '<name>_raw.txt'.
|
|
501
|
-
function displayNamedXsn(xsn, name
|
|
503
|
+
function displayNamedXsn(xsn, name) {
|
|
502
504
|
if (options.rawOutput) {
|
|
503
505
|
writeToFileOrDisplay(options.out, `${name}_raw.txt`, util.inspect(reveal(xsn, options.rawOutput), false, null), true);
|
|
504
506
|
}
|
|
@@ -518,9 +520,8 @@ function executeCommandLine(command, options, args) {
|
|
|
518
520
|
/**
|
|
519
521
|
* @param {CSN.Model} csn
|
|
520
522
|
* @param {string} name
|
|
521
|
-
* @param {CSN.Options} options
|
|
522
523
|
*/
|
|
523
|
-
function displayNamedCsn(csn, name
|
|
524
|
+
function displayNamedCsn(csn, name) {
|
|
524
525
|
if (!csn) // only print CSN if it is set.
|
|
525
526
|
return;
|
|
526
527
|
if (options.internalMsg) {
|
|
@@ -551,8 +552,13 @@ function executeCommandLine(command, options, args) {
|
|
|
551
552
|
content = JSON.stringify(content, null, 2);
|
|
552
553
|
|
|
553
554
|
if (dir === '-') {
|
|
554
|
-
if (!omitHeadline)
|
|
555
|
-
|
|
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
|
+
}
|
|
556
562
|
|
|
557
563
|
process.stdout.write(`${content}\n`);
|
|
558
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/bin/cdsv2m.js
CHANGED
|
@@ -34,10 +34,11 @@ function usage( err ) {
|
|
|
34
34
|
function ria() {
|
|
35
35
|
const annotates = Object.create( null );
|
|
36
36
|
const msgs = options.messages.filter( m => m.messageId === 'redirected-implicitly-ambiguous' );
|
|
37
|
-
//
|
|
37
|
+
// 'Choose via $(ANNO) one of $(SORTED_ARTS) as redirection target for $(TARGET) in … $(ART) otherwise'
|
|
38
|
+
// NOTE: regex match on message text not for productive code!
|
|
38
39
|
for (const msgObj of msgs) {
|
|
39
40
|
const matches = msgObj.message.match( /["“][^"”]+["”]/g );
|
|
40
|
-
matches.slice(2).forEach( (name) => {
|
|
41
|
+
matches.slice( 1, -2 ).forEach( (name) => {
|
|
41
42
|
annotates[name.slice( 1, -1 )] = true;
|
|
42
43
|
} );
|
|
43
44
|
}
|
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
|