@sap/cds-compiler 3.3.2 → 3.4.2

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 (76) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/bin/cdsc.js +3 -1
  3. package/doc/CHANGELOG_BETA.md +17 -0
  4. package/lib/api/main.js +147 -18
  5. package/lib/api/validate.js +8 -3
  6. package/lib/base/dictionaries.js +6 -6
  7. package/lib/base/keywords.js +104 -0
  8. package/lib/base/message-registry.js +137 -68
  9. package/lib/base/messages.js +59 -48
  10. package/lib/base/model.js +1 -0
  11. package/lib/checks/actionsFunctions.js +1 -1
  12. package/lib/checks/cdsPersistence.js +1 -1
  13. package/lib/checks/checkForTypes.js +13 -8
  14. package/lib/checks/defaultValues.js +3 -1
  15. package/lib/checks/elements.js +1 -1
  16. package/lib/checks/parameters.js +4 -2
  17. package/lib/checks/queryNoDbArtifacts.js +1 -1
  18. package/lib/checks/sql-snippets.js +12 -10
  19. package/lib/checks/validator.js +14 -4
  20. package/lib/compiler/assert-consistency.js +8 -7
  21. package/lib/compiler/checks.js +30 -20
  22. package/lib/compiler/define.js +89 -25
  23. package/lib/compiler/extend.js +33 -28
  24. package/lib/compiler/finalize-parse-cdl.js +14 -9
  25. package/lib/compiler/populate.js +30 -8
  26. package/lib/compiler/propagator.js +23 -28
  27. package/lib/compiler/resolve.js +11 -5
  28. package/lib/compiler/shared.js +66 -48
  29. package/lib/compiler/tweak-assocs.js +2 -3
  30. package/lib/compiler/utils.js +11 -0
  31. package/lib/edm/annotations/genericTranslation.js +7 -4
  32. package/lib/edm/csn2edm.js +1 -1
  33. package/lib/gen/language.checksum +1 -1
  34. package/lib/gen/language.interp +1 -1
  35. package/lib/gen/languageParser.js +3565 -3544
  36. package/lib/json/csnVersion.js +13 -13
  37. package/lib/json/from-csn.js +140 -158
  38. package/lib/json/to-csn.js +23 -5
  39. package/lib/language/.eslintrc.json +4 -0
  40. package/lib/language/antlrParser.js +7 -10
  41. package/lib/language/docCommentParser.js +1 -2
  42. package/lib/language/errorStrategy.js +54 -27
  43. package/lib/language/genericAntlrParser.js +115 -84
  44. package/lib/language/language.g4 +29 -25
  45. package/lib/language/multiLineStringParser.js +75 -63
  46. package/lib/main.js +1 -0
  47. package/lib/model/csnRefs.js +4 -3
  48. package/lib/model/csnUtils.js +39 -7
  49. package/lib/model/sortViews.js +7 -3
  50. package/lib/modelCompare/compare.js +49 -15
  51. package/lib/modelCompare/filter.js +83 -0
  52. package/lib/optionProcessor.js +5 -1
  53. package/lib/render/manageConstraints.js +9 -5
  54. package/lib/render/toCdl.js +120 -62
  55. package/lib/render/toHdbcds.js +1 -1
  56. package/lib/render/toSql.js +6 -2
  57. package/lib/render/utils/common.js +7 -0
  58. package/lib/sql-identifier.js +7 -0
  59. package/lib/transform/db/assertUnique.js +27 -38
  60. package/lib/transform/db/expansion.js +11 -4
  61. package/lib/transform/db/temporal.js +3 -1
  62. package/lib/transform/db/transformExists.js +7 -1
  63. package/lib/transform/db/views.js +42 -13
  64. package/lib/transform/draft/db.js +2 -2
  65. package/lib/transform/forOdataNew.js +7 -3
  66. package/lib/transform/forRelationalDB.js +12 -6
  67. package/lib/transform/localized.js +1 -1
  68. package/lib/transform/odata/typesExposure.js +2 -1
  69. package/lib/transform/parseExpr.js +245 -0
  70. package/lib/transform/transformUtilsNew.js +23 -14
  71. package/lib/transform/translateAssocsToJoins.js +12 -12
  72. package/lib/transform/universalCsn/universalCsnEnricher.js +1 -0
  73. package/lib/utils/term.js +5 -5
  74. package/package.json +2 -2
  75. package/share/messages/message-explanations.json +1 -1
  76. package/share/messages/{syntax-expected-integer.md → syntax-expecting-integer.md} +1 -1
@@ -6,7 +6,6 @@ const oDataDictionary = require('../../gen/Dictionary.json');
6
6
  const { forEachDefinition } = require('../../model/csnUtils');
7
7
  const { forEach } = require("../../utils/objectUtils");
8
8
 
9
-
10
9
  /*
11
10
  OASIS: https://github.com/oasis-tcs/odata-vocabularies/tree/master/vocabularies
12
11
  Aggregation (published)
@@ -562,6 +561,9 @@ function csn2annotationEdm(csn, serviceName, Edm = undefined, options=undefined,
562
561
  alternativeEdmTargetName = serviceName + '.EntityContainer/' + alternativeEdmTargetName.substr(lastDotIndex + 1);
563
562
  hasAlternativeCarrier = carrier.$hasEntitySet;
564
563
  }
564
+ else if(carrier.kind === 'type') {
565
+ testToStandardEdmTarget = (x => x ? x.includes(carrier.elements ? 'ComplexType' : 'TypeDefinition') : true);
566
+ }
565
567
  else if (carrier.kind === 'service') {
566
568
  // if annotated object is a service, annotation goes to EntityContainer,
567
569
  // except if AppliesTo contains Schema but not EntityContainer, then annotation goes to Schema
@@ -653,14 +655,15 @@ function csn2annotationEdm(csn, serviceName, Edm = undefined, options=undefined,
653
655
  Insert $value into $edmJson with inner annotation as well.
654
656
  */
655
657
  if(innerAnnotation) {
656
- if(carrier[prefix]) {
658
+ // != null => also != undefined
659
+ if(carrier[prefix] != null) {
657
660
  const valPrefix = prefix + '.$value';
658
661
  carrier[valPrefix] = carrier[prefix];
659
662
  delete carrier[prefix];
660
663
  rc = true;
661
664
  }
662
665
  const edmJsonPrefix = prefix + '.$edmJson';
663
- if(carrier[edmJsonPrefix]) {
666
+ if(carrier[edmJsonPrefix] != null) {
664
667
  const valPrefix = prefix + '.$value.$edmJson';
665
668
  carrier[valPrefix] = carrier[edmJsonPrefix];
666
669
  delete carrier[edmJsonPrefix];
@@ -908,7 +911,7 @@ function csn2annotationEdm(csn, serviceName, Edm = undefined, options=undefined,
908
911
  oTarget.append(handleEdmJson(cAnnoValue['$edmJson'], context));
909
912
  }
910
913
  else if ( Object.keys(cAnnoValue).filter( x => x[0] !== '@' ).length === 0) {
911
- // object consists only of properties starting with "@"
914
+ // object consists only of properties starting with "@", no $value
912
915
  message(warning, context, 'nested annotations without corresponding base annotation');
913
916
  }
914
917
  else {
@@ -731,7 +731,7 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
731
731
 
732
732
  });
733
733
  if(options.isV2()) {
734
- if(streamProps.length > 1) {
734
+ if(streamProps.length > 1) { // TODO: why not mention 2.0 in text?
735
735
  error(null, ['definitions', elementsCsn.name], { names: streamProps, version: '2.0', anno: '@Core.MediaType' },
736
736
  `Expected only one element to be annotated with $(ANNO) for OData $(VERSION) but found $(NAMES)`);
737
737
  }
@@ -1 +1 @@
1
- d054015b5c1bda3f92422cb3f44733bb
1
+ 5a5c0432924af9c8833ad5aa6b94724f