@sap/cds-compiler 4.0.2 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +200 -5
- package/bin/cdsc.js +18 -15
- package/doc/CHANGELOG_BETA.md +16 -0
- package/doc/CHANGELOG_DEPRECATED.md +15 -0
- package/lib/api/main.js +33 -13
- package/lib/api/options.js +2 -2
- package/lib/api/validate.js +25 -25
- package/lib/base/location.js +6 -7
- package/lib/base/message-registry.js +123 -42
- package/lib/base/messages.js +18 -10
- package/lib/base/model.js +43 -10
- package/lib/checks/defaultValues.js +6 -6
- package/lib/checks/elements.js +11 -10
- package/lib/checks/foreignKeys.js +0 -5
- package/lib/checks/manyNavigations.js +33 -0
- package/lib/checks/onConditions.js +22 -14
- package/lib/checks/queryNoDbArtifacts.js +132 -73
- package/lib/checks/selectItems.js +4 -55
- package/lib/checks/sql-snippets.js +15 -4
- package/lib/checks/types.js +3 -3
- package/lib/checks/utils.js +4 -3
- package/lib/checks/validator.js +3 -1
- package/lib/compiler/.eslintrc.json +2 -1
- package/lib/compiler/assert-consistency.js +71 -40
- package/lib/compiler/base.js +7 -2
- package/lib/compiler/builtins.js +40 -41
- package/lib/compiler/checks.js +415 -367
- package/lib/compiler/classes.js +62 -0
- package/lib/compiler/cycle-detector.js +9 -9
- package/lib/compiler/define.js +124 -90
- package/lib/compiler/extend.js +115 -88
- package/lib/compiler/finalize-parse-cdl.js +26 -25
- package/lib/compiler/generate.js +57 -49
- package/lib/compiler/index.js +56 -56
- package/lib/compiler/kick-start.js +10 -7
- package/lib/compiler/moduleLayers.js +1 -1
- package/lib/compiler/populate.js +180 -144
- package/lib/compiler/propagator.js +10 -9
- package/lib/compiler/resolve.js +321 -246
- package/lib/compiler/shared.js +812 -433
- package/lib/compiler/tweak-assocs.js +114 -50
- package/lib/compiler/utils.js +241 -46
- package/lib/edm/.eslintrc.json +40 -1
- package/lib/edm/annotations/genericTranslation.js +721 -707
- package/lib/edm/annotations/preprocessAnnotations.js +88 -77
- package/lib/edm/csn2edm.js +389 -378
- package/lib/edm/edm.js +679 -770
- package/lib/edm/edmAnnoPreprocessor.js +132 -146
- package/lib/edm/edmInboundChecks.js +29 -27
- package/lib/edm/edmPreprocessor.js +689 -648
- package/lib/edm/edmUtils.js +279 -300
- package/lib/gen/Dictionary.json +34 -10
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +1 -1
- package/lib/gen/languageParser.js +2857 -2856
- package/lib/json/from-csn.js +77 -51
- package/lib/json/to-csn.js +15 -15
- package/lib/language/antlrParser.js +2 -1
- package/lib/language/genericAntlrParser.js +52 -43
- package/lib/language/language.g4 +61 -64
- package/lib/language/multiLineStringParser.js +2 -0
- package/lib/main.d.ts +65 -0
- package/lib/model/csnRefs.js +37 -19
- package/lib/model/csnUtils.js +51 -18
- package/lib/model/revealInternalProperties.js +30 -22
- package/lib/modelCompare/compare.js +149 -41
- package/lib/modelCompare/utils/filter.js +55 -25
- package/lib/optionProcessor.js +21 -9
- package/lib/render/manageConstraints.js +20 -17
- package/lib/render/toCdl.js +63 -23
- package/lib/render/toHdbcds.js +2 -2
- package/lib/render/toRename.js +4 -9
- package/lib/render/toSql.js +82 -35
- package/lib/render/utils/common.js +11 -9
- package/lib/render/utils/unique.js +52 -0
- package/lib/transform/db/applyTransformations.js +62 -21
- package/lib/transform/db/assertUnique.js +7 -8
- package/lib/transform/db/associations.js +2 -2
- package/lib/transform/db/cdsPersistence.js +9 -9
- package/lib/transform/db/constraints.js +47 -17
- package/lib/transform/db/expansion.js +138 -68
- package/lib/transform/db/flattening.js +98 -30
- package/lib/transform/db/rewriteCalculatedElements.js +20 -14
- package/lib/transform/db/temporal.js +1 -1
- package/lib/transform/db/transformExists.js +8 -7
- package/lib/transform/db/views.js +73 -33
- package/lib/transform/draft/db.js +11 -9
- package/lib/transform/draft/odata.js +1 -1
- package/lib/transform/{forOdataNew.js → forOdata.js} +10 -7
- package/lib/transform/forRelationalDB.js +148 -136
- package/lib/transform/localized.js +92 -54
- package/lib/transform/odata/toFinalBaseType.js +3 -3
- package/lib/transform/{transformUtilsNew.js → transformUtils.js} +13 -111
- package/lib/transform/translateAssocsToJoins.js +14 -28
- package/lib/utils/file.js +7 -7
- package/lib/utils/moduleResolve.js +210 -121
- package/lib/utils/objectUtils.js +1 -1
- package/package.json +5 -5
- package/share/messages/check-proper-type-of.md +1 -1
- package/share/messages/{check-proper-type.md → def-missing-type.md} +3 -5
- package/share/messages/message-explanations.json +1 -1
|
@@ -33,7 +33,7 @@ function kickStart( model ) {
|
|
|
33
33
|
const art = model.definitions[name];
|
|
34
34
|
if (art._parent === undefined)
|
|
35
35
|
return; // nothing to do for builtins and redefinitions
|
|
36
|
-
if (art.query && art._ancestors === undefined)
|
|
36
|
+
if (art.query && art._ancestors === undefined && art.kind === 'entity')
|
|
37
37
|
setProjectionAncestors( art );
|
|
38
38
|
|
|
39
39
|
let parent = art._parent;
|
|
@@ -44,7 +44,7 @@ function kickStart( model ) {
|
|
|
44
44
|
if (!parent || !service)
|
|
45
45
|
return;
|
|
46
46
|
// To be removed when nested services are allowed
|
|
47
|
-
if (!isBetaEnabled(options, 'nestedServices') && art.kind === 'service') {
|
|
47
|
+
if (!isBetaEnabled( options, 'nestedServices' ) && art.kind === 'service') {
|
|
48
48
|
while (parent.kind !== 'service')
|
|
49
49
|
parent = parent._parent;
|
|
50
50
|
message( 'service-nested-service', [ art.name.location, art ], { art: parent },
|
|
@@ -66,15 +66,16 @@ function kickStart( model ) {
|
|
|
66
66
|
// TODO: do not do implicit redirection across services, i.e. Service2.E is
|
|
67
67
|
// no redirection target for E if Service2.E = projection on Service1.E and
|
|
68
68
|
// Service1.E = projection on E
|
|
69
|
+
|
|
70
|
+
// Remark: _ancestors are also set with includes, and there also for aspects,
|
|
71
|
+
// types and events.
|
|
69
72
|
const chain = [];
|
|
70
73
|
const autoexposed = annotationVal( art['@cds.autoexposed'] );
|
|
71
|
-
const preferredRedirectionTarget = annotationVal( art['@cds.redirection.target'] );
|
|
72
74
|
// no need to set preferredRedirectionTarget in the while loop as we would
|
|
73
75
|
// use the projection having @cds.redirection.target anyhow instead of
|
|
74
76
|
// `art` anyway (if we do the no-x-service-implicit-redirection TODO above)
|
|
75
77
|
while (art?.query?.from?.path && // direct select with one source
|
|
76
|
-
art._ancestors !== 0
|
|
77
|
-
(preferredRedirectionTarget || !annotationIsFalse( art['@cds.redirection.target'] ) )) {
|
|
78
|
+
art._ancestors !== 0) { // prevent inf-loop
|
|
78
79
|
chain.push( art );
|
|
79
80
|
setLink( art, '_ancestors', 0 ); // avoid infloop with cyclic from
|
|
80
81
|
const name = resolveUncheckedPath( art.query.from, 'from', art );
|
|
@@ -109,10 +110,10 @@ function kickStart( model ) {
|
|
|
109
110
|
return;
|
|
110
111
|
|
|
111
112
|
function expose( ancestor ) {
|
|
112
|
-
if (ancestor._service === service)
|
|
113
|
+
if (ancestor._service === service || annotationIsFalse( art['@cds.redirection.target'] ))
|
|
113
114
|
return;
|
|
114
115
|
const desc = ancestor._descendants ||
|
|
115
|
-
setLink( ancestor, '_descendants', Object.create(null) );
|
|
116
|
+
setLink( ancestor, '_descendants', Object.create( null ) );
|
|
116
117
|
if (!desc[sname])
|
|
117
118
|
desc[sname] = [ art ];
|
|
118
119
|
else
|
|
@@ -125,6 +126,7 @@ function kickStart( model ) {
|
|
|
125
126
|
if (elem.target && type && type[0] && type[0].id === 'cds.Composition') {
|
|
126
127
|
// A target aspect would have already moved to property `targetAspect` in
|
|
127
128
|
// define.js (hm... more something for kick-start.js...)
|
|
129
|
+
// TODO: for safety, just use resolveUncheckedPath()
|
|
128
130
|
const target = resolvePath( elem.target, 'target', elem );
|
|
129
131
|
if (target)
|
|
130
132
|
model.$compositionTargets[target.name.absolute] = true;
|
|
@@ -134,6 +136,7 @@ function kickStart( model ) {
|
|
|
134
136
|
|
|
135
137
|
// Resolve the using declarations in `using`. Issue
|
|
136
138
|
// error message if the referenced artifact does not exist.
|
|
139
|
+
// TODO: think of moving this to resolve.js
|
|
137
140
|
function resolveUsings( src, topLevel ) {
|
|
138
141
|
if (!src.usings)
|
|
139
142
|
return;
|
|
@@ -23,7 +23,7 @@ function setLayers( sources ) {
|
|
|
23
23
|
|
|
24
24
|
// It is ensured that the representative is called last in SCC and that
|
|
25
25
|
// dependent SCCs are called first
|
|
26
|
-
function setExtends( node, representative, sccDeps = Object.create(null) ) {
|
|
26
|
+
function setExtends( node, representative, sccDeps = Object.create( null ) ) {
|
|
27
27
|
setLink( node, '_layerRepresentative', representative );
|
|
28
28
|
if (layerRepresentative !== representative) {
|
|
29
29
|
layerRepresentative = representative;
|