@sap/cds-compiler 3.4.2 → 3.5.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 +80 -0
- package/README.md +1 -0
- package/bin/cds_update_identifiers.js +5 -5
- package/bin/cdsc.js +15 -16
- package/bin/cdshi.js +19 -6
- package/doc/CHANGELOG_ARCHIVE.md +2 -2
- package/doc/CHANGELOG_BETA.md +9 -1
- package/doc/CHANGELOG_DEPRECATED.md +2 -0
- package/lib/api/main.js +61 -59
- package/lib/api/options.js +4 -2
- package/lib/api/validate.js +2 -2
- package/lib/base/cleanSymbols.js +2 -3
- package/lib/base/dictionaries.js +6 -6
- package/lib/base/error.js +2 -2
- package/lib/base/keywords.js +6 -6
- package/lib/base/location.js +11 -12
- package/lib/base/message-registry.js +177 -58
- package/lib/base/messages.js +252 -180
- package/lib/base/model.js +14 -11
- package/lib/base/node-helpers.js +9 -10
- package/lib/base/optionProcessorHelper.js +138 -129
- package/lib/checks/.eslintrc.json +2 -0
- package/lib/checks/actionsFunctions.js +5 -5
- package/lib/checks/annotationsOData.js +4 -4
- package/lib/checks/arrayOfs.js +1 -1
- package/lib/checks/cdsPersistence.js +1 -1
- package/lib/checks/checkForTypes.js +3 -3
- package/lib/checks/defaultValues.js +3 -3
- package/lib/checks/elements.js +7 -7
- package/lib/checks/emptyOrOnlyVirtual.js +2 -2
- package/lib/checks/foreignKeys.js +1 -1
- package/lib/checks/invalidTarget.js +4 -4
- package/lib/checks/managedInType.js +1 -1
- package/lib/checks/managedWithoutKeys.js +1 -1
- package/lib/checks/nonexpandableStructured.js +5 -3
- package/lib/checks/nullableKeys.js +1 -1
- package/lib/checks/onConditions.js +5 -6
- package/lib/checks/parameters.js +1 -1
- package/lib/checks/queryNoDbArtifacts.js +2 -2
- package/lib/checks/selectItems.js +4 -4
- package/lib/checks/sql-snippets.js +4 -4
- package/lib/checks/types.js +7 -7
- package/lib/checks/utils.js +4 -4
- package/lib/checks/validator.js +16 -13
- package/lib/compiler/.eslintrc.json +4 -1
- package/lib/compiler/assert-consistency.js +8 -7
- package/lib/compiler/builtins.js +14 -14
- package/lib/compiler/checks.js +123 -48
- package/lib/compiler/define.js +12 -13
- package/lib/compiler/extend.js +266 -60
- package/lib/compiler/finalize-parse-cdl.js +10 -5
- package/lib/compiler/index.js +17 -14
- package/lib/compiler/populate.js +14 -6
- package/lib/compiler/propagator.js +2 -0
- package/lib/compiler/resolve.js +2 -15
- package/lib/compiler/shared.js +27 -16
- package/lib/compiler/tweak-assocs.js +5 -6
- package/lib/compiler/utils.js +20 -0
- package/lib/edm/annotations/genericTranslation.js +604 -358
- package/lib/edm/annotations/preprocessAnnotations.js +39 -35
- package/lib/edm/csn2edm.js +275 -222
- package/lib/edm/edm.js +17 -3
- package/lib/edm/edmAnnoPreprocessor.js +6 -6
- package/lib/edm/edmInboundChecks.js +2 -2
- package/lib/edm/edmPreprocessor.js +107 -77
- package/lib/edm/edmUtils.js +44 -5
- package/lib/gen/Dictionary.json +210 -8
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +67 -63
- package/lib/gen/language.tokens +81 -81
- package/lib/gen/languageLexer.interp +4 -10
- package/lib/gen/languageLexer.js +854 -869
- package/lib/gen/languageLexer.tokens +79 -81
- package/lib/gen/languageParser.js +14309 -13832
- package/lib/inspect/inspectModelStatistics.js +2 -2
- package/lib/inspect/inspectPropagation.js +6 -6
- package/lib/inspect/inspectUtils.js +2 -2
- package/lib/json/from-csn.js +102 -55
- package/lib/json/to-csn.js +119 -198
- package/lib/language/antlrParser.js +5 -2
- package/lib/language/docCommentParser.js +6 -6
- package/lib/language/errorStrategy.js +43 -23
- package/lib/language/genericAntlrParser.js +113 -133
- package/lib/language/language.g4 +1550 -1506
- package/lib/language/multiLineStringParser.js +3 -3
- package/lib/language/textUtils.js +2 -2
- package/lib/main.js +3 -3
- package/lib/model/csnRefs.js +5 -0
- package/lib/model/csnUtils.js +130 -122
- package/lib/model/revealInternalProperties.js +1 -1
- package/lib/model/sortViews.js +4 -6
- package/lib/modelCompare/compare.js +2 -2
- package/lib/modelCompare/utils/.eslintrc.json +22 -0
- package/lib/modelCompare/utils/filter.js +100 -0
- package/lib/optionProcessor.js +5 -0
- package/lib/render/.eslintrc.json +1 -0
- package/lib/render/DuplicateChecker.js +1 -1
- package/lib/render/manageConstraints.js +12 -12
- package/lib/render/toCdl.js +311 -276
- package/lib/render/toHdbcds.js +97 -94
- package/lib/render/toRename.js +5 -5
- package/lib/render/toSql.js +127 -223
- package/lib/render/utils/common.js +141 -108
- package/lib/render/utils/delta.js +227 -0
- package/lib/render/utils/sql.js +22 -6
- package/lib/render/utils/stringEscapes.js +3 -3
- package/lib/transform/db/.eslintrc.json +2 -0
- package/lib/transform/db/applyTransformations.js +3 -3
- package/lib/transform/db/assertUnique.js +13 -12
- package/lib/transform/db/associations.js +5 -5
- package/lib/transform/db/cdsPersistence.js +10 -8
- package/lib/transform/db/constraints.js +14 -14
- package/lib/transform/db/expansion.js +20 -22
- package/lib/transform/db/flattening.js +24 -42
- package/lib/transform/db/groupByOrderBy.js +3 -3
- package/lib/transform/db/temporal.js +6 -6
- package/lib/transform/db/transformExists.js +23 -23
- package/lib/transform/db/views.js +16 -16
- package/lib/transform/draft/.eslintrc.json +1 -35
- package/lib/transform/draft/db.js +10 -10
- package/lib/transform/draft/odata.js +2 -2
- package/lib/transform/forOdataNew.js +8 -29
- package/lib/transform/forRelationalDB.js +16 -6
- package/lib/transform/localized.js +11 -10
- package/lib/transform/odata/toFinalBaseType.js +41 -27
- package/lib/transform/odata/typesExposure.js +113 -47
- package/lib/transform/parseExpr.js +209 -106
- package/lib/transform/transformUtilsNew.js +17 -10
- package/lib/transform/translateAssocsToJoins.js +24 -19
- package/lib/transform/universalCsn/coreComputed.js +10 -10
- package/lib/transform/universalCsn/universalCsnEnricher.js +26 -26
- package/lib/transform/universalCsn/utils.js +3 -3
- package/lib/utils/file.js +5 -5
- package/lib/utils/moduleResolve.js +13 -13
- package/lib/utils/objectUtils.js +6 -6
- package/lib/utils/term.js +5 -2
- package/lib/utils/timetrace.js +51 -24
- package/package.json +5 -8
- package/share/messages/check-proper-type-of.md +1 -1
- package/share/messages/message-explanations.json +1 -1
- package/share/messages/redirected-to-complex.md +4 -4
- package/share/messages/{syntax-expecting-integer.md → syntax-expecting-unsigned-int.md} +7 -4
- package/lib/modelCompare/filter.js +0 -83
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap/cds-compiler",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "CDS (Core Data Services) compiler and backends",
|
|
5
5
|
"homepage": "https://cap.cloud.sap/",
|
|
6
6
|
"author": "SAP SE (https://www.sap.com)",
|
|
@@ -21,16 +21,14 @@
|
|
|
21
21
|
"xmakePrepareRelease": "echo \"$(node scripts/stripReadme.js README.md)\" > README.md && node scripts/assertSnapshotVersioning.js && node scripts/assertChangelog.js && node scripts/cleanup.js --remove-dev",
|
|
22
22
|
"test": "node scripts/verifyGrammarChecksum.js && mocha --reporter min --reporter-option maxDiffSize=0 scripts/testLazyLoading.js && mocha --parallel --reporter min --reporter-option maxDiffSize=0 test/ test3/",
|
|
23
23
|
"testverbose": "node scripts/verifyGrammarChecksum.js && mocha --parallel test/ test3/",
|
|
24
|
-
"test3": "node scripts/verifyGrammarChecksum.js &&
|
|
25
|
-
"deployTest3SQL": "deployRefs=true mocha --reporter-option maxDiffSize=0 test3/
|
|
24
|
+
"test3": "node scripts/verifyGrammarChecksum.js && mocha --reporter-option maxDiffSize=0 test3/",
|
|
25
|
+
"deployTest3SQL": "deployRefs=true mocha --reporter-option maxDiffSize=0 test3/test.deploy.hana-sql.js",
|
|
26
26
|
"deployTest3": "deployRefs=true mocha --reporter-option maxDiffSize=0 test3/testDeployment.js",
|
|
27
|
+
"deployHanaDeltaSQL": "CDS_COMPILER_DEPLOY_HANA=1 mocha test3/test.deploy.hana-sql.delta.js",
|
|
27
28
|
"deployDiffs": "deployRefs=true mocha --reporter-option maxDiffSize=0 test3/deployDiffs.js",
|
|
28
29
|
"gentest3": "cross-env MAKEREFS=${MAKEREFS:-'true'} mocha --reporter-option maxDiffSize=0 test3/testRefFiles.js",
|
|
29
|
-
"testdb": "node scripts/verifyGrammarChecksum.js && cross-env TESTDB='TRUE' mocha",
|
|
30
|
-
"testmigration": "npm install --no-save @sap/hana-client@2.3.123 @sap/hdi-deploy@3.10.0 && node scripts/verifyGrammarChecksum.js && cross-env TESTMIGRATION='TRUE' mocha",
|
|
31
|
-
"testall": "npm install --no-save @sap/hana-client@2.3.123 @sap/hdi-deploy@3.10.0 && node scripts/verifyGrammarChecksum.js && cross-env TESTDB='TRUE' TESTMIGRATION='TRUE' mocha",
|
|
32
30
|
"coverage": "cross-env nyc mocha --reporter-option maxDiffSize=0 test/ test3/ && nyc report --reporter=lcov",
|
|
33
|
-
"lint": "eslint bin/ benchmark/ lib/ test/ test3/ scripts/ types/ && node scripts/linter/lintGrammar.js && node scripts/linter/lintTests.js test3/ && markdownlint README.md CHANGELOG.md doc/ internalDoc/ && cd share/messages && markdownlint .",
|
|
31
|
+
"lint": "eslint bin/ benchmark/ lib/ test/ test3/ scripts/ types/ && node scripts/linter/lintGrammar.js && node scripts/linter/lintTests.js test3/ && node scripts/linter/lintMessages.js && node scripts/linter/lintMessageIdCoverage.js lib/ && markdownlint README.md CHANGELOG.md doc/ internalDoc/ && cd share/messages && markdownlint .",
|
|
34
32
|
"tslint": "tsc --pretty -p .",
|
|
35
33
|
"updateVocs": "node scripts/odataAnnotations/generateDictMain.js && npm run generateAllRefs",
|
|
36
34
|
"generateCompilerRefs": "cross-env MAKEREFS='true' mocha test/testCompiler.js",
|
|
@@ -41,7 +39,6 @@
|
|
|
41
39
|
"generateToSqlRefs": "cross-env MAKEREFS='true' mocha test/testToSql.js",
|
|
42
40
|
"generateToRenameRefs": "cross-env MAKEREFS='true' mocha test/testToRename.js",
|
|
43
41
|
"generateChecksRefs": "cross-env MAKEREFS='true' mocha test/testChecks.js",
|
|
44
|
-
"generateScenarioRefs": "cross-env MAKEREFS='true' mocha test/testScenarios.js",
|
|
45
42
|
"generateDraftRefs": "cross-env MAKEREFS='true' mocha test/testDraft.js",
|
|
46
43
|
"generateAllRefs": "node scripts/verifyGrammarChecksum.js && cross-env MAKEREFS='true' mocha --reporter-option maxDiffSize=0 test/ test3/"
|
|
47
44
|
},
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
The redirected target is a complex view, for example, contains a JOIN or UNION.
|
|
4
4
|
|
|
5
5
|
The message's severity is `Info` and is raised by the compiler.
|
|
6
|
-
It is emitted to help developers identify possible
|
|
6
|
+
It is emitted to help developers identify possible modeling issues.
|
|
7
7
|
|
|
8
8
|
## Example
|
|
9
9
|
|
|
@@ -33,7 +33,7 @@ The cross join in the view `CrossJoin` results in multiple rows with the same
|
|
|
33
33
|
`id`. Following the redirected view now returns multiple results, effectively
|
|
34
34
|
making the to-one association a to-many association.
|
|
35
35
|
|
|
36
|
-
Visualizing the tables with a bit of data, this
|
|
36
|
+
Visualizing the tables with a bit of data, this issue becomes obvious:
|
|
37
37
|
|
|
38
38
|
```markdown
|
|
39
39
|
Main Secondary
|
|
@@ -54,8 +54,8 @@ CrossJoin
|
|
|
54
54
|
## How to Fix
|
|
55
55
|
|
|
56
56
|
Ensure that the redirected association points to an entity that is a reasonable
|
|
57
|
-
redirection target.
|
|
58
|
-
|
|
57
|
+
redirection target. That means, the redirection target shouldn't accidentally
|
|
58
|
+
make it a to-many association.
|
|
59
59
|
|
|
60
60
|
## Related Messages
|
|
61
61
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# syntax-expecting-
|
|
1
|
+
# syntax-expecting-unsigned-int
|
|
2
2
|
|
|
3
|
-
The compiler expects a safe integer here.
|
|
3
|
+
The compiler expects a safe non-negative integer here.
|
|
4
4
|
The last safe integer is `2^53 - 1` or `9007199254740991`.
|
|
5
5
|
|
|
6
6
|
A safe integer is an integer that fulfills all of the following:
|
|
@@ -34,5 +34,8 @@ type LengthIsSafe : String(9007199254740991);
|
|
|
34
34
|
type AnInteger : String(42);
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
At other places, using unsafe integers (or non-integer numbers) is allowed:
|
|
38
|
+
|
|
39
|
+
- Annotation values: The value is then simply a string.
|
|
40
|
+
- Expressions: The `val` property in the CSN contains a string
|
|
41
|
+
having a sibling `literal: 'number'`.
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
// Each db has some changes that it can and cannot represent, or that cause problems only on that specific db
|
|
2
|
-
// In this file, we define rules for each db-dialect to detect and act on these cases.
|
|
3
|
-
|
|
4
|
-
const { forEach } = require("../utils/objectUtils");
|
|
5
|
-
const { isPersistedAsTable } = require('../model/csnUtils');
|
|
6
|
-
|
|
7
|
-
function isKey(element) {
|
|
8
|
-
return element.key;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
sqlite: getFilterObject(
|
|
13
|
-
'sqlite',
|
|
14
|
-
(extend, name, element, error) => {
|
|
15
|
-
if(isKey(element)) { // Key must not be extended
|
|
16
|
-
error(null, ['definitions', extend, 'elements', name], {id: name, name: 'sqlite'}, "Added element $(ID) is a primary key change and will not work with $(NAME)")
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
(migrate, name, migration, change, error) => {
|
|
20
|
-
const newIsKey = isKey(migration.new);
|
|
21
|
-
const oldIsKey = isKey(migration.old);
|
|
22
|
-
if((newIsKey || oldIsKey) && oldIsKey !== newIsKey) { // Turned into key or key was removed
|
|
23
|
-
error(null, ['definitions', migrate, 'elements', name], {id: name, name: 'sqlite'}, "Changed element $(ID) is a primary key change and will not work with $(NAME)")
|
|
24
|
-
} else { // Ignore simple migrations
|
|
25
|
-
delete change[name];
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function getFilterObject(dialect, extensionCallback, migrationCallback) {
|
|
31
|
-
return {
|
|
32
|
-
// will be called with a simple Array.forEach
|
|
33
|
-
extension: ({ elements, extend }, error) => {
|
|
34
|
-
forEach(elements, (name, element) => {
|
|
35
|
-
extensionCallback(extend, name, element, error);
|
|
36
|
-
});
|
|
37
|
-
},
|
|
38
|
-
// will be called with a Array.map, as we need to filter "change" for SQLite
|
|
39
|
-
migration: ({ change, migrate, remove }, error) => {
|
|
40
|
-
forEach(remove, (name) => {
|
|
41
|
-
error(null, ['definitions', migrate, 'elements', name], {}, "Dropping elements is not supported")
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
forEach(change, (name, migration) => {
|
|
45
|
-
if(migration.new.type !== migration.old.type && typeChangeIsNotCompatible(dialect, migration.old.type, migration.new.type)) {
|
|
46
|
-
error(null, ['definitions', migrate, 'elements', name], { id: name, name: migration.old.type, type: migration.new.type }, "Changed element $(ID) is a lossy type change from $(NAME) to $(TYPE) and is not supported")
|
|
47
|
-
} else if(migration.new.length < migration.old.length) {
|
|
48
|
-
error(null, ['definitions', migrate, 'elements', name], { id: name }, "Changed element $(ID) is a length reduction and is not supported")
|
|
49
|
-
} else {
|
|
50
|
-
migrationCallback(migrate, name, migration, change, error);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// TODO: precision/scale growth
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
deletion: ([artifactName, artifact ], error) => {
|
|
57
|
-
if(isPersistedAsTable(artifact))
|
|
58
|
-
error(null, ['definitions', artifactName], "Dropping tables is not supported");
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const baseMatrix = {
|
|
64
|
-
// Integer types
|
|
65
|
-
'cds.hana.tinyint':['cds.UInt8', 'cds.Int16', 'cds.Int32', 'cds.Integer', 'cds.Int64', 'cds.Integer64'],
|
|
66
|
-
'cds.UInt8': ['cds.hana.tinyint', 'cds.Int16', 'cds.Int32', 'cds.Integer', 'cds.Int64', 'cds.Integer64'],
|
|
67
|
-
'cds.Int16': ['cds.hana.smallint', 'cds.Int32', 'cds.Integer', 'cds.Int64', 'cds.Integer64'],
|
|
68
|
-
'cds.hana.smallint':['cds.Int16', 'cds.Int32', 'cds.Integer', 'cds.Int64', 'cds.Integer64'],
|
|
69
|
-
'cds.Int32': ['cds.Integer', 'cds.Int64', 'cds.Integer64'],
|
|
70
|
-
'cds.Integer': ['cds.Int32', 'cds.Int64', 'cds.Integer64'],
|
|
71
|
-
'cds.Integer64': ['cds.Int64'],
|
|
72
|
-
'cds.Int64': ['cds.Integer64']
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const allowedTypeChanges = {
|
|
76
|
-
'sqlite': baseMatrix
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
function typeChangeIsNotCompatible(dialect, before, after) {
|
|
80
|
-
if(allowedTypeChanges[dialect])
|
|
81
|
-
return allowedTypeChanges[dialect][before]?.indexOf(after) === -1;
|
|
82
|
-
return true;
|
|
83
|
-
}
|