@sap/cds-compiler 3.5.2 → 3.5.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 +8 -0
- package/lib/api/options.js +1 -0
- package/lib/base/model.js +33 -22
- package/lib/compiler/resolve.js +1 -7
- package/lib/edm/annotations/preprocessAnnotations.js +3 -3
- package/lib/optionProcessor.js +4 -0
- package/lib/render/toHdbcds.js +1 -1
- package/lib/render/utils/sql.js +1 -2
- package/lib/transform/db/constraints.js +4 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,14 @@
|
|
|
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 3.5.4 - 2023-01-10
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Allow window functions also with a deprecated flag being set.
|
|
15
|
+
- to.edm(x): Fix program abort due to malformed error location in EDM annotation preprocessing.
|
|
16
|
+
- to.sql/hdi/hdbcds: The option `pre2134ReferentialConstraintNames` can be used to omit the referential constraint identifier prefix "c__".
|
|
17
|
+
|
|
10
18
|
## Version 3.5.2 - 2022-12-20
|
|
11
19
|
|
|
12
20
|
### Fixed
|
package/lib/api/options.js
CHANGED
package/lib/base/model.js
CHANGED
|
@@ -37,6 +37,30 @@ const availableBetaFlags = {
|
|
|
37
37
|
nestedServices: false,
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
const availableDeprecatedFlags = {
|
|
41
|
+
// the old ones starting with _, : false
|
|
42
|
+
autoCorrectOrderBySourceRefs: true,
|
|
43
|
+
eagerPersistenceForGeneratedEntities: true,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const oldDeprecatedFlags_v2 = [
|
|
47
|
+
'createLocalizedViews',
|
|
48
|
+
'downgradableErrors',
|
|
49
|
+
'generatedEntityNameWithUnderscore',
|
|
50
|
+
'longAutoexposed',
|
|
51
|
+
'noElementsExpansion',
|
|
52
|
+
'noInheritedAutoexposeViaComposition',
|
|
53
|
+
'noScopedRedirections',
|
|
54
|
+
'oldVirtualNotNullPropagation',
|
|
55
|
+
'parensAsStrings',
|
|
56
|
+
'projectionAsQuery',
|
|
57
|
+
'redirectInSubQueries',
|
|
58
|
+
'renderVirtualElements',
|
|
59
|
+
'shortAutoexposed',
|
|
60
|
+
'unmanagedUpInComponent',
|
|
61
|
+
'v1KeysForTemporal',
|
|
62
|
+
];
|
|
63
|
+
|
|
40
64
|
/**
|
|
41
65
|
* Test for early-adaptor feature, stored in option `beta`(new-style) / `betaMode`(old-style)
|
|
42
66
|
* With that, the value of `beta` is a dictionary of feature=>Boolean.
|
|
@@ -59,7 +83,11 @@ function isBetaEnabled( options, feature ) {
|
|
|
59
83
|
/**
|
|
60
84
|
* Test for deprecated feature, stored in option `deprecated`.
|
|
61
85
|
* With that, the value of `deprecated` is a dictionary of feature=>Boolean.
|
|
62
|
-
*
|
|
86
|
+
*
|
|
87
|
+
* If no `feature` is provided, checks if any deprecated option is set
|
|
88
|
+
* which is not mentioned in availableDeprecatedFlags with value true.
|
|
89
|
+
* Useful for newer functionality which might not work with some
|
|
90
|
+
* deprecated feature turned on.
|
|
63
91
|
*
|
|
64
92
|
* Please do not move this function to the "option processor" code.
|
|
65
93
|
*
|
|
@@ -69,30 +97,13 @@ function isBetaEnabled( options, feature ) {
|
|
|
69
97
|
*/
|
|
70
98
|
function isDeprecatedEnabled( options, feature = null ) {
|
|
71
99
|
const { deprecated } = options;
|
|
72
|
-
if (!feature)
|
|
73
|
-
return !!deprecated
|
|
74
|
-
|
|
100
|
+
if (!feature) {
|
|
101
|
+
return !!deprecated && Object.keys( deprecated )
|
|
102
|
+
.some( d => !availableDeprecatedFlags[d] );
|
|
103
|
+
}
|
|
75
104
|
return deprecated && typeof deprecated === 'object' && deprecated[feature];
|
|
76
105
|
}
|
|
77
106
|
|
|
78
|
-
const oldDeprecatedFlags_v2 = [
|
|
79
|
-
'createLocalizedViews',
|
|
80
|
-
'downgradableErrors',
|
|
81
|
-
'generatedEntityNameWithUnderscore',
|
|
82
|
-
'longAutoexposed',
|
|
83
|
-
'noElementsExpansion',
|
|
84
|
-
'noInheritedAutoexposeViaComposition',
|
|
85
|
-
'noScopedRedirections',
|
|
86
|
-
'oldVirtualNotNullPropagation',
|
|
87
|
-
'parensAsStrings',
|
|
88
|
-
'projectionAsQuery',
|
|
89
|
-
'redirectInSubQueries',
|
|
90
|
-
'renderVirtualElements',
|
|
91
|
-
'shortAutoexposed',
|
|
92
|
-
'unmanagedUpInComponent',
|
|
93
|
-
'v1KeysForTemporal',
|
|
94
|
-
];
|
|
95
|
-
|
|
96
107
|
/**
|
|
97
108
|
* In cds-compiler v3, we removed old v2 deprecated flags. That can lead to silent
|
|
98
109
|
* errors such as entity/view names changing. To ensure that the user is forced
|
package/lib/compiler/resolve.js
CHANGED
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
'use strict';
|
|
40
40
|
|
|
41
41
|
const {
|
|
42
|
-
isDeprecatedEnabled,
|
|
43
42
|
forEachDefinition,
|
|
44
43
|
forEachMember,
|
|
45
44
|
forEachGeneric,
|
|
@@ -80,7 +79,7 @@ const $inferred = Symbol.for('cds.$inferred');
|
|
|
80
79
|
// exception in case of an error, but push the corresponding error object to
|
|
81
80
|
// that property (should be a vector).
|
|
82
81
|
function resolve( model ) {
|
|
83
|
-
const { options } = model;
|
|
82
|
+
// const { options } = model;
|
|
84
83
|
// Get shared functionality and the message function:
|
|
85
84
|
const {
|
|
86
85
|
info, warning, error, message,
|
|
@@ -1328,11 +1327,6 @@ function resolve( model ) {
|
|
|
1328
1327
|
const args = Array.isArray(expr.args) ? expr.args : Object.values( expr.args );
|
|
1329
1328
|
args.forEach( e => e && resolveExpr( e, e.$expected || expected, user, extDict ) );
|
|
1330
1329
|
}
|
|
1331
|
-
if (expr.suffix && isDeprecatedEnabled( options )) {
|
|
1332
|
-
const { location } = expr.suffix[0] || expr;
|
|
1333
|
-
error( null, [ location, user ], { prop: 'deprecated' },
|
|
1334
|
-
'Window functions are not supported if $(PROP) options are set' );
|
|
1335
|
-
}
|
|
1336
1330
|
if (expr.suffix)
|
|
1337
1331
|
expr.suffix.forEach( s => s && resolveExpr( s, expected, user, extDict ) );
|
|
1338
1332
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const { makeMessageFunction } = require('../../base/messages.js');
|
|
4
|
-
const { forEachDefinition } = require('../../model/csnUtils.js');
|
|
4
|
+
const { forEachDefinition, forEachGeneric } = require('../../model/csnUtils.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
/**************************************************************************************************
|
|
@@ -66,9 +66,9 @@ function preprocessAnnotations(csn, serviceName, options) {
|
|
|
66
66
|
artifact.elements && Object.entries(artifact.elements).forEach(([elementName, element]) => {
|
|
67
67
|
handleAnnotations(elementName, element, [ ...location, 'elements', elementName ]);
|
|
68
68
|
});
|
|
69
|
-
artifact
|
|
69
|
+
forEachGeneric(artifact, 'actions', (action, actionName) => {
|
|
70
70
|
action.params && Object.entries(action.params).forEach(([paramName, param]) => {
|
|
71
|
-
handleAnnotations(paramName, param, [ ...location, 'actions',
|
|
71
|
+
handleAnnotations(paramName, param, [ ...location, 'actions', actionName, 'params', paramName ]);
|
|
72
72
|
});
|
|
73
73
|
});
|
|
74
74
|
}
|
package/lib/optionProcessor.js
CHANGED
|
@@ -166,6 +166,7 @@ optionProcessor.command('H, toHana')
|
|
|
166
166
|
.option(' --integrity-not-enforced')
|
|
167
167
|
.option(' --assert-integrity <mode>', ['true', 'false', 'individual'])
|
|
168
168
|
.option(' --assert-integrity-type <type>', ['RT', 'DB'], { ignoreCase: true })
|
|
169
|
+
.option(' --pre2134ReferentialConstraintNames')
|
|
169
170
|
.option(' --disable-hana-comments')
|
|
170
171
|
.help(`
|
|
171
172
|
Usage: cdsc toHana [options] <files...>
|
|
@@ -201,6 +202,7 @@ optionProcessor.command('H, toHana')
|
|
|
201
202
|
RT : (default) No database constraint for an association
|
|
202
203
|
if not explicitly demanded via annotation
|
|
203
204
|
DB : Create database constraints for associations
|
|
205
|
+
--pre2134ReferentialConstraintNames Do not prefix the constraint identifier with "c__"
|
|
204
206
|
--disable-hana-comments Disable rendering of doc comments as SAP HANA comments.
|
|
205
207
|
`);
|
|
206
208
|
|
|
@@ -280,6 +282,7 @@ optionProcessor.command('Q, toSql')
|
|
|
280
282
|
.option(' --assert-integrity <mode>', ['true', 'false', 'individual'])
|
|
281
283
|
.option(' --assert-integrity-type <type>', ['RT', 'DB'], { ignoreCase: true })
|
|
282
284
|
.option(' --constraints-in-create-table')
|
|
285
|
+
.option(' --pre2134ReferentialConstraintNames')
|
|
283
286
|
.option(' --disable-hana-comments')
|
|
284
287
|
.help(`
|
|
285
288
|
Usage: cdsc toSql [options] <files...>
|
|
@@ -329,6 +332,7 @@ optionProcessor.command('Q, toSql')
|
|
|
329
332
|
--constraints-in-create-table If set, the foreign key constraints will be rendered as
|
|
330
333
|
part of the "CREATE TABLE" statements rather than as separate
|
|
331
334
|
"ALTER TABLE ADD CONSTRAINT" statements
|
|
335
|
+
--pre2134ReferentialConstraintNames Do not prefix the constraint identifier with "c__"
|
|
332
336
|
--disable-hana-comments Disable rendering of doc comments as SAP HANA comments.
|
|
333
337
|
`);
|
|
334
338
|
|
package/lib/render/toHdbcds.js
CHANGED
|
@@ -146,7 +146,7 @@ function toHdbcdsSource( csn, options ) {
|
|
|
146
146
|
Object.entries(art.$tableConstraints.referential)
|
|
147
147
|
.forEach(([ fileName, referentialConstraint ]) => {
|
|
148
148
|
referentialConstraints[fileName] = renderReferentialConstraint(
|
|
149
|
-
referentialConstraint,
|
|
149
|
+
referentialConstraint, increaseIndent(createEnv()).indent, renderToUppercase, csn, options
|
|
150
150
|
);
|
|
151
151
|
});
|
|
152
152
|
Object.entries(referentialConstraints)
|
package/lib/render/utils/sql.js
CHANGED
|
@@ -65,8 +65,7 @@ function renderReferentialConstraint( constraint, indent, toUpperCase, csn, opti
|
|
|
65
65
|
}
|
|
66
66
|
// constraint enforcement / validation must be switched off using sqlite pragma statement
|
|
67
67
|
// constraint enforcement / validation not supported by postgres
|
|
68
|
-
|
|
69
|
-
if (options.toSql && sqlDialect !== 'sqlite' && sqlDialect !== 'postgres') {
|
|
68
|
+
if (options.transformation === 'hdbcds' || (options.toSql && sqlDialect !== 'sqlite' && sqlDialect !== 'postgres')) {
|
|
70
69
|
result += `${indent}${!constraint.validated ? 'NOT ' : ''}VALIDATED\n`;
|
|
71
70
|
result += `${indent}${!constraint.enforced ? 'NOT ' : ''}ENFORCED\n`;
|
|
72
71
|
}
|
|
@@ -515,9 +515,11 @@ function createReferentialConstraints( csn, options ) {
|
|
|
515
515
|
// comments in sqlite files are causing the JDBC driver to throw an error on deployment
|
|
516
516
|
if (options.testMode && onDelete === 'CASCADE')
|
|
517
517
|
onDeleteRemark = `Up_ link for Composition "${$foreignKeyConstraint.upLinkFor}" implies existential dependency`;
|
|
518
|
+
// constraint identifier usually start with `c__` to avoid name clashes
|
|
519
|
+
let identifier = options.pre2134ReferentialConstraintNames ? '' : 'c__';
|
|
520
|
+
identifier += `${getResultingName(csn, options.sqlMapping, artifactName)}_${$foreignKeyConstraint.sourceAssociation}`;
|
|
518
521
|
referentialConstraints[`${getResultingName(csn, 'quoted', artifactName)}_${$foreignKeyConstraint.sourceAssociation}`] = {
|
|
519
|
-
|
|
520
|
-
identifier: `c__${getResultingName(csn, options.sqlMapping, artifactName)}_${$foreignKeyConstraint.sourceAssociation}`,
|
|
522
|
+
identifier,
|
|
521
523
|
foreignKey: dependentKey,
|
|
522
524
|
parentKey,
|
|
523
525
|
dependentTable: artifactName,
|