@sap/cds-compiler 5.9.2 → 6.0.10

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.
Files changed (111) hide show
  1. package/CHANGELOG.md +109 -319
  2. package/README.md +1 -1
  3. package/bin/cds_update_identifiers.js +3 -5
  4. package/bin/cdsc.js +22 -8
  5. package/bin/cdshi.js +1 -1
  6. package/bin/cdsse.js +4 -4
  7. package/doc/CHANGELOG_BETA.md +11 -0
  8. package/doc/CHANGELOG_DEPRECATED.md +29 -0
  9. package/lib/api/main.js +8 -5
  10. package/lib/api/options.js +12 -10
  11. package/lib/base/builtins.js +1 -0
  12. package/lib/base/message-registry.js +190 -96
  13. package/lib/base/messages.js +29 -20
  14. package/lib/base/model.js +14 -24
  15. package/lib/checks/actionsFunctions.js +10 -20
  16. package/lib/checks/annotationsOData.js +1 -1
  17. package/lib/checks/elements.js +30 -10
  18. package/lib/checks/enums.js +31 -0
  19. package/lib/checks/foreignKeys.js +2 -2
  20. package/lib/checks/hasPersistedElements.js +5 -0
  21. package/lib/checks/invalidTarget.js +1 -1
  22. package/lib/checks/managedWithoutKeys.js +5 -4
  23. package/lib/checks/queryNoDbArtifacts.js +10 -8
  24. package/lib/checks/types.js +5 -5
  25. package/lib/checks/validator.js +6 -4
  26. package/lib/compiler/assert-consistency.js +12 -9
  27. package/lib/compiler/checks.js +18 -50
  28. package/lib/compiler/define.js +6 -6
  29. package/lib/compiler/extend.js +2 -1
  30. package/lib/compiler/generate.js +14 -17
  31. package/lib/compiler/populate.js +8 -31
  32. package/lib/compiler/propagator.js +21 -35
  33. package/lib/compiler/resolve.js +35 -22
  34. package/lib/compiler/shared.js +7 -1
  35. package/lib/compiler/tweak-assocs.js +1 -1
  36. package/lib/compiler/utils.js +1 -1
  37. package/lib/edm/annotations/edmJson.js +20 -15
  38. package/lib/edm/annotations/genericTranslation.js +7 -8
  39. package/lib/edm/csn2edm.js +46 -50
  40. package/lib/edm/edm.js +8 -7
  41. package/lib/edm/edmPreprocessor.js +37 -85
  42. package/lib/edm/edmUtils.js +2 -2
  43. package/lib/gen/BaseParser.js +55 -44
  44. package/lib/gen/CdlGrammar.checksum +1 -1
  45. package/lib/gen/CdlParser.js +1133 -1150
  46. package/lib/json/from-csn.js +70 -43
  47. package/lib/json/to-csn.js +6 -8
  48. package/lib/language/multiLineStringParser.js +3 -2
  49. package/lib/main.d.ts +58 -24
  50. package/lib/model/csnUtils.js +28 -39
  51. package/lib/model/xprAsTree.js +23 -9
  52. package/lib/modelCompare/compare.js +5 -4
  53. package/lib/optionProcessor.js +21 -17
  54. package/lib/parsers/AstBuildingParser.js +63 -11
  55. package/lib/parsers/XprTree.js +57 -3
  56. package/lib/parsers/identifiers.js +1 -1
  57. package/lib/parsers/index.js +0 -3
  58. package/lib/render/manageConstraints.js +25 -25
  59. package/lib/render/toCdl.js +173 -170
  60. package/lib/render/toHdbcds.js +126 -128
  61. package/lib/render/toRename.js +7 -7
  62. package/lib/render/toSql.js +128 -125
  63. package/lib/render/utils/common.js +47 -22
  64. package/lib/render/utils/delta.js +25 -25
  65. package/lib/render/utils/operators.js +2 -2
  66. package/lib/render/utils/pretty.js +5 -5
  67. package/lib/render/utils/sql.js +13 -13
  68. package/lib/render/utils/standardDatabaseFunctions.js +115 -103
  69. package/lib/render/utils/unique.js +4 -4
  70. package/lib/transform/db/applyTransformations.js +1 -1
  71. package/lib/transform/db/assertUnique.js +2 -2
  72. package/lib/transform/db/associations.js +6 -7
  73. package/lib/transform/db/assocsToQueries/utils.js +4 -5
  74. package/lib/transform/db/backlinks.js +12 -9
  75. package/lib/transform/db/cdsPersistence.js +8 -7
  76. package/lib/transform/db/constraints.js +13 -10
  77. package/lib/transform/db/expansion.js +7 -3
  78. package/lib/transform/db/flattening.js +4 -14
  79. package/lib/transform/db/processSqlServices.js +2 -1
  80. package/lib/transform/db/temporal.js +5 -7
  81. package/lib/transform/db/views.js +2 -4
  82. package/lib/transform/draft/db.js +8 -8
  83. package/lib/transform/draft/odata.js +10 -7
  84. package/lib/transform/forOdata.js +10 -5
  85. package/lib/transform/forRelationalDB.js +5 -75
  86. package/lib/transform/localized.js +1 -1
  87. package/lib/transform/odata/createForeignKeys.js +11 -10
  88. package/lib/transform/odata/flattening.js +8 -4
  89. package/lib/transform/odata/foreignKeyRefsInXprAnnos.js +96 -0
  90. package/lib/transform/odata/typesExposure.js +3 -3
  91. package/lib/transform/transformUtils.js +4 -8
  92. package/lib/transform/translateAssocsToJoins.js +14 -7
  93. package/lib/transform/universalCsn/universalCsnEnricher.js +10 -4
  94. package/lib/utils/objectUtils.js +0 -17
  95. package/package.json +10 -13
  96. package/share/messages/def-upcoming-virtual-change.md +1 -1
  97. package/LICENSE +0 -37
  98. package/bin/cds_remove_invalid_whitespace.js +0 -138
  99. package/doc/CHANGELOG_ARCHIVE.md +0 -3604
  100. package/lib/gen/genericAntlrParser.js +0 -3
  101. package/lib/gen/language.checksum +0 -1
  102. package/lib/gen/language.interp +0 -456
  103. package/lib/gen/language.tokens +0 -180
  104. package/lib/gen/languageLexer.interp +0 -439
  105. package/lib/gen/languageLexer.js +0 -1483
  106. package/lib/gen/languageLexer.tokens +0 -167
  107. package/lib/gen/languageParser.js +0 -24941
  108. package/lib/language/antlrParser.js +0 -205
  109. package/lib/language/errorStrategy.js +0 -646
  110. package/lib/language/genericAntlrParser.js +0 -1572
  111. package/lib/parsers/CdlGrammar.g4 +0 -2070
@@ -11,6 +11,35 @@ Note: `deprecated` features are listed in this ChangeLog just for information.
11
11
  **When the `deprecated` option is set, the `beta` option is ignored,
12
12
  and several new features are not available.**
13
13
 
14
+ ## Version 6.0.8 - 2025-05-23
15
+
16
+ ### Added `noQuasiVirtualAssocs`
17
+
18
+ If set, managed to-many associations will get foreign keys again.
19
+ In cds-compiler v6, managed to-many associations without explicit foreign keys
20
+ don't get `keys` anymore. This flag restores v5 behavior.
21
+
22
+ ### Added `noCompositionIncludes`
23
+
24
+ If set, generated entities for composition-of-named-aspect will not
25
+ get an `includes` property.
26
+
27
+ ### Added `noPersistenceJournalForGeneratedEntities`
28
+
29
+ If set, `@cds.persistence.journal` will _not_ be propagated to generated entities,
30
+ including generated `.texts` entities for localized entities, nor generated entities
31
+ for compositions-of-aspect.
32
+
33
+ In cds-compiler v6, this annotation is copied to `.texts` entities as well as
34
+ generated composition-of-aspect entities it by default.
35
+
36
+ ### Removed `includesNonShadowedFirst`
37
+
38
+ ### Removed `eagerPersistenceForGeneratedEntities`
39
+
40
+ ### Removed `noKeyPropagationWithExpansions`
41
+
42
+
14
43
  ## Version 4.2.0 - 2023-08-29
15
44
 
16
45
  ### Added `noKeyPropagationWithExpansions`
package/lib/api/main.js CHANGED
@@ -481,6 +481,9 @@ function sqlMigration( csn, options, messageFunctions, beforeImage ) {
481
481
  messageFunctions.throwWithError();
482
482
  }
483
483
 
484
+ if (!internalOptions.script && internalOptions.sqlDialect === 'hana')
485
+ messageFunctions.warning('api-invalid-combination', null, { '#': 'hana-migration', value: internalOptions.sqlDialect });
486
+
484
487
  if (internalOptions.script && !internalOptions.severities?.['migration-unsupported-key-change']) {
485
488
  internalOptions.severities = Object.assign({}, internalOptions.severities ?? {});
486
489
  internalOptions.severities['migration-unsupported-key-change'] = 'Warning';
@@ -567,7 +570,7 @@ function sqlMigration( csn, options, messageFunctions, beforeImage ) {
567
570
  const name = stack.pop();
568
571
  const artifact = diff.definitions[name];
569
572
  if (drops.creates[name] === undefined) {
570
- if (artifact['@cds.persistence.skip'] && markedSkipByUs[name]) {
573
+ if (csnUtils.hasPersistenceSkipAnnotation(artifact) && markedSkipByUs[name]) {
571
574
  // Remove the skip so we render a CREATE VIEW
572
575
  diff.definitions[name]['@cds.persistence.skip'] = false;
573
576
  drops.creates[name] = `DROP VIEW ${ identifierUtils.renderArtifactName(name) };`;
@@ -752,8 +755,8 @@ function hdbcds( csn, options, messageFunctions ) {
752
755
  messageFunctions.setOptions( internalOptions );
753
756
 
754
757
  // Since v5, the HDBCDS backend is considered deprecated.
755
- // TODO(v6): Make this a configurable error
756
- messageFunctions.warning('api-deprecated-v5', null, null);
758
+ // Since v6, it is a configurable error.
759
+ messageFunctions.message('api-deprecated-hdbcds', null, null);
757
760
 
758
761
  if (options.tenantDiscriminator) {
759
762
  messageFunctions.error('api-invalid-option', null, {
@@ -816,7 +819,7 @@ function edmall( csn, options, messageFunctions ) {
816
819
  const { error } = messageFunctions;
817
820
 
818
821
  if (internalOptions.odataVersion === 'v2')
819
- error(null, null, {}, 'OData JSON output is not available for OData V2');
822
+ error('api-invalid-option', null, { '#': 'odataV2json' });
820
823
 
821
824
  const result = {};
822
825
  let oDataCsn = csn;
@@ -966,7 +969,7 @@ function odataall( csn, options, messageFunctions ) {
966
969
  const { error } = messageFunctions;
967
970
 
968
971
  if (internalOptions.odataVersion === 'v2')
969
- error(null, null, {}, 'OData JSON output is not available for OData V2');
972
+ error('api-invalid-option', null, { '#': 'odataV2json' });
970
973
 
971
974
  let oDataCsn = csn;
972
975
  if (isPreTransformed(csn, 'odata')) {
@@ -20,7 +20,6 @@ const publicOptionsNewAPI = [
20
20
  'defaultBinaryLength',
21
21
  'defaultStringLength',
22
22
  'csnFlavor',
23
- 'compositionIncludes',
24
23
  // DB
25
24
  'sqlDialect',
26
25
  'sqlMapping',
@@ -35,6 +34,7 @@ const publicOptionsNewAPI = [
35
34
  'withHanaAssociations',
36
35
  'standardDatabaseFunctions',
37
36
  'booleanEquality',
37
+ 'dollarNowAsTimestamp',
38
38
  // ODATA
39
39
  'odataOpenapiHints',
40
40
  'edm4OpenAPI',
@@ -86,7 +86,7 @@ const privateOptions = [
86
86
  'internalMsg',
87
87
  'disableHanaComments', // in case of issues with hana comment rendering
88
88
  'tenantDiscriminator', // not published yet
89
- 'localizedWithoutCoalesce', // deprecated version of 'localizedLanguageFallback', TODO(v6): Remove option
89
+ 'localizedWithoutCoalesce', // deprecated version of 'localizedLanguageFallback', TODO(v7): Remove option
90
90
  ];
91
91
 
92
92
  const overallOptions = publicOptionsNewAPI.concat(privateOptions);
@@ -156,7 +156,7 @@ function reclassifyErrorsForOpenApi( options ) {
156
156
  // shallow clone, so that we can modify severities without changing the user's.
157
157
  options.severities = Object.assign({}, options.severities ?? {});
158
158
 
159
- options.severities['odata-spec-violation-no-key'] = 'Warning';
159
+ options.severities['odata-missing-key'] = 'Warning';
160
160
  }
161
161
  }
162
162
 
@@ -164,10 +164,9 @@ function reclassifyErrorsForOpenApi( options ) {
164
164
  module.exports = {
165
165
  to: {
166
166
  cdl: (options) => {
167
- // TODO(v6): Change defaults to 'true'
168
167
  const defaultOptions = {
169
- renderCdlDefinitionNesting: false,
170
- renderCdlCommonNamespace: false,
168
+ renderCdlDefinitionNesting: true,
169
+ renderCdlCommonNamespace: true,
171
170
  };
172
171
  return translateOptions(options, defaultOptions, undefined, undefined, undefined, 'to.cdl');
173
172
  },
@@ -176,8 +175,9 @@ module.exports = {
176
175
  const defaultOptions = {
177
176
  sqlMapping: 'plain',
178
177
  sqlDialect: 'plain',
179
- withHanaAssociations: true,
180
- booleanEquality: false,
178
+ withHanaAssociations: false,
179
+ booleanEquality: true,
180
+ dollarNowAsTimestamp: false,
181
181
  };
182
182
  const processed = translateOptions(options, defaultOptions, hardOptions, undefined, [ 'sql-dialect-and-naming' ], 'to.sql');
183
183
 
@@ -189,8 +189,9 @@ module.exports = {
189
189
  const defaultOptions = {
190
190
  sqlMapping: 'plain',
191
191
  sqlDialect: 'hana',
192
- withHanaAssociations: true,
193
- booleanEquality: false,
192
+ withHanaAssociations: false,
193
+ booleanEquality: true,
194
+ dollarNowAsTimestamp: false,
194
195
  };
195
196
  return translateOptions(options, defaultOptions, hardOptions, { sqlDialect: generateStringValidator([ 'hana' ]) }, undefined, 'to.hdi');
196
197
  },
@@ -201,6 +202,7 @@ module.exports = {
201
202
  sqlMapping: 'plain',
202
203
  sqlDialect: 'hana',
203
204
  booleanEquality: false,
205
+ dollarNowAsTimestamp: true, // Keep v5 behavior; backend is deprecated
204
206
  };
205
207
  return translateOptions(options, defaultOptions, hardOptions, { sqlDialect: generateStringValidator([ 'hana' ]) }, undefined, 'to.hdbcds');
206
208
  },
@@ -41,6 +41,7 @@ function isInReservedNamespace( absolute ) {
41
41
  return absolute === 'cds' || absolute.startsWith( 'cds.' ) &&
42
42
  !absolute.match( /^cds\.foundation(\.|$)/ ) &&
43
43
  !absolute.match( /^cds\.outbox(\.|$)/ ) && // Requested by Node runtime
44
+ !absolute.match( /^cds\.core(\.|$)/ ) && // Requested by Node runtime
44
45
  !absolute.match( /^cds\.xt(\.|$)/ ); // Requested by Mtx
45
46
  }
46
47