@sap/cds-compiler 3.6.2 → 3.8.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.
- package/CHANGELOG.md +109 -1
- package/README.md +3 -0
- package/bin/cdsc.js +12 -5
- package/doc/CHANGELOG_ARCHIVE.md +6 -6
- package/doc/CHANGELOG_BETA.md +35 -2
- package/doc/CHANGELOG_DEPRECATED.md +2 -2
- package/doc/DeprecatedOptions_v2.md +1 -1
- package/doc/NameResolution.md +1 -1
- package/lib/api/main.js +63 -23
- package/lib/api/options.js +1 -0
- package/lib/api/validate.js +5 -0
- package/lib/base/dictionaries.js +15 -3
- package/lib/base/keywords.js +2 -0
- package/lib/base/message-registry.js +120 -34
- package/lib/base/messages.js +51 -27
- package/lib/base/model.js +4 -2
- package/lib/base/shuffle.js +2 -1
- package/lib/checks/arrayOfs.js +1 -1
- package/lib/checks/defaultValues.js +1 -1
- package/lib/checks/elements.js +29 -1
- package/lib/checks/{emptyOrOnlyVirtual.js → hasPersistedElements.js} +10 -6
- package/lib/checks/invalidTarget.js +1 -1
- package/lib/checks/nonexpandableStructured.js +1 -1
- package/lib/checks/onConditions.js +15 -9
- package/lib/checks/sql-snippets.js +2 -2
- package/lib/checks/types.js +5 -1
- package/lib/checks/validator.js +7 -3
- package/lib/compiler/assert-consistency.js +42 -26
- package/lib/compiler/base.js +50 -4
- package/lib/compiler/builtins.js +17 -8
- package/lib/compiler/checks.js +241 -246
- package/lib/compiler/define.js +113 -146
- package/lib/compiler/extend.js +889 -383
- package/lib/compiler/finalize-parse-cdl.js +5 -58
- package/lib/compiler/index.js +1 -1
- package/lib/compiler/kick-start.js +7 -8
- package/lib/compiler/populate.js +297 -293
- package/lib/compiler/propagator.js +27 -18
- package/lib/compiler/resolve.js +146 -463
- package/lib/compiler/shared.js +36 -79
- package/lib/compiler/tweak-assocs.js +30 -28
- package/lib/compiler/utils.js +31 -5
- package/lib/edm/annotations/genericTranslation.js +131 -59
- package/lib/edm/annotations/preprocessAnnotations.js +3 -0
- package/lib/edm/csn2edm.js +22 -5
- package/lib/edm/edm.js +6 -4
- package/lib/edm/edmAnnoPreprocessor.js +1 -0
- package/lib/edm/edmPreprocessor.js +42 -26
- package/lib/gen/Dictionary.json +38 -2
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +3 -1
- package/lib/gen/languageLexer.js +1 -1
- package/lib/gen/languageParser.js +4828 -4472
- package/lib/inspect/inspectPropagation.js +20 -34
- package/lib/json/from-csn.js +140 -44
- package/lib/json/to-csn.js +114 -122
- package/lib/language/errorStrategy.js +2 -0
- package/lib/language/genericAntlrParser.js +156 -36
- package/lib/language/language.g4 +100 -58
- package/lib/language/textUtils.js +13 -0
- package/lib/main.d.ts +43 -3
- package/lib/main.js +4 -2
- package/lib/model/csnRefs.js +15 -3
- package/lib/model/csnUtils.js +12 -74
- package/lib/model/revealInternalProperties.js +4 -2
- package/lib/modelCompare/compare.js +2 -1
- package/lib/optionProcessor.js +3 -0
- package/lib/render/manageConstraints.js +5 -2
- package/lib/render/toCdl.js +216 -104
- package/lib/render/toHdbcds.js +2 -9
- package/lib/render/toRename.js +14 -51
- package/lib/render/toSql.js +4 -3
- package/lib/render/utils/common.js +9 -5
- package/lib/transform/braceExpression.js +6 -0
- package/lib/transform/db/assertUnique.js +2 -1
- package/lib/transform/db/expansion.js +2 -0
- package/lib/transform/db/flattening.js +37 -36
- package/lib/transform/db/rewriteCalculatedElements.js +600 -0
- package/lib/transform/db/transformExists.js +4 -0
- package/lib/transform/db/views.js +40 -37
- package/lib/transform/forOdataNew.js +20 -15
- package/lib/transform/forRelationalDB.js +58 -41
- package/lib/transform/odata/typesExposure.js +50 -15
- package/lib/transform/parseExpr.js +16 -8
- package/lib/transform/transformUtilsNew.js +42 -14
- package/lib/transform/translateAssocsToJoins.js +60 -37
- package/lib/transform/universalCsn/coreComputed.js +15 -7
- package/lib/transform/universalCsn/universalCsnEnricher.js +4 -4
- package/package.json +2 -1
|
@@ -14,7 +14,12 @@ const {
|
|
|
14
14
|
forEachGeneric,
|
|
15
15
|
isDeprecatedEnabled,
|
|
16
16
|
} = require( '../base/model');
|
|
17
|
-
const {
|
|
17
|
+
const {
|
|
18
|
+
setLink,
|
|
19
|
+
linkToOrigin,
|
|
20
|
+
withAssociation,
|
|
21
|
+
viewFromPrimary,
|
|
22
|
+
} = require('./utils');
|
|
18
23
|
const $inferred = Symbol.for('cds.$inferred');
|
|
19
24
|
// const { refString } = require( '../base/messages')
|
|
20
25
|
|
|
@@ -81,7 +86,7 @@ function propagate( model ) {
|
|
|
81
86
|
function run( art ) {
|
|
82
87
|
if (!art)
|
|
83
88
|
return;
|
|
84
|
-
if (!checkAndSetStatus( art )) {
|
|
89
|
+
if (!checkAndSetStatus( art ) || art.kind === 'select') {
|
|
85
90
|
runMembers( art );
|
|
86
91
|
return;
|
|
87
92
|
}
|
|
@@ -94,6 +99,13 @@ function propagate( model ) {
|
|
|
94
99
|
for (const target of targets) {
|
|
95
100
|
const origin = getOrigin( target );
|
|
96
101
|
if (origin) {
|
|
102
|
+
// Calculated elements that are simple references: `calc = field;`.
|
|
103
|
+
// Respect sibling properties in inheritance.
|
|
104
|
+
if (target._calcOrigin?._origin && target.value?._artifact) {
|
|
105
|
+
chain.push({ target, source: target.value._artifact });
|
|
106
|
+
if (checkAndSetStatus( target.value._artifact ))
|
|
107
|
+
news.push(target.value._artifact);
|
|
108
|
+
}
|
|
97
109
|
chain.push( { target, source: origin } );
|
|
98
110
|
if (checkAndSetStatus( origin ))
|
|
99
111
|
news.push( origin );
|
|
@@ -173,13 +185,13 @@ function propagate( model ) {
|
|
|
173
185
|
}
|
|
174
186
|
else {
|
|
175
187
|
target[prop] = Object.assign( {}, val, { $inferred: 'prop' } );
|
|
176
|
-
if (
|
|
188
|
+
if (val._artifact !== undefined)
|
|
177
189
|
setLink( target[prop], '_artifact', val._artifact );
|
|
178
|
-
if (
|
|
190
|
+
if (val._outer !== undefined)
|
|
179
191
|
setLink( target[prop], '_outer', val._outer );
|
|
180
|
-
if (
|
|
192
|
+
if (val._parent !== undefined)
|
|
181
193
|
setLink( target[prop], '_parent', val._parent );
|
|
182
|
-
if (
|
|
194
|
+
if (val._main !== undefined)
|
|
183
195
|
setLink( target[prop], '_main', val._main );
|
|
184
196
|
}
|
|
185
197
|
}
|
|
@@ -254,7 +266,8 @@ function propagate( model ) {
|
|
|
254
266
|
}
|
|
255
267
|
|
|
256
268
|
function onlyViaArtifact( prop, target, source ) {
|
|
257
|
-
const from = target
|
|
269
|
+
const from = viewFromPrimary( target )?.path;
|
|
270
|
+
// do not propagate from member / if follow assoc in from:
|
|
258
271
|
if (!(from ? from[from.length - 1]._artifact : source)._main)
|
|
259
272
|
annotation( prop, target, source );
|
|
260
273
|
}
|
|
@@ -280,7 +293,7 @@ function propagate( model ) {
|
|
|
280
293
|
if (!viaType)
|
|
281
294
|
always( prop, target, source );
|
|
282
295
|
else if (!oldVirtualNotNullPropagation) // NULL would block strange propagation to sub element
|
|
283
|
-
target[prop] = { $inferred: 'NULL', val: undefined }; // set null value in
|
|
296
|
+
target[prop] = { $inferred: 'NULL', val: undefined }; // set null value in Universal CSN
|
|
284
297
|
}
|
|
285
298
|
|
|
286
299
|
function checkVirtual( view ) {
|
|
@@ -331,18 +344,14 @@ function targetMinZero( art ) {
|
|
|
331
344
|
}
|
|
332
345
|
|
|
333
346
|
function getOrigin( art ) {
|
|
334
|
-
|
|
347
|
+
let origin = art._origin;
|
|
348
|
+
while (origin?.kind === 'select')
|
|
349
|
+
origin = origin._origin;
|
|
350
|
+
if (origin)
|
|
335
351
|
// Do not consider _origin if due to expand of table alias ref
|
|
336
|
-
return (!art.expand ||
|
|
352
|
+
return (!art.expand || origin.kind === 'element') && origin;
|
|
337
353
|
// Remark: a column with an 'inline' is never an element -> no need to check
|
|
338
354
|
// art.inline
|
|
339
|
-
if (art._from && art._from.length) { // query
|
|
340
|
-
const tabref = art._from[0]._artifact;
|
|
341
|
-
return (tabref && tabref.kind === 'element')
|
|
342
|
-
? tabref._effectiveType && tabref._effectiveType.target &&
|
|
343
|
-
tabref._effectiveType.target._artifact
|
|
344
|
-
: tabref;
|
|
345
|
-
}
|
|
346
355
|
|
|
347
356
|
return (art.type && (!art.type.$inferred || art.type.$inferred === 'cast'))
|
|
348
357
|
? art.type._artifact
|
|
@@ -357,7 +366,7 @@ function checkAndSetStatus( art ) {
|
|
|
357
366
|
}
|
|
358
367
|
|
|
359
368
|
function setEffectiveType( target, source ) {
|
|
360
|
-
if (
|
|
369
|
+
if (source._effectiveType !== undefined)
|
|
361
370
|
setLink( target, '_effectiveType', source._effectiveType);
|
|
362
371
|
}
|
|
363
372
|
|