@sap/cds-compiler 4.6.2 → 4.7.4
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 +37 -0
- package/bin/cds_update_identifiers.js +6 -2
- package/bin/cdsc.js +1 -1
- package/doc/CHANGELOG_ARCHIVE.md +9 -9
- package/doc/CHANGELOG_BETA.md +6 -0
- package/lib/api/main.js +56 -9
- package/lib/api/options.js +6 -3
- package/lib/api/validate.js +20 -29
- package/lib/base/message-registry.js +27 -3
- package/lib/base/messages.js +8 -3
- package/lib/base/model.js +2 -0
- package/lib/checks/dbFeatureFlags.js +28 -0
- package/lib/checks/elements.js +81 -13
- package/lib/checks/enricher.js +3 -2
- package/lib/checks/validator.js +38 -4
- package/lib/compiler/assert-consistency.js +4 -4
- package/lib/compiler/checks.js +5 -4
- package/lib/compiler/define.js +2 -2
- package/lib/compiler/generate.js +2 -1
- package/lib/compiler/propagator.js +3 -11
- package/lib/compiler/shared.js +2 -1
- package/lib/compiler/tweak-assocs.js +43 -24
- package/lib/edm/annotations/edmJson.js +3 -0
- package/lib/edm/annotations/genericTranslation.js +156 -106
- package/lib/edm/annotations/preprocessAnnotations.js +11 -14
- package/lib/edm/csn2edm.js +27 -24
- package/lib/edm/edm.js +8 -8
- package/lib/edm/edmPreprocessor.js +135 -37
- package/lib/edm/edmUtils.js +20 -7
- package/lib/gen/Dictionary.json +1 -0
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +9 -11
- package/lib/gen/languageParser.js +5942 -5446
- package/lib/json/to-csn.js +7 -114
- package/lib/language/genericAntlrParser.js +106 -48
- package/lib/model/cloneCsn.js +203 -0
- package/lib/model/csnRefs.js +11 -3
- package/lib/model/csnUtils.js +42 -85
- package/lib/optionProcessor.js +2 -2
- package/lib/render/manageConstraints.js +1 -1
- package/lib/render/toCdl.js +133 -88
- package/lib/render/toHdbcds.js +1 -5
- package/lib/render/toSql.js +7 -9
- package/lib/render/utils/common.js +9 -16
- package/lib/transform/addTenantFields.js +277 -102
- package/lib/transform/db/applyTransformations.js +14 -9
- package/lib/transform/db/backlinks.js +2 -1
- package/lib/transform/db/constraints.js +60 -82
- package/lib/transform/db/expansion.js +6 -6
- package/lib/transform/db/featureFlags.js +5 -0
- package/lib/transform/db/flattening.js +4 -4
- package/lib/transform/db/killAnnotations.js +1 -0
- package/lib/transform/db/rewriteCalculatedElements.js +2 -2
- package/lib/transform/db/transformExists.js +12 -0
- package/lib/transform/db/views.js +5 -2
- package/lib/transform/draft/odata.js +7 -6
- package/lib/transform/effective/associations.js +2 -1
- package/lib/transform/effective/main.js +3 -2
- package/lib/transform/effective/types.js +6 -3
- package/lib/transform/forOdata.js +39 -24
- package/lib/transform/forRelationalDB.js +34 -27
- package/lib/transform/localized.js +29 -9
- package/lib/transform/odata/flattening.js +419 -0
- package/lib/transform/odata/toFinalBaseType.js +95 -15
- package/lib/transform/odata/typesExposure.js +9 -7
- package/lib/transform/transformUtils.js +7 -6
- package/lib/transform/translateAssocsToJoins.js +3 -3
- package/lib/utils/objectUtils.js +14 -0
- package/package.json +1 -1
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
const { setProp } = require('../base/model');
|
|
8
8
|
|
|
9
9
|
const { copyAnnotations, applyTransformations, isDollarSelfOrProjectionOperand } = require('../model/csnUtils');
|
|
10
|
-
const {
|
|
10
|
+
const { getUtils } = require('../model/csnUtils');
|
|
11
11
|
const { typeParameters, isBuiltinType } = require('../compiler/builtins');
|
|
12
12
|
const { ModelError, CompilerAssertion} = require('../base/error');
|
|
13
13
|
const { forEach } = require('../utils/objectUtils');
|
|
14
|
+
const { cloneCsnNonDict, cloneCsnDict } = require('../model/cloneCsn');
|
|
14
15
|
|
|
15
16
|
const RestrictedOperators = ['<', '>', '>=', '<='];
|
|
16
17
|
const RelationalOperators = ['=', '!=', '<>', 'is' /*, 'like'*/,...RestrictedOperators];
|
|
@@ -341,13 +342,13 @@ function getTransformers(model, options, msgFunctions, pathDelimiter = '_') {
|
|
|
341
342
|
|
|
342
343
|
// Don't process a leading $self - it will a .art with .elements!
|
|
343
344
|
let i = scope === '$self' ? 1 : 0;
|
|
344
|
-
|
|
345
|
+
|
|
345
346
|
// read property from resolved path link
|
|
346
347
|
const art = (propName) =>
|
|
347
348
|
(links[i].art?.[propName] ||
|
|
348
349
|
effectiveType(links[i].art)[propName] ||
|
|
349
350
|
(resolvedLinkTypes.get(links[i])||{})[propName]);
|
|
350
|
-
|
|
351
|
+
|
|
351
352
|
let flattenStep = false;
|
|
352
353
|
let nextIsItems = !!art('items') || (refParentIsItems && i === 0);
|
|
353
354
|
for(; i < links.length; i++) {
|
|
@@ -370,7 +371,7 @@ function getTransformers(model, options, msgFunctions, pathDelimiter = '_') {
|
|
|
370
371
|
if(nextIsItems && art('target'))
|
|
371
372
|
nextIsItems = false;
|
|
372
373
|
|
|
373
|
-
flattenStep = !links[i].art?.kind &&
|
|
374
|
+
flattenStep = !links[i].art?.kind &&
|
|
374
375
|
!links[i].art?.SELECT &&
|
|
375
376
|
!links[i].art?.from &&
|
|
376
377
|
art('elements');
|
|
@@ -441,7 +442,7 @@ function getTransformers(model, options, msgFunctions, pathDelimiter = '_') {
|
|
|
441
442
|
// since it must also be structured and must contain at least as many elements,
|
|
442
443
|
// if not more (in client style CSN).
|
|
443
444
|
if (typeRef.elements && !(options.transformation === 'hdbcds' && options.sqlMapping === 'hdbcds'))
|
|
444
|
-
nodeWithType.elements =
|
|
445
|
+
nodeWithType.elements = cloneCsnDict(typeRef.elements, options);
|
|
445
446
|
else if (typeRef.items)
|
|
446
447
|
nodeWithType.items = cloneCsnNonDict(typeRef.items, options);
|
|
447
448
|
|
|
@@ -449,7 +450,7 @@ function getTransformers(model, options, msgFunctions, pathDelimiter = '_') {
|
|
|
449
450
|
}
|
|
450
451
|
|
|
451
452
|
if (typeRef.enum && nodeWithType.enum === undefined)
|
|
452
|
-
nodeWithType.enum =
|
|
453
|
+
nodeWithType.enum = cloneCsnDict(typeRef.enum, options);
|
|
453
454
|
|
|
454
455
|
// Copy type and type arguments (+ localized)
|
|
455
456
|
|
|
@@ -55,7 +55,7 @@ function translateAssocsToJoinsCSN(csn, options){
|
|
|
55
55
|
|
|
56
56
|
function translateAssocsToJoins(model, inputOptions = {})
|
|
57
57
|
{
|
|
58
|
-
const { error, warning, throwWithError } = makeMessageFunction(model, inputOptions);
|
|
58
|
+
const { error, warning, throwWithError } = makeMessageFunction(model, inputOptions, 'a2j');
|
|
59
59
|
|
|
60
60
|
const options = model.options || inputOptions;
|
|
61
61
|
|
|
@@ -495,7 +495,7 @@ function translateAssocsToJoins(model, inputOptions = {})
|
|
|
495
495
|
let srcTableAlias = constructTableAliasPathStep(assocSourceQA);
|
|
496
496
|
let tgtTableAlias = constructTableAliasPathStep(assocQAT.$QA);
|
|
497
497
|
|
|
498
|
-
node.on = createOnCondition(assoc, srcTableAlias, tgtTableAlias, options.
|
|
498
|
+
node.on = createOnCondition(assoc, srcTableAlias, tgtTableAlias, options.tenantDiscriminator);
|
|
499
499
|
|
|
500
500
|
if(assocQAT._filter)
|
|
501
501
|
{
|
|
@@ -600,7 +600,7 @@ function translateAssocsToJoins(model, inputOptions = {})
|
|
|
600
600
|
Put all src/tgt path siblings into the EQ term and create the proper path objects
|
|
601
601
|
with the src/tgt table alias path steps in front.
|
|
602
602
|
*/
|
|
603
|
-
let args = []
|
|
603
|
+
let args = compareTenants ? [ addTenantComparison(assoc) ] : [];
|
|
604
604
|
for(let i = 0; i < assoc.$flatSrcFKs.length; i++)
|
|
605
605
|
{
|
|
606
606
|
args.push({op: {val: '=' },
|
package/lib/utils/objectUtils.js
CHANGED
|
@@ -70,10 +70,24 @@ function forEachKey( o, callback ) {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Sets a property as "hidden" (a.k.a. non-enumerable).
|
|
75
|
+
*
|
|
76
|
+
* @param {object} obj
|
|
77
|
+
* @param {string} prop
|
|
78
|
+
* @param {any} val
|
|
79
|
+
*/
|
|
80
|
+
function setHidden( obj, prop, val ) {
|
|
81
|
+
Object.defineProperty( obj, prop, {
|
|
82
|
+
value: val, configurable: true, writable: true, enumerable: false,
|
|
83
|
+
} );
|
|
84
|
+
}
|
|
85
|
+
|
|
73
86
|
module.exports = {
|
|
74
87
|
copyPropIfExist,
|
|
75
88
|
createDict,
|
|
76
89
|
forEach,
|
|
77
90
|
forEachValue,
|
|
78
91
|
forEachKey,
|
|
92
|
+
setHidden,
|
|
79
93
|
};
|